Show Posts
|
|
Pages: [1] 2 3 ... 13
|
|
7
|
Topics / Robotics / Re: Autonomous Arduino Car
|
on: May 12, 2013, 08:30:08 am
|
Try something like this… F_DCMotor motor1(1, MOTOR12_64KHZ); // create motor #2, 64KHz pwm AF_DCMotor motor2(2, MOTOR12_64KHZ); // create motor #2, 64KHz pwm
int long sensorValue = 0;
void setup() { Serial.begin(9600); // set up Serial library at 9600 bps Serial.println("Motor test!"); motor1.setSpeed(2000); // set the speed to 200/255 motor2.setSpeed(150); // set the speed to 200/255 /// change commits to be up to date }
void loop() { Serial.print("tick"); sensorValue = analogRead(A0); Serial.print(sensorValue);
if (sensorValue > 520) { // I dont know if your sensor's readings get larger when it gets close to the wall or smaller so you might have to change > to < motor1.run(FORWARD); motor2.run(BACKWARD); // turn it on going backward delay(1000); motor1.run(FORWARD); motor2.run(FORWARD); delay(500); //play around with the delay to make it turn the right amount } else { motor1.run(BACKWARD); motor2.setSpeed(150); motor2.run(FORWARD); // turn it on going forward delay(1000); } }
|
|
|
|
|
8
|
Topics / Robotics / Re: Autonomous Arduino Car
|
on: May 12, 2013, 07:56:27 am
|
Could you please post the code you already have. Also, how close do you want the robot to be before it reverses and turns around? Use the code below to see the analog value that the sensor is putting out. Place the robot as close to the wall as you want it then run the code and look at the serial monitor on your computer. It should read out the analog value of the sensor. When you post the code post that value as well. /* AnalogReadSerial Reads an analog input on pin 0, prints the result to the serial monitor. Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground. This example code is in the public domain. */
// the setup routine runs once when you press reset: void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); }
// the loop routine runs over and over again forever: void loop() { // read the input on analog pin 0: int sensorValue = analogRead(A0); // print out the value you read: Serial.println(sensorValue); delay(700); // delay in between reads for stability }
Best of luck, Drew
|
|
|
|
|
12
|
Using Arduino / Sensors / RFID RXO HELP
|
on: May 10, 2013, 10:45:14 pm
|
|
Hello,
I have an RFID reader but each time I turn on the Arduino I have to unplug the RFID RXO Line for a second. Once I put it back into the board the reader will work until I turn off the Arduino. Is this normal and is their any way around it?
Also, i'm using a MEGA 2560 and Pin 0.
Thanks!
|
|
|
|
|
15
|
Using Arduino / General Electronics / Re: How do Ground's work?
|
on: May 10, 2013, 08:46:41 am
|
|
Also, I forgot to mention that each motor driver will be using their own battery pack. So what I plan on doing is running both the grounds of the battery back together and one pin coming from the ground on the Arduino. Then from the connection I will have two wires, one for each ground connection on the motor driver.
|
|
|
|
|