Hi, everyone. I am in the process of building a "fire extinguishing robot" which basically should drive straight forward for ten feet, stop, and then flip on a fan motor to extinguish a candle mounted at 1 foot off the ground.
I have constructed the robot, however am having difficulty with the code. ( I know it should be simple, however I am new to the robotics as well as the code behind the robot.) The code I have right now is as follows, it will run two DC motors that i have wired into one set of +/- wires to fit into port A on the Arduino Uno. After it runs these motors for a certain amount of time, it will stop them, and then loop again.
My goal however, is to get port A to run the wheel motors, stop them, and then directly after they have been stopped, to start the port B fan motor which will hopefully run for about 10 seconds and then turn off.
I am worried that if I input Port B code directly after I have put a delay on Port A for x amount of time, the robot will wait x amount of time and then begin to run the tire motors again.
You can probably tell I am very confused, and any help would be greatly appreciated! Thanks
My current code...
void setup() {
// put your setup code here, to run once:
//Setup Channel A
pinMode(12, OUTPUT); //Initiates Motor Channel A pin
pinMode(9, OUTPUT); //Initiates Brake Channel A pin
pinMode(8, OUTPUT); // hopefully initiates channel b motor pin
pinMode(13, OUTPUT); //hopefully initiates channel b brake pin
}
void loop() {
// put your main code here, to run repeatedly:
//forward @ full speed
digitalWrite(12, HIGH); //Establishes forward direction of Channel A
digitalWrite(9, LOW); //Disengage the Brake for Channel A
analogWrite(3, 255); //Spins the motor on Channel A at full speed
delay(45000); //milliseconds
digitalWrite(9, HIGH); //Engage the Brake for Channel A
delay(10000000);
// worried fan won't start until 10,000 seconds after motor stops, but we want the motor
//to stop then immediately turn the fan on and then stop the fan about 10-15 seconds later, and NOT LOOP THE PROGRAM
}