Code for self controlled Robert
Code for self controlled robert
void setup() {
pinMode(6,OUTPUT); pinMode(8,INPUT); pinMode(9, OUTPUT); pinMode(10, OUTPUT); pinMode(A2, INPUT_PULLUP); pinMode(A0,INPUT_PULLUP); } void loop() { int m= analogRead(A0); if(m==XXX) //calibrate your accelerometer and find out the value when your bot is tilted forward { digitalWrite(6, HIGH); digitalWrite(8, LOW); digitalWrite(9, HIGH); digitalWrite(10, LOW); } else if(m==XXX) //calibrate your accelerometer and find out the value when your bot is tilt backward { digitalWrite(6, LOW); digitalWrite(8, HIGH); digitalWrite(9, LOW); digitalWrite(10, HIGH); } else { digitalWrite(6, LOW); digitalWrite(8, HIGH); digitalWrite(9, LOW); digitalWrite(10, HIGH); } }
Comments
Post a Comment
Thank you for visiting😊