You can find more information at Dawn robotics blog .
Demo program for a car controlled by Dagu mini driver.
You can actually turn this program into a line tracker using IR sensor like TCRT5000,
or using sonar sensor to detect walls.
Hope this make a good start. If you need, change the motor speed as needed.
// Demo program for the Dagu Arduino Mini Driver. Uses dead reckoning // to try to drive a robot in a square const int LEFT_MOTOR_DIR_PIN = 7; const int LEFT_MOTOR_PWM_PIN = 9; const int RIGHT_MOTOR_DIR_PIN = 8; const int RIGHT_MOTOR_PWM_PIN = 10; const int DRIVE_FORWARD_TIME_MS = 1500; const int TURN_TIME_MS = 2000; //---------------------------------------------------------- void setup() { // Setup the pins pinMode( LEFT_MOTOR_DIR_PIN, OUTPUT ); pinMode( LEFT_MOTOR_PWM_PIN, OUTPUT ); pinMode( RIGHT_MOTOR_DIR_PIN, OUTPUT ); pinMode( RIGHT_MOTOR_PWM_PIN, OUTPUT ); } //---------------------------------------------------------- void loop() { // Drive forwards at 100% // Try changing the maximum value to 100 if your car is running too fast. digitalWrite( LEFT_MOTOR_DIR_PIN, HIGH ); digitalWrite( RIGHT_MOTOR_DIR_PIN, HIGH ); analogWrite( LEFT_MOTOR_PWM_PIN, 255 ); analogWrite( RIGHT_MOTOR_PWM_PIN, 255 ); delay( DRIVE_FORWARD_TIME_MS ); // Turn right at 50%. Stop right motor on left motor. // you can change the value from 128 to lower. digitalWrite( LEFT_MOTOR_DIR_PIN, HIGH ); digitalWrite( RIGHT_MOTOR_DIR_PIN, LOW ); analogWrite( LEFT_MOTOR_PWM_PIN, 128 ); analogWrite( RIGHT_MOTOR_PWM_PIN, 128 ); delay( TURN_TIME_MS );
With these, you can easily start you Dagu vehicle. You can check out Dawn robotics for their program with Bluetooth, which could be harder for some to understand. |
No comments:
Post a Comment