Components and supplies
Jumper wires (generic)
LED (generic)
Breadboard (generic)
5V Power Bank
ESP8266 ESP-01
Arduino UNO
USB-A to B Cable
Resistor 221 ohm
9V battery (generic)
Dual H-Bridge motor drivers L293D
DC motor (generic)
Tools and machines
Cutter
Scissors
ScrewDriver
Apps and platforms
Google Chrome
Project description
Code
M-Car_Source_Code
arduino
The M-Car Source Code :D
1/* 2 /| //| | // ) ) 3 //| // | | // ___ __ 4 // | // | | ____ // // ) ) // ) ) 5 // | // | | // // / / // 6// |// | | ((____/ / ((___( ( // */ 7 8 9/* _____ _______ ______ _______ _________ _______ 10 / ___ \ ( ____ )/ ___ \( ____ )\\__ __/( ____ \\|\ /| 11 / / _ \\| ( )|\\/ \ \\| ( )| ) ( | ( \\/| ) ( | 12( ( / \) )| (____)| ___) /| (____)| | | | (_____ | (___) | 13| |(()// / | _____) (___ ( | __) | | (_____ )| ___ | 14( ( \\___/ | ( ) \\| (\( | | ) || ( ) | 15 \\\____/\| ) /\\___/ /| ) \\\_____) (___/\\____) || ) ( | 16 \\______/ |/ \\______/ |/ \\__/\\_______/\\_______)|/ \\| */ 17 18 19/* 20--.-- --.-- .-. .-. .--. .---. 21 | | ( )( ) : | o 22 | | `-. `-. | --. |--- .-. .--..--..-. .--.. .--. 23 | | ( )( ) : | | (.-' | | ( ) | | `--. 24--'--o--'--o`-'o `-' `--'o' `--'' ' `-'`-' -' `-`--' */ 25/* 26Before sending the program to the Arduino board , 27make sure the connections are correct , 28which has as its browser Google Chrome , 29and you have a Wifi connection. */ 30/* Instructions */ /* Instructions */ /* Instructions */ 31/* 321) Send the program to the Arduino board . 332) Wait 20 seconds to complete initialization of the Wifi Shiled (ESP8266) . 343) Connect your phone to the Wifi connection : " Ai- Thinker " . 354) Open Google Chrome and go to address " 192.168.4.1 " . 365) HAVE FUN !. 37 */ 38 39#include <SoftwareSerial.h> 40#include <String.h> 41#include <Servo.h> 42#define DEBUG true 43SoftwareSerial esp8266 (10,11); 44Servo frontWheel; 45int blueLed = 12; int redLed = 8; int greenLed = 13; 46/* Ruota posteriore destra */ 47const int enablePinRight = 9; //Aziona il ponte H. 48const int forwardVerseRight = 4; //Fa andare il motore destro in avanti. 49const int backVerseRight = 3; //Fa andare il motore destro indietro. 50/* Fine dichiazioni ruota posteriore destra */ 51/* Ruota posteriore sinistra */ 52const int enablePinLeft = 6; //Aziona il ponte H. 53const int forwardVerseLeft = 2; //Fa andare il motore sinistro in avanti. 54const int backVerseLeft = 5; //Fa andare il motore sinistro indietro. 55/* Fine dichiazioni ruota posteriore sinistra */ 56String webPage = "<html><head><title>M-Car</title><link rel='shortcut icon' type='image/x-icon' href='http://arduino.cc/en/favicon.png' /></head><body bgcolor='grey'><p align='center'><button><a href='/?Power=1'>Avvia Motore</a></button></p><br><p align='left'><button><a href='/?Turn=2'>Gira a Sinistra</a></button><p align='right'><button><a href='/?Turn=3'>Gira a Destra</a></button></p></p><br><p align='center'><button><a href='/?Turn=4'>Vai Dritto</a></button></p><br><p align='center'><button><a href='/?Power=0'>Spegni Motore</a></button></p></body></html>"; 57String search = ""; 58int startPos = 90; int pos; 59void setup (){ 60 Serial.begin (115200); 61 esp8266.begin (115200); 62 frontWheel.attach (7); 63 pinMode (blueLed,OUTPUT); 64 pinMode (redLed,OUTPUT); 65 pinMode (greenLed,OUTPUT); 66 pinMode (enablePinRight,OUTPUT); 67 pinMode (forwardVerseRight,OUTPUT); 68 pinMode (backVerseRight,OUTPUT); 69 pinMode (enablePinLeft,OUTPUT); 70 pinMode (backVerseLeft,OUTPUT); 71 pinMode (forwardVerseLeft,OUTPUT); 72 esp8266.print ("AT+RST\ \ 73"); /*Resetta il modulo.*/ delay (2000); 74 esp8266.print ("AT+CWMODE=2\ \ 75"); /*Imposta il modulo come punto di accesso.*/ delay (2000); 76 esp8266.print ("AT+CIFSR\ \ 77"); /*Localizza l'indirizzo ip.*/ delay (2000); 78 esp8266.print ("AT+CIPMUX=1\ \ 79"); /*Imposta la connessione multipla.*/ delay (2000); 80 esp8266.print ("AT+CIPSERVER=1,80\ \ 81"); /*Crea il server sulla porta 80.*/ delay (2000); 82 Serial.println ("Inizzializzazione avvenuta con successo!"); 83 digitalWrite (greenLed,HIGH); 84 digitalWrite (enablePinRight,HIGH); 85 digitalWrite (enablePinLeft,HIGH); 86 frontWheel.write (startPos); 87} 88void loop (){ 89 while (esp8266.available()){ 90 char data = esp8266.read(); 91 search.concat (data); 92 } 93 if (esp8266.find("+IPD,")){ //Se la connessione avvenuta con successo... 94 if (search.indexOf("Power=1")>-1){ 95 Serial.println ("Motori Accesi!"); 96 digitalWrite(backVerseRight, LOW); 97 digitalWrite(forwardVerseRight, HIGH); 98 digitalWrite(backVerseLeft, LOW); 99 digitalWrite(forwardVerseLeft, HIGH); 100 } 101 if (search.indexOf("Turn=2")>0){ 102 Serial.println ("Giro a Sinistra"); 103 frontWheel.write (80); 104 } 105 if (search.indexOf("Turn=3")>0){ 106 Serial.println ("Giro a Destra"); 107 frontWheel.write (105); 108 } 109 if (search.indexOf("Turn=4")>0){ 110 Serial.println ("Vado Dritto"); 111 frontWheel.write (90); 112 } 113 if (search.indexOf("Power=0")>0){ 114 Serial.println ("Motori Spenti"); 115 digitalWrite(backVerseRight, LOW); 116 digitalWrite(forwardVerseRight, LOW); 117 digitalWrite(backVerseLeft, LOW); 118 digitalWrite(forwardVerseLeft, LOW); 119 } 120 int netId = esp8266.read() -48; 121 esp8266.print (sendToEsp(netId,webPage.length())); 122 esp8266.print (webPage); //Mostra la pagina.. 123 esp8266.print (closeEsp(netId)); 124 search = ""; 125 blink (); //Lampeggia :D 126 } 127} 128String sendToEsp (int id,int webpageLength){ //Funzione per l'invio di dati al modulo. 129 String data = "AT+CIPSEND="; 130 data += id; 131 data += ","; 132 data += webpageLength; 133 data += "\ \ 134"; 135 return data; 136} 137String closeEsp (int id){ //Funzione per la chiusura di connessione. 138 String closeConnection = "AT+CIPCLOSE="; 139 closeConnection += id; 140 closeConnection += "\ \ 141"; 142 return closeConnection; 143} 144void blink (void){ 145 digitalWrite (blueLed,HIGH); 146 delay (1000); 147 digitalWrite (blueLed,LOW); 148 digitalWrite (redLed,HIGH); 149 delay (1000); 150 digitalWrite (redLed,LOW); 151 152} 153
M-Car_Source_Code
arduino
The M-Car Source Code :D
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 o 35 | | `-. `-. | --. |--- .-. .--..--..-. 36 .--.. .--. 37 | | ( )( ) : | | (.-' | | ( ) | | `--. 38--'--o--'--o`-'o 39 `-' `--'o' `--'' ' `-'`-' -' `-`--' */ 40/* 41Before sending the program 42 to the Arduino board , 43make sure the connections are correct , 44which has 45 as its browser Google Chrome , 46and you have a Wifi connection. */ 47/* Instructions 48 */ /* Instructions */ /* Instructions */ 49/* 501) Send the program to the Arduino 51 board . 522) Wait 20 seconds to complete initialization of the Wifi Shiled (ESP8266) 53 . 543) Connect your phone to the Wifi connection : " Ai- Thinker " . 554) Open 56 Google Chrome and go to address " 192.168.4.1 " . 575) HAVE FUN !. 58 */ 59 60#include 61 <SoftwareSerial.h> 62#include <String.h> 63#include <Servo.h> 64#define DEBUG 65 true 66SoftwareSerial esp8266 (10,11); 67Servo frontWheel; 68int blueLed = 12; 69 int redLed = 8; int greenLed = 13; 70/* Ruota posteriore destra */ 71const int 72 enablePinRight = 9; //Aziona il ponte H. 73const int forwardVerseRight = 4; //Fa 74 andare il motore destro in avanti. 75const int backVerseRight = 3; //Fa andare 76 il motore destro indietro. 77/* Fine dichiazioni ruota posteriore destra */ 78/* 79 Ruota posteriore sinistra */ 80const int enablePinLeft = 6; //Aziona il ponte H. 81const 82 int forwardVerseLeft = 2; //Fa andare il motore sinistro in avanti. 83const int 84 backVerseLeft = 5; //Fa andare il motore sinistro indietro. 85/* Fine dichiazioni 86 ruota posteriore sinistra */ 87String webPage = "<html><head><title>M-Car</title><link 88 rel='shortcut icon' type='image/x-icon' href='http://arduino.cc/en/favicon.png' 89 /></head><body bgcolor='grey'><p align='center'><button><a href='/?Power=1'>Avvia 90 Motore</a></button></p><br><p align='left'><button><a href='/?Turn=2'>Gira a Sinistra</a></button><p 91 align='right'><button><a href='/?Turn=3'>Gira a Destra</a></button></p></p><br><p 92 align='center'><button><a href='/?Turn=4'>Vai Dritto</a></button></p><br><p align='center'><button><a 93 href='/?Power=0'>Spegni Motore</a></button></p></body></html>"; 94String search 95 = ""; 96int startPos = 90; int pos; 97void setup (){ 98 Serial.begin (115200); 99 100 esp8266.begin (115200); 101 frontWheel.attach (7); 102 pinMode (blueLed,OUTPUT); 103 104 pinMode (redLed,OUTPUT); 105 pinMode (greenLed,OUTPUT); 106 pinMode (enablePinRight,OUTPUT); 107 108 pinMode (forwardVerseRight,OUTPUT); 109 pinMode (backVerseRight,OUTPUT); 110 111 pinMode (enablePinLeft,OUTPUT); 112 pinMode (backVerseLeft,OUTPUT); 113 pinMode 114 (forwardVerseLeft,OUTPUT); 115 esp8266.print ("AT+RST\ \ 116"); /*Resetta il modulo.*/ 117 delay (2000); 118 esp8266.print ("AT+CWMODE=2\ \ 119"); /*Imposta il modulo come 120 punto di accesso.*/ delay (2000); 121 esp8266.print ("AT+CIFSR\ \ 122"); /*Localizza 123 l'indirizzo ip.*/ delay (2000); 124 esp8266.print ("AT+CIPMUX=1\ \ 125"); /*Imposta 126 la connessione multipla.*/ delay (2000); 127 esp8266.print ("AT+CIPSERVER=1,80\ \ 128"); 129 /*Crea il server sulla porta 80.*/ delay (2000); 130 Serial.println ("Inizzializzazione 131 avvenuta con successo!"); 132 digitalWrite (greenLed,HIGH); 133 digitalWrite 134 (enablePinRight,HIGH); 135 digitalWrite (enablePinLeft,HIGH); 136 frontWheel.write 137 (startPos); 138} 139void loop (){ 140 while (esp8266.available()){ 141 char 142 data = esp8266.read(); 143 search.concat (data); 144 } 145 if (esp8266.find("+IPD,")){ 146 //Se la connessione avvenuta con successo... 147 if (search.indexOf("Power=1")>-1){ 148 149 Serial.println ("Motori Accesi!"); 150 digitalWrite(backVerseRight, 151 LOW); 152 digitalWrite(forwardVerseRight, HIGH); 153 digitalWrite(backVerseLeft, 154 LOW); 155 digitalWrite(forwardVerseLeft, HIGH); 156 } 157 if (search.indexOf("Turn=2")>0){ 158 159 Serial.println ("Giro a Sinistra"); 160 frontWheel.write (80); 161 162 } 163 if (search.indexOf("Turn=3")>0){ 164 Serial.println ("Giro 165 a Destra"); 166 frontWheel.write (105); 167 } 168 if (search.indexOf("Turn=4")>0){ 169 170 Serial.println ("Vado Dritto"); 171 frontWheel.write (90); 172 } 173 174 if (search.indexOf("Power=0")>0){ 175 Serial.println ("Motori Spenti"); 176 177 digitalWrite(backVerseRight, LOW); 178 digitalWrite(forwardVerseRight, 179 LOW); 180 digitalWrite(backVerseLeft, LOW); 181 digitalWrite(forwardVerseLeft, 182 LOW); 183 } 184 int netId = esp8266.read() -48; 185 esp8266.print (sendToEsp(netId,webPage.length())); 186 187 esp8266.print (webPage); //Mostra la pagina.. 188 esp8266.print (closeEsp(netId)); 189 190 search = ""; 191 blink (); //Lampeggia :D 192 } 193} 194String sendToEsp 195 (int id,int webpageLength){ //Funzione per l'invio di dati al modulo. 196 String 197 data = "AT+CIPSEND="; 198 data += id; 199 data += ","; 200 data += webpageLength; 201 202 data += "\ \ 203"; 204 return data; 205} 206String closeEsp (int id){ //Funzione 207 per la chiusura di connessione. 208 String closeConnection = "AT+CIPCLOSE="; 209 210 closeConnection += id; 211 closeConnection += "\ \ 212"; 213 return closeConnection; 214} 215void 216 blink (void){ 217 digitalWrite (blueLed,HIGH); 218 delay (1000); 219 digitalWrite 220 (blueLed,LOW); 221 digitalWrite (redLed,HIGH); 222 delay (1000); 223 digitalWrite 224 (redLed,LOW); 225 226} 227
Downloadable files
M-Car_Scheme
The M-Car Wiring Scheme :D
M-Car_Scheme
Comments
Only logged in users can leave comments
P3RISH
0 Followers
•0 Projects
Table of contents
Intro
2
0