Two proximity sensors help this bot avoid cliffs.
/* LucidTronix Cliff Avoider Servo Bot * http://www.lucidtronix.com/tutorials/16 * Control a servo robot using differential * steering based on two binary proximity * sensors. avoids cliffs, and follows * convex perimeters. */#includeServo right;Servo left;int leftSensor = 0;int rightSensor = 1;void setup() { right.attach(6); left.attach(5); pinMode(leftSensor, INPUT); pinMode(rightSensor,INPUT);}void loop() { int leftIn = digitalRead(leftSensor); int rightIn = digitalRead(rightSensor); if (rightIn == HIGH){ left.write(45); right.write( 45 ); } else if (leftIn == HIGH ) { left.write( 165 ); right.write (165 ); } else { left.write( 165); right.write( 65 ); } }
| Title | Description | # | Cost | Link | Picture |
| Servo Motor | Continuous rotation servo motor. | 2 | $13.95 | Link |
|
| Proximity Sensor | Digital proximity sensor. 5vValue:5v | 2 | $6.95 | Link |
|
| Servo Wheel | Wheel that attaches easily to servo motors. | 2 | $4.0 | Link |
|
| ATMEGA168A-AU | IC MCU AVR 16K FLASH 32TQFPValue:1.8 V ~ 5.5 V 20MHz | 1 | $2.43 | Link |
|
| Crystal | CRYSTAL 16.00000 MHZ 20PF SMDValue:16MHz | 1 | $0.53 | Link |
|
| Resistor | Chip Resistor - Surface Mount RES 10K OHM 1/8W 5% 0805 SMDValue: 10k | 1 | $0.1 | Link |
|
Comments: