Components and supplies
Battery Holder, AA x 3
AA Batteries
DC Motor, 12 V
Dual H-Bridge motor drivers L293D
Arduino Nano R3
NodeMCU ESP8266 Breakout Board
Tools and machines
Hot glue gun (generic)
Project description
Code
this is the wifi code can be used with l298
c_cpp
simply upload it on ur node mcu
1#define ENA 14 // Enable/speed motors Right GPIO14(D5) 2#define ENB 12 // Enable/speed motors Left GPIO12(D6) 3#define IN_1 15 // in1 motors Right GPIO15(D8) 4#define IN_2 13 // in2 motors Right GPIO13(D7) 5#define IN_3 2 // in3 motors Left GPIO2(D4) 6#define IN_4 0 // in4 motors Left GPIO0(D3) 7 8#include <ESP8266WiFi.h> 9#include <WiFiClient.h> 10#include <ESP8266WebServer.h> 11 12String command; //String to store app command state. 13int speedCar = 800; // 400 - 1023. 14int speed_Coeff = 3; 15 16const char* ssid = "NodeMCU Car"; 17ESP8266WebServer server(80); 18 19void setup() { 20 21 pinMode(ENA, OUTPUT); 22 pinMode(ENB, OUTPUT); 23 pinMode(IN_1, OUTPUT); 24 pinMode(IN_2, OUTPUT); 25 pinMode(IN_3, OUTPUT); 26 pinMode(IN_4, OUTPUT); 27 28 Serial.begin(115200); 29 30// Connecting WiFi 31 32 WiFi.mode(WIFI_AP); 33 WiFi.softAP(ssid); 34 35 IPAddress myIP = WiFi.softAPIP(); 36 Serial.print("AP IP address: "); 37 Serial.println(myIP); 38 39 // Starting WEB-server 40 server.on ( "/", HTTP_handleRoot ); 41 server.onNotFound ( HTTP_handleRoot ); 42 server.begin(); 43} 44 45void goAhead(){ 46 47 digitalWrite(IN_1, LOW); 48 digitalWrite(IN_2, HIGH); 49 analogWrite(ENA, speedCar); 50 51 digitalWrite(IN_3, LOW); 52 digitalWrite(IN_4, HIGH); 53 analogWrite(ENB, speedCar); 54 } 55 56void goBack(){ 57 58 digitalWrite(IN_1, HIGH); 59 digitalWrite(IN_2, LOW); 60 analogWrite(ENA, speedCar); 61 62 digitalWrite(IN_3, HIGH); 63 digitalWrite(IN_4, LOW); 64 analogWrite(ENB, speedCar); 65 } 66 67void goRight(){ 68 69 digitalWrite(IN_1, HIGH); 70 digitalWrite(IN_2, LOW); 71 analogWrite(ENA, speedCar); 72 73 digitalWrite(IN_3, LOW); 74 digitalWrite(IN_4, HIGH); 75 analogWrite(ENB, speedCar); 76 } 77 78void goLeft(){ 79 80 digitalWrite(IN_1, LOW); 81 digitalWrite(IN_2, HIGH); 82 analogWrite(ENA, speedCar); 83 84 digitalWrite(IN_3, HIGH); 85 digitalWrite(IN_4, LOW); 86 analogWrite(ENB, speedCar); 87 } 88 89void goAheadRight(){ 90 91 digitalWrite(IN_1, LOW); 92 digitalWrite(IN_2, HIGH); 93 analogWrite(ENA, speedCar/speed_Coeff); 94 95 digitalWrite(IN_3, LOW); 96 digitalWrite(IN_4, HIGH); 97 analogWrite(ENB, speedCar); 98 } 99 100void goAheadLeft(){ 101 102 digitalWrite(IN_1, LOW); 103 digitalWrite(IN_2, HIGH); 104 analogWrite(ENA, speedCar); 105 106 digitalWrite(IN_3, LOW); 107 digitalWrite(IN_4, HIGH); 108 analogWrite(ENB, speedCar/speed_Coeff); 109 } 110 111void goBackRight(){ 112 113 digitalWrite(IN_1, HIGH); 114 digitalWrite(IN_2, LOW); 115 analogWrite(ENA, speedCar/speed_Coeff); 116 117 digitalWrite(IN_3, HIGH); 118 digitalWrite(IN_4, LOW); 119 analogWrite(ENB, speedCar); 120 } 121 122void goBackLeft(){ 123 124 digitalWrite(IN_1, HIGH); 125 digitalWrite(IN_2, LOW); 126 analogWrite(ENA, speedCar); 127 128 digitalWrite(IN_3, HIGH); 129 digitalWrite(IN_4, LOW); 130 analogWrite(ENB, speedCar/speed_Coeff); 131 } 132 133void stopRobot(){ 134 135 digitalWrite(IN_1, LOW); 136 digitalWrite(IN_2, LOW); 137 analogWrite(ENA, speedCar); 138 139 digitalWrite(IN_3, LOW); 140 digitalWrite(IN_4, LOW); 141 analogWrite(ENB, speedCar); 142 } 143 144void loop() { 145 server.handleClient(); 146 147 command = server.arg("State"); 148 if (command == "F") goAhead(); 149 else if (command == "B") goBack(); 150 else if (command == "L") goLeft(); 151 else if (command == "R") goRight(); 152 else if (command == "I") goAheadRight(); 153 else if (command == "G") goAheadLeft(); 154 else if (command == "J") goBackRight(); 155 else if (command == "H") goBackLeft(); 156 else if (command == "0") speedCar = 400; 157 else if (command == "1") speedCar = 470; 158 else if (command == "2") speedCar = 540; 159 else if (command == "3") speedCar = 610; 160 else if (command == "4") speedCar = 680; 161 else if (command == "5") speedCar = 750; 162 else if (command == "6") speedCar = 820; 163 else if (command == "7") speedCar = 890; 164 else if (command == "8") speedCar = 960; 165 else if (command == "9") speedCar = 1023; 166 else if (command == "S") stopRobot(); 167} 168 169void HTTP_handleRoot(void) { 170 171if( server.hasArg("State") ){ 172 Serial.println(server.arg("State")); 173 } 174 server.send ( 200, "text/html", "" ); 175 delay(1); 176}
autonomous
c_cpp
1#define IN_1 15 // (D8) 2#define IN_2 13 // 3 (D7) 4#define IN_3 2 // (D4) 5#define IN_4 0 // 6 (D3) 7void setup() 8{ 9 pinMode(IN_1, OUTPUT); 10 pinMode(IN_2, 11 OUTPUT); 12 pinMode(IN_3, OUTPUT); 13 pinMode(IN_4, OUTPUT); 14 15} 16void 17 loop () 18{ 19 20 digitalWrite(IN_1, LOW); 21 digitalWrite(IN_2, HIGH); 22 23 24 digitalWrite(IN_3, LOW); 25 digitalWrite(IN_4, HIGH); 26 delay (3000); 27 28 29 digitalWrite(IN_1, LOW); 30 digitalWrite(IN_2, HIGH); 31 32 33 digitalWrite(IN_3, 34 HIGH); 35 digitalWrite(IN_4, LOW); 36 delay (1500); 37 38 39}
autonomous
c_cpp
1#define IN_1 15 // (D8) 2#define IN_2 13 // (D7) 3#define IN_3 2 // (D4) 4#define IN_4 0 // (D3) 5void setup() 6{ 7 pinMode(IN_1, OUTPUT); 8 pinMode(IN_2, OUTPUT); 9 pinMode(IN_3, OUTPUT); 10 pinMode(IN_4, OUTPUT); 11 12} 13void loop () 14{ 15 16 digitalWrite(IN_1, LOW); 17 digitalWrite(IN_2, HIGH); 18 19 digitalWrite(IN_3, LOW); 20 digitalWrite(IN_4, HIGH); 21 delay (3000); 22 23 digitalWrite(IN_1, LOW); 24 digitalWrite(IN_2, HIGH); 25 26 27 digitalWrite(IN_3, HIGH); 28 digitalWrite(IN_4, LOW); 29 delay (1500); 30 31 32}
this is the wifi code can be used with l298
c_cpp
simply upload it on ur node mcu
1#define ENA 14 // Enable/speed motors Right GPIO14(D5) 2#define ENB 12 // Enable/speed motors Left GPIO12(D6) 3#define IN_1 15 // in1 motors Right GPIO15(D8) 4#define IN_2 13 // in2 motors Right GPIO13(D7) 5#define IN_3 2 // in3 motors Left GPIO2(D4) 6#define IN_4 0 // in4 motors Left GPIO0(D3) 7 8#include <ESP8266WiFi.h> 9#include <WiFiClient.h> 10#include <ESP8266WebServer.h> 11 12String command; //String to store app command state. 13int speedCar = 800; // 400 - 1023. 14int speed_Coeff = 3; 15 16const char* ssid = "NodeMCU Car"; 17ESP8266WebServer server(80); 18 19void setup() { 20 21 pinMode(ENA, OUTPUT); 22 pinMode(ENB, OUTPUT); 23 pinMode(IN_1, OUTPUT); 24 pinMode(IN_2, OUTPUT); 25 pinMode(IN_3, OUTPUT); 26 pinMode(IN_4, OUTPUT); 27 28 Serial.begin(115200); 29 30// Connecting WiFi 31 32 WiFi.mode(WIFI_AP); 33 WiFi.softAP(ssid); 34 35 IPAddress myIP = WiFi.softAPIP(); 36 Serial.print("AP IP address: "); 37 Serial.println(myIP); 38 39 // Starting WEB-server 40 server.on ( "/", HTTP_handleRoot ); 41 server.onNotFound ( HTTP_handleRoot ); 42 server.begin(); 43} 44 45void goAhead(){ 46 47 digitalWrite(IN_1, LOW); 48 digitalWrite(IN_2, HIGH); 49 analogWrite(ENA, speedCar); 50 51 digitalWrite(IN_3, LOW); 52 digitalWrite(IN_4, HIGH); 53 analogWrite(ENB, speedCar); 54 } 55 56void goBack(){ 57 58 digitalWrite(IN_1, HIGH); 59 digitalWrite(IN_2, LOW); 60 analogWrite(ENA, speedCar); 61 62 digitalWrite(IN_3, HIGH); 63 digitalWrite(IN_4, LOW); 64 analogWrite(ENB, speedCar); 65 } 66 67void goRight(){ 68 69 digitalWrite(IN_1, HIGH); 70 digitalWrite(IN_2, LOW); 71 analogWrite(ENA, speedCar); 72 73 digitalWrite(IN_3, LOW); 74 digitalWrite(IN_4, HIGH); 75 analogWrite(ENB, speedCar); 76 } 77 78void goLeft(){ 79 80 digitalWrite(IN_1, LOW); 81 digitalWrite(IN_2, HIGH); 82 analogWrite(ENA, speedCar); 83 84 digitalWrite(IN_3, HIGH); 85 digitalWrite(IN_4, LOW); 86 analogWrite(ENB, speedCar); 87 } 88 89void goAheadRight(){ 90 91 digitalWrite(IN_1, LOW); 92 digitalWrite(IN_2, HIGH); 93 analogWrite(ENA, speedCar/speed_Coeff); 94 95 digitalWrite(IN_3, LOW); 96 digitalWrite(IN_4, HIGH); 97 analogWrite(ENB, speedCar); 98 } 99 100void goAheadLeft(){ 101 102 digitalWrite(IN_1, LOW); 103 digitalWrite(IN_2, HIGH); 104 analogWrite(ENA, speedCar); 105 106 digitalWrite(IN_3, LOW); 107 digitalWrite(IN_4, HIGH); 108 analogWrite(ENB, speedCar/speed_Coeff); 109 } 110 111void goBackRight(){ 112 113 digitalWrite(IN_1, HIGH); 114 digitalWrite(IN_2, LOW); 115 analogWrite(ENA, speedCar/speed_Coeff); 116 117 digitalWrite(IN_3, HIGH); 118 digitalWrite(IN_4, LOW); 119 analogWrite(ENB, speedCar); 120 } 121 122void goBackLeft(){ 123 124 digitalWrite(IN_1, HIGH); 125 digitalWrite(IN_2, LOW); 126 analogWrite(ENA, speedCar); 127 128 digitalWrite(IN_3, HIGH); 129 digitalWrite(IN_4, LOW); 130 analogWrite(ENB, speedCar/speed_Coeff); 131 } 132 133void stopRobot(){ 134 135 digitalWrite(IN_1, LOW); 136 digitalWrite(IN_2, LOW); 137 analogWrite(ENA, speedCar); 138 139 digitalWrite(IN_3, LOW); 140 digitalWrite(IN_4, LOW); 141 analogWrite(ENB, speedCar); 142 } 143 144void loop() { 145 server.handleClient(); 146 147 command = server.arg("State"); 148 if (command == "F") goAhead(); 149 else if (command == "B") goBack(); 150 else if (command == "L") goLeft(); 151 else if (command == "R") goRight(); 152 else if (command == "I") goAheadRight(); 153 else if (command == "G") goAheadLeft(); 154 else if (command == "J") goBackRight(); 155 else if (command == "H") goBackLeft(); 156 else if (command == "0") speedCar = 400; 157 else if (command == "1") speedCar = 470; 158 else if (command == "2") speedCar = 540; 159 else if (command == "3") speedCar = 610; 160 else if (command == "4") speedCar = 680; 161 else if (command == "5") speedCar = 750; 162 else if (command == "6") speedCar = 820; 163 else if (command == "7") speedCar = 890; 164 else if (command == "8") speedCar = 960; 165 else if (command == "9") speedCar = 1023; 166 else if (command == "S") stopRobot(); 167} 168 169void HTTP_handleRoot(void) { 170 171if( server.hasArg("State") ){ 172 Serial.println(server.arg("State")); 173 } 174 server.send ( 200, "text/html", "" ); 175 delay(1); 176}
Documentation
the cad model
this is the 2nd version one so the roof is not there on version 1
the cad model
Comments
Only logged in users can leave comments