In this lesson we show you how to teach the NVIDIA Jetson Nano to talk. We show two different ways. In the first, we use the espeak TTS engine. We then show how to do it with gTTS. We compare and contrast the pros and cons of each technique.
Robotics Training LESSON 15: Using the BLE Bluetooth Module for Robotic Control
In this lesson we show how to control the Elegoo Smart Car Robot Kit using the Bluetooth module. This allows much more accurate control than what was possible with the IR Remote. Below is the code which we developed in the lesson.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
int ENA=5; int ENB=6; int IN1=7; int IN2=8; int IN3=9; int IN4=11; float d=1; int degRot=90; int left; int right; float v=1.2; int rv; char cmd; void setup() { // put your setup code here, to run once: Serial.begin(9600); pinMode(ENA,OUTPUT); pinMode(ENB,OUTPUT); pinMode(IN1,OUTPUT); pinMode(IN2,OUTPUT); pinMode(IN3,OUTPUT); pinMode(IN4,OUTPUT); digitalWrite(ENA,HIGH); digitalWrite(ENB,HIGH); } void loop() { int wv; //v=1.2; //d=1; wv=(v-.35)/.0075; left=wv; right=wv; setSpeed(left,right); while (Serial.available()==0){ } cmd=Serial.read(); if (cmd=='G'){ Serial.println("Forward"); forward(d,v); } if (cmd=='B'){ Serial.println("Backward"); backward(d,v); } if (cmd=='R'){ Serial.println("Right"); turnRight(degRot,wv); } if (cmd=='L'){ Serial.println("Left"); turnLeft(degRot,wv); } //If Command Was Pound, Set Distance if (cmd=='d'){ Serial.println("Set distance"); delay(500); while (Serial.available()==0){ } cmd=Serial.read(); if (cmd=='1'){ Serial.println("Distance=1"); d=1; } if (cmd=='2'){ Serial.println("Distance=2"); d=2; } if (cmd=='3'){ Serial.println("Distance=3"); d=3; } if (cmd=='4'){ Serial.println("Distance=4"); d=4; } if (cmd=='5'){ Serial.println("Distance=5"); d=5; } if (cmd=='6'){ Serial.println("Distance=6"); d=6; } if (cmd=='7'){ Serial.println("Distance=7"); d=7; } if (cmd=='8'){ Serial.println("Distance=8"); d=8; } if (cmd=='9'){ Serial.println("Distance=9"); d=9; } } //If Command Was star, Set Speed if (cmd=='v'){ Serial.println("Set speed"); delay(500); while (Serial.available()==0){ } delay(100); cmd=Serial.read(); if (cmd=='1'){ Serial.println("rv=1"); rv=1; } if (cmd=='2'){ Serial.println("rv=2"); rv=2; } if (cmd=='3'){ Serial.println("rv=3"); rv=3; } if (cmd=='4'){ Serial.println("rv=4"); rv=4; } if (cmd=='5'){ Serial.println("rv=5"); rv=5; } if (cmd=='6'){ Serial.println("rv=6"); rv=6; } if (cmd=='7'){ Serial.println("rv=7"); rv=7; } if (cmd=='8'){ Serial.println("rv=8"); rv=8; } if (cmd=='9'){ Serial.println("rv=9"); rv=9; } v=(1.16/9.)*rv+1.1; } } void setSpeed(int leftVal,int rightVal){ analogWrite(ENA,leftVal); analogWrite(ENB,rightVal); } void forward(float d, float v){ float t; digitalWrite(IN1,HIGH); digitalWrite(IN2,LOW); digitalWrite(IN3,LOW); digitalWrite(IN4,HIGH); t=d/v*1000; delay(t); stopCar(); } void backward(float d, float v){ float t; digitalWrite(IN1,LOW); digitalWrite(IN2,HIGH); digitalWrite(IN3,HIGH); digitalWrite(IN4,LOW); t=d/v*1000; delay(t); stopCar(); } void turnRight(int deg, int wv){ float t; stopCar(); delay(100); analogWrite(ENA,125); analogWrite(ENB,125); digitalWrite(IN1,HIGH); digitalWrite(IN2,LOW); digitalWrite(IN3,HIGH); digitalWrite(IN4,LOW); t=(deg+6)/136.29*1000.; delay(t); stopCar(); analogWrite(ENA,wv); analogWrite(ENB,wv); } void turnLeft(int deg, int wv){ float t; analogWrite(ENA,125); analogWrite(ENB,125); digitalWrite(IN1,LOW); digitalWrite(IN2,HIGH); digitalWrite(IN3,LOW); digitalWrite(IN4,HIGH); t=(deg+6)/136.29*1000.; delay(t); stopCar(); analogWrite(ENA,wv); analogWrite(ENB,wv); } void stopCar(){ digitalWrite(IN1,LOW); digitalWrite(IN2,LOW); digitalWrite(IN3,LOW); digitalWrite(IN4,LOW); } void calF(){ digitalWrite(IN1,HIGH); digitalWrite(IN2,LOW); digitalWrite(IN3,LOW); digitalWrite(IN4,HIGH); delay(5000); stopCar(); } void calB(){ digitalWrite(IN1,LOW); digitalWrite(IN2,HIGH); digitalWrite(IN3,HIGH); digitalWrite(IN4,LOW); delay(5000); stopCar(); } void calR(int wv){ stopCar(); analogWrite(ENA,125); analogWrite(ENB,125); digitalWrite(IN1,HIGH); digitalWrite(IN2,LOW); digitalWrite(IN3,HIGH); digitalWrite(IN4,LOW); delay(3000); analogWrite(ENA,wv); analogWrite(ENB,wv); stopCar(); } void calL(int wv){ analogWrite(ENA,125); analogWrite(ENB,125); digitalWrite(IN1,LOW); digitalWrite(IN2,HIGH); digitalWrite(IN3,LOW); digitalWrite(IN4,HIGH); delay(5000); analogWrite(ENA,wv); analogWrite(ENB,wv); stopCar(); } |
AI on the Jetson Nano LESSON 59: PWM on the GPIO Pins of the Jetson Nano
In this lesson we show how to configure the GPIO pins on the Jetson Nano to produce PWM signals. We show how the PWM libraries can be run in python. The Jetson Nano can provide Pulse Width Modulation signals on two physical pins, pins 32 and 33. We take you through the step by step process in the video above.
Robotics Training LESSON 14: Using the BLE Bluetooth Module to Control the Arduino Elegoo Smart Car
In this lesson we learn how to use bluetooth with the Arduino. We show how you can control the Elegoo Smart Car from a Bluetooth App. We show how to download the app on your phone, and then how to program the Ap to control the smart car.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
int ENA=5; int ENB=6; int IN1=7; int IN2=8; int IN3=9; int IN4=11; float d; int degRot; char cmd; void setup() { // put your setup code here, to run once: Serial.begin(9600); pinMode(ENA,OUTPUT); pinMode(ENB,OUTPUT); pinMode(IN1,OUTPUT); pinMode(IN2,OUTPUT); pinMode(IN3,OUTPUT); pinMode(IN4,OUTPUT); digitalWrite(ENA,HIGH); digitalWrite(ENB,HIGH); } void loop() { while (Serial.available()==0){ } cmd=Serial.read(); if (cmd=='f'){ forward(4); } if (cmd=='b'){ backward(4); } if (cmd=='r'){ turnRight(180); } if (cmd=='l'){ turnLeft(180); } } void forward(float d){ float t; digitalWrite(IN1,HIGH); digitalWrite(IN2,LOW); digitalWrite(IN3,LOW); digitalWrite(IN4,HIGH); t=d/2.45*1000; delay(t); stopCar(); } void backward(float d){ float t; digitalWrite(IN1,LOW); digitalWrite(IN2,HIGH); digitalWrite(IN3,HIGH); digitalWrite(IN4,LOW); t=d/2.45*1000; delay(t); stopCar(); } void turnRight(int deg){ float t; digitalWrite(IN1,HIGH); digitalWrite(IN2,LOW); digitalWrite(IN3,HIGH); digitalWrite(IN4,LOW); t=deg/345.*1000.; Serial.println(deg); delay(t); stopCar(); } void turnLeft(float deg){ float t; digitalWrite(IN1,LOW); digitalWrite(IN2,HIGH); digitalWrite(IN3,LOW); digitalWrite(IN4,HIGH); t=deg/345.*1000.; Serial.println(deg); delay(t); stopCar(); } void stopCar(){ digitalWrite(IN1,LOW); digitalWrite(IN2,LOW); digitalWrite(IN3,LOW); digitalWrite(IN4,LOW); } void calF(){ digitalWrite(IN1,HIGH); digitalWrite(IN2,LOW); digitalWrite(IN3,LOW); digitalWrite(IN4,HIGH); delay(5000); stopCar(); } void calB(){ digitalWrite(IN1,LOW); digitalWrite(IN2,HIGH); digitalWrite(IN3,HIGH); digitalWrite(IN4,LOW); delay(5000); stopCar(); } void calR(){ digitalWrite(IN1,HIGH); digitalWrite(IN2,LOW); digitalWrite(IN3,HIGH); digitalWrite(IN4,LOW); delay(5000); stopCar(); } void calL(){ digitalWrite(IN1,LOW); digitalWrite(IN2,HIGH); digitalWrite(IN3,LOW); digitalWrite(IN4,HIGH); delay(5000); stopCar(); } |
AI on the Jetson Nano LESSON 58: Controlling an LED With GPIO Pins and Button Switch
In this lesson we show you how to control a simple LED circuit using the GPIO pins on the Jetson Nano. We use pull up resistors to connect a push button to the Jetson Nano GPIO pins. We create a toggle switch where the light turns off when the button is pressed, and then turns it back on when pressed again.