Please see the comments section if confused. I am trying to turn a motor on and off once per second, and when the motor is on, the RGB turns green. When the motor is off, the RGB is red. Everything is connected to an arduino UNO.I have the motor connected to pins 0 and 1, and to the 5V and GND. The RGB is connected to pins 4, 5, and 6, and the 5V. I have two codes; one with a bunch of screwing around with a bunch of different loops and everything else I've tried, and one with the simple motor on/off code.
void setup ()
{
pinMode(0,OUTPUT); //IB1
pinMode(1,OUTPUT); //IA1
//// pinMode(2,OUTPUT); //IB2
//// pinMode(3,OUTPUT); //IA2
// pinMode(4,OUTPUT); //RGB
// pinMode(5,OUTPUT); //RGB
// pinMode(6,OUTPUT); //RGB
// pinMode(A0,INPUT); //lMotor
//// pinMode(A1,INPUT); //rMotor
// Serial.begin(9600);
}
void loop ()
{
digitalWrite(0,HIGH);
delay(1000);
digitalWrite(0,LOW);
delay(1000);
// int lMotor = analogRead(A0);
// Serial.write(lMotor);
//// int lMotor = analogRead(A1);
//// Serial.write(lMotor);
//
// if (lMotor>10)
// {
// digitalWrite(4,HIGH);
// digitalWrite(5,HIGH);
// digitalWrite(6,LOW);
// }
// else
// {
// digitalWrite(4,HIGH);
// digitalWrite(5,LOW);
// digitalWrite(6,HIGH);
// }
}
And here's this:
void setup ()
{
pinMode(0,OUTPUT);
pinMode(1,OUTPUT);
}
void loop ()
{
digitalWrite(0,HIGH);
delay(1000);
digitalWrite(0,LOW);
delay(1000);
}
What do I need to do? Should I use a "while" loop? If so, how? Is my circuit put together properly? I'm using a motor relay switch to turn the motor on/off, but I'm pretty sure it's hooked up right. Any help is appreciated, even if it doesn't answer all of my questions. Thank you.