Sense The Tilt

SRJT10104

Jugaadu realized about his teacher's tiring job of board erasing again and again. He thinks of some solution which could automatically erase the board for his teacher. What could be it? Think!?

  1. Arduino UNO
  2. Arduino UNO Cable
  3. Bread Board
  4. Motor Driver
  5. Triple Axis Accelerometer
  6. Car Chassis Kit
  7. Hookup Wire
  8. BO Motor
  9. Wheels
  10. Screw Driver
  11. Free Wheel
  12. Screws and Nuts
  13. 9V Battery
  14. L Brackets
  15. Jumper Wires
  16. Battery Connector
We can start by creating an Arduino UNO based Bot mechanism using triple axis Accelerometer sensor. As soon as the sensor senses the tilt, value of resistance changes about 3 axis which is read by Arduino UNO. Arduino UNO will give its output to Motor Driver which will cause movement of the bot.

    const int xpin = A3;                
const int ypin = A2;             
const int zpin = A1;         
int lm1=10;
int lm2=11;
int rm1=8;
int rm2=9;

void setup()
{
  Serial.begin(9600);
  pinMode(lm1, OUTPUT);
  pinMode(lm2, OUTPUT);
  pinMode(rm1, OUTPUT);
  pinMode(rm2, OUTPUT);
  pinMode(xpin, INPUT);
  pinMode(ypin, INPUT);
  pinMode(zpin, INPUT);
}

void loop()
{
  Serial.print(analogRead(xpin));
  Serial.print("\t");
  Serial.print(analogRead(ypin));
  Serial.print("\t");
  Serial.print(analogRead(zpin));
  Serial.println();
  delay(1000);
if(analogRead(xpin)>340)
{
digitalWrite(rm1,LOW);
digitalWrite(rm2,HIGH);
digitalWrite(lm1,LOW);
digitalWrite(lm2,HIGH);
}
else
{
digitalWrite(rm1,LOW);
digitalWrite(rm2,LOW);
digitalWrite(lm1,LOW);
digitalWrite(lm2,LOW);
}
}