Devices & Components
Arduino Uno Rev3
Motor Control
Gearbox
Rotary potentiometer (generic)
DC motor (generic)
Project description
Code
Robot_Arm Software
arduino
1int POT1 = A0; // select the input pin for the potentiometer 1 2int 3 POT2 = A1; // select the input pin for the potentiometer 2 4int X = 0; // 5 select the pin for the motor control (FORWARD) 6int Y = 1; // select the 7 pin for the motor control (REVERSE) 8int sensorValue1 = 0; // variable to store 9 the value coming from POT1 10int sensorValue2 = 0; // variable to store the value 11 coming from POT2 12void setup() 13{ // declare X AND Y as an OUTPUT: 14 pinMode(X, 15 OUTPUT); 16 pinMode(Y, OUTPUT); } 17void loop() 18{ // read the values from 19 the POTS: 20 sensorValue1 = analogRead(POT1); 21 sensorValue2 = analogRead(POT2); 22 23 // compare sensor values: 24 if (sensorValue1 <= sensorValue2 + 50 || sensorValue1 25 >= sensorValue2 - 50) 26{ digitalWrite(X, LOW); 27 digitalWrite(Y, LOW); } 28 29 if (sensorValue1 < sensorValue2 - 51) 30{ digitalWrite(X, LOW); 31 digitalWrite(Y, 32 HIGH); } 33 if (sensorValue1 > sensorValue2 + 51) 34{ digitalWrite(X, HIGH); 35 36 digitalWrite(Y, LOW); } } 37
Robot_Arm Software
arduino
1int POT1 = A0; // select the input pin for the potentiometer 1 2int POT2 = A1; // select the input pin for the potentiometer 2 3int X = 0; // select the pin for the motor control (FORWARD) 4int Y = 1; // select the pin for the motor control (REVERSE) 5int sensorValue1 = 0; // variable to store the value coming from POT1 6int sensorValue2 = 0; // variable to store the value coming from POT2 7void setup() 8{ // declare X AND Y as an OUTPUT: 9 pinMode(X, OUTPUT); 10 pinMode(Y, OUTPUT); } 11void loop() 12{ // read the values from the POTS: 13 sensorValue1 = analogRead(POT1); 14 sensorValue2 = analogRead(POT2); 15 // compare sensor values: 16 if (sensorValue1 <= sensorValue2 + 50 || sensorValue1 >= sensorValue2 - 50) 17{ digitalWrite(X, LOW); 18 digitalWrite(Y, LOW); } 19 if (sensorValue1 < sensorValue2 - 51) 20{ digitalWrite(X, LOW); 21 digitalWrite(Y, HIGH); } 22 if (sensorValue1 > sensorValue2 + 51) 23{ digitalWrite(X, HIGH); 24 digitalWrite(Y, LOW); } } 25
Downloadable files
Circuit Diagram
Circuit Diagram
Circuit Diagram
Circuit Diagram
Wiring
Wiring
Comments
Only logged in users can leave comments