Components and supplies
Modulo Joystick
Jumper wires (generic)
Arduino Nano 33 IoT
Arduino UNO
Resistor 100 ohm
IR transmitter (generic)
IR receiver (generic)
SG90 Micro-servo motor
Tools and machines
3D Printer (generic)
Apps and platforms
Arduino IDE
Project description
Code
Code Remote
csharp
This code is the Remote code, used for driving the Robot, made on Arduino.
1#include<IRremote.h> 2 3 4IRsend emitter; //this is the name of the IR LED 5 6//the following variables are necessary for the remote to understand the position of the joystick 7int x = 0; 8int y = 0; 9int xPos = 0; //right side of the X axis 10int xNeg = 0; //left side of the X axis 11int yPos = 0; //right side of the Y axis 12int yNeg = 0; //left side of the Y axis 13 14void setup() 15{ 16 Serial.begin(9600); 17} 18 19void loop() 20{ 21 22 //read the joystick's X axis & Y axis values 23 x = analogRead(A0); 24 y = analogRead(A1); 25 26 27 //these are the operations to calculate Xpos & Xneg 28 if (x > 524) { 29 xPos = (x - 512) / 2; 30 xNeg = 0; 31 } 32 else if (x < 500) { 33 xPos = 0; 34 xNeg = (511 - x) / 2 ; 35 } 36 else { 37 xPos = 0; 38 xNeg = 0; 39 } 40 41 //these are the operations to calculate Ypos & Yneg 42 if (y > 524) { 43 yPos = (y - 512) / 2; 44 yNeg = 0; 45 } 46 else if (y < 500) { 47 yPos = 0; 48 yNeg = (511 - y) / 2; 49 } 50 else { 51 yPos = 0; 52 yNeg = 0; 53 } 54 55 56 //tell otto to turn right 57 if ((xPos - xNeg - yPos - yNeg) > 0) { 58 emitter.sendSony(0x8, 32); 59 Serial.println("right"); 60 delay(40); 61 //tell otto to turn left 62 } 63 if ((xNeg - yPos - yNeg - xPos) > 0) { 64 emitter.sendSony(0x10, 32); 65 Serial.println("left"); 66 delay(40); 67 } 68 //tell otto to walk forward 69 if ((yPos - yNeg - xPos - xNeg) > 0) { 70 emitter.sendSony(0x18, 32); 71 Serial.println("forward"); 72 delay(40); 73 //tell otto to walk backwards 74 } 75 if ((yNeg - xPos - xNeg - yPos) > 0) { 76 emitter.sendSony(0x20, 32); 77 Serial.println("backwards"); 78 delay(40); 79 } 80 81} 82
Code Robot
csharp
This code is the Robot code, made on Arduino
1#include <IRremote.h> 2#include <Otto9.h> 3 4 5Otto9 Otto; //this is the name of our robot :) 6 7IRrecv ir(12); //name and pin of the IR sensor 8decode_results results; //this variable will assume the values of the recieved signals 9 10#define PIN_LLEG 3 //YL - left leg pin 11#define PIN_RLEG 4 //YR - right leg pin 12#define PIN_LFOOT 2 //RL - left foot pin 13#define PIN_RFOOT 5 //RR - right foot pin 14 15#define PIN_Trigger 8 //US send pin 16#define PIN_Echo 10 //US return pin 17#define PIN_Buzzer 13 //buzzer pin 18 19void setup() { 20 21 //initialisation of the robot by defining: YL, YR, RL, RR, load calibration (true or false), Noise sensor, Buzzer, Trigger, Echo 22 Otto.init(PIN_LLEG, PIN_RLEG, PIN_LFOOT, PIN_RFOOT, false, A6, PIN_Buzzer, PIN_Trigger, PIN_Echo); 23 Otto.home(); //set all the servos to 90 24 25 delay(500); 26 Serial.begin(9600); 27 ir.enableIRIn(); //start to read the IR sensor values 28} 29 30void loop() { 31 32 if (ir.decode(&results)) { 33 34 if (results.value == 24) { //if the code sent by the remote is 24: 35 Otto.walk(8, 600, 1); //walk: 8=steps, 600=period (time per step), 1=direction (forward) 36 Serial.println("forward"); 37 } 38 39 if (results.value == 32) { //if the code sent by the remote is 32: 40 Otto.walk(8, 600, -1); //walk: 8=steps, 600=period (time per step), -1=direction (backwards) 41 Serial.println("backwards"); 42 } 43 if (results.value == 8) { //if the code sent by the remote is 8: 44 Otto.turn(8, 800, 1); //turn: 8=steps, 600=period (time per step), -1=direction (right) 45 Serial.println("right"); 46 } 47 if (results.value == 16) { //if the code sent by the remote is 16: 48 Otto.turn(8, 800, -1); //turn: 8=steps, 600=period (time per step), -1=direction (left) 49 Serial.println("left"); 50 } 51 ir.resume(); //start reading the sensor values again 52 } 53 else { //if the robot doesn't recieve any signal 54 Otto.home(); 55 } 56 results.value = 0; 57} 58
Code Robot
csharp
This code is the Robot code, made on Arduino
1#include <IRremote.h> 2#include <Otto9.h> 3 4 5Otto9 Otto; //this 6 is the name of our robot :) 7 8IRrecv ir(12); //name and pin of the IR sensor 9decode_results 10 results; //this variable will assume the values of the recieved signals 11 12#define 13 PIN_LLEG 3 //YL - left leg pin 14#define PIN_RLEG 4 //YR - right leg pin 15#define 16 PIN_LFOOT 2 //RL - left foot pin 17#define PIN_RFOOT 5 //RR - right foot pin 18 19#define 20 PIN_Trigger 8 //US send pin 21#define PIN_Echo 10 //US return pin 22#define 23 PIN_Buzzer 13 //buzzer pin 24 25void setup() { 26 27 //initialisation of the 28 robot by defining: YL, YR, RL, RR, load calibration (true or false), Noise sensor, 29 Buzzer, Trigger, Echo 30 Otto.init(PIN_LLEG, PIN_RLEG, PIN_LFOOT, PIN_RFOOT, false, 31 A6, PIN_Buzzer, PIN_Trigger, PIN_Echo); 32 Otto.home(); //set all the servos to 33 90 34 35 delay(500); 36 Serial.begin(9600); 37 ir.enableIRIn(); //start to 38 read the IR sensor values 39} 40 41void loop() { 42 43 if (ir.decode(&results)) 44 { 45 46 if (results.value == 24) { //if the code sent by the remote is 24: 47 48 Otto.walk(8, 600, 1); //walk: 8=steps, 600=period (time per step), 1=direction 49 (forward) 50 Serial.println("forward"); 51 } 52 53 if (results.value 54 == 32) { //if the code sent by the remote is 32: 55 Otto.walk(8, 600, -1); 56 //walk: 8=steps, 600=period (time per step), -1=direction (backwards) 57 Serial.println("backwards"); 58 59 } 60 if (results.value == 8) { //if the code sent by the remote is 8: 61 62 Otto.turn(8, 800, 1); //turn: 8=steps, 600=period (time per step), -1=direction 63 (right) 64 Serial.println("right"); 65 } 66 if (results.value == 67 16) { //if the code sent by the remote is 16: 68 Otto.turn(8, 800, -1); //turn: 69 8=steps, 600=period (time per step), -1=direction (left) 70 Serial.println("left"); 71 72 } 73 ir.resume(); //start reading the sensor values again 74 } 75 else 76 { //if the robot doesn't recieve any signal 77 Otto.home(); 78 } 79 results.value 80 = 0; 81} 82
Code Remote
csharp
This code is the Remote code, used for driving the Robot, made on Arduino.
1#include<IRremote.h> 2 3 4IRsend emitter; //this is the name of 5 the IR LED 6 7//the following variables are necessary for the remote to understand 8 the position of the joystick 9int x = 0; 10int y = 0; 11int xPos = 0; //right 12 side of the X axis 13int xNeg = 0; //left side of the X axis 14int yPos = 0; //right 15 side of the Y axis 16int yNeg = 0; //left side of the Y axis 17 18void setup() 19{ 20 21 Serial.begin(9600); 22} 23 24void loop() 25{ 26 27 //read the joystick's 28 X axis & Y axis values 29 x = analogRead(A0); 30 y = analogRead(A1); 31 32 33 34 //these are the operations to calculate Xpos & Xneg 35 if (x > 524) { 36 xPos 37 = (x - 512) / 2; 38 xNeg = 0; 39 } 40 else if (x < 500) { 41 xPos = 42 0; 43 xNeg = (511 - x) / 2 ; 44 } 45 else { 46 xPos = 0; 47 xNeg 48 = 0; 49 } 50 51 //these are the operations to calculate Ypos & Yneg 52 if 53 (y > 524) { 54 yPos = (y - 512) / 2; 55 yNeg = 0; 56 } 57 else if (y 58 < 500) { 59 yPos = 0; 60 yNeg = (511 - y) / 2; 61 } 62 else { 63 yPos 64 = 0; 65 yNeg = 0; 66 } 67 68 69 //tell otto to turn right 70 if ((xPos 71 - xNeg - yPos - yNeg) > 0) { 72 emitter.sendSony(0x8, 32); 73 Serial.println("right"); 74 75 delay(40); 76 //tell otto to turn left 77 } 78 if ((xNeg - yPos - yNeg 79 - xPos) > 0) { 80 emitter.sendSony(0x10, 32); 81 Serial.println("left"); 82 83 delay(40); 84 } 85 //tell otto to walk forward 86 if ((yPos - yNeg - xPos 87 - xNeg) > 0) { 88 emitter.sendSony(0x18, 32); 89 Serial.println("forward"); 90 91 delay(40); 92 //tell otto to walk backwards 93 } 94 if ((yNeg - xPos 95 - xNeg - yPos) > 0) { 96 emitter.sendSony(0x20, 32); 97 Serial.println("backwards"); 98 99 delay(40); 100 } 101 102} 103
Downloadable files
Circuit Remote
this is the Remote circuit, made on Tinkercad
Circuit Remote
Circuit Robot
This is the robot circuit, made on Tinkercad
Circuit Robot
Circuit Robot
This is the robot circuit, made on Tinkercad
Circuit Robot
Documentation
3D Printed parts
The parts we used to assembly the robot.
https://www.thingiverse.com/thing:2460511
3D Printed parts
The parts we used to assembly the robot.
https://www.thingiverse.com/thing:2460511
Comments
Only logged in users can leave comments
momograma
0 Followers
•0 Projects
Table of contents
Intro
2
0