- I want a robot that runs on my hand movement. I can also do this with my smartphone I go with M5Stack and NodeMCU.
- As I have the core kit of M5Stack there is no imu in it. so that's why I added an MPU6T050 in it. to get all data I need.
- I use some female headers to connect it.
and connected it to M5Stack.
VCC ---- 3.3v
GND ---- GND
SCL ---- SCL
SDA ---- SDA
M5Stack(client):- M5Stack will work as a remote control for the robot.
- with MPU6050 we are calculating "PITCH" and "ROLL".
WEB CLIENT:
- so here we are working as a client for the server.
- so it's similar to web server, where we give commands from our devices to the board,
HOW IT WORKS:
- so if we need to turn on a led by using this server and client system then we will connect to the server and write led after its IP ex--- 198.168.43.212/led
- then the server will read it and do work as assigned, to turn ON the led.
- so I'm using the sketch that comes with the M5Stack library.
- I'm modifying the sketch as per my need.
- so we begin a server that reads what client print.
- so as I gave the example up there that if server reads led then it will turn on the led or do as per commands.
- to ensure that it's working you can also connect to the server with your phone and type led to check everything is working or not.
- so let's talk about the connection of robot.
- I'm using here a motor controller L298N.
- so here we are not controlling motor speed that's why we are not going to connect the wire to enable A or B.
- here you get how to use l298n.
D1 ---- INPUT1
D2 ---- INPUT2
D3 ---- INPUT3
D4 ---- INPUT4
- I'm using this type of robot kit.
- CLIENT SIDE:
if(roll >= 40){
M5.Lcd.print("[HTTP] begin...\n");
http.begin("http://192.168.4.1/right");
M5.Lcd.fillScreen(RED);
int httpCode = http.GET();
http.end();
}
else if(roll <= -40){
M5.Lcd.print("[HTTP] begin...\n");
http.begin("http://192.168.4.1/left"); //HTTP
M5.Lcd.fillScreen(BLUE);
int httpCode = http.GET();
http.end();
}
else if(pitch >= 40){
M5.Lcd.print("[HTTP] begin...\n");
http.begin("http://192.168.4.1/forward"); //HTTP
M5.Lcd.fillScreen(YELLOW);
int httpCode = http.GET();
http.end();
}
else if(pitch <= -40){
M5.Lcd.print("[HTTP] begin...\n");
http.begin("http://192.168.4.1/back"); //HTTP
M5.Lcd.fillScreen(WHITE);
int httpCode = http.GET();
http.end();
}
- so these lines decide where the robot will move this is from the M5Stack side(remote).
- so if the value of roll is more or equal to 40 it will write right.
- and if the value of roll is less or equal to 40 it will write left.
- and if the value of pitch is more or equal to 40 it will write forward.
- and if the value of pitch is less or equal to 40 it will write back
- SERVER SIDE:
void forward(){
digitalWrite(5, 1);
digitalWrite(0, 1);
delay(2000);
digitalWrite(5,0);
digitalWrite(0,0);
delay(1000);
}
- if the client writes forward robot will follow this void forward and go forward
- this way there are for back, right, and left.
- you will find the M5Stack library here.
- if you will go for the right screen will fill with red.
- if you will go for the left screen will fill with blue.
- if you will go for the forward screen will fill with yellow.
- if you will go for the back screen will fill with white.
if you have any problem with it then do let me know in the comment section.
Comments
Please log in or sign up to comment.