Hello,
I am making some flashing 12V LED lights with my ardiuno uno and a bluetooth module. What i have working is when i press "1" on my bluetooth terminal the lights start flashing, but when i press "0" they don't turn off, they just stay completely on no flashing. Also when I don't apply power to the Uno the LEDs stay on but dim. Can someone please point me in the right direction on what I have done wrong?
My goal in general what im wanting to do with this project is when i turn on the arduino the lights are off. When I press "1" i want them to turn on and flash. Then I want them to stay on until i press "0" and have all the lights turned off. For all this to work i'm just working step by step so I can learn this sketching a bit more.
My code:
char INBYTE;
void setup()
{
Serial.begin(9600);
pinMode(10, OUTPUT);
pinMode(7, OUTPUT);
}
void loop()
{
Serial.println("Press 1 to turn lights on or 0 to turn lights off:"); // lights on or off
while (!Serial.available()); // stay here so long as COM port is empty
INBYTE = Serial.read(); // read next available byte
if( INBYTE == '1' ) {
digitalWrite(10, HIGH);
delay(100); // When value is changed lights change speed
digitalWrite(10, LOW);
delay(50);
digitalWrite(10, HIGH);
delay(50);
digitalWrite(10, LOW);
delay(100);
digitalWrite(10, HIGH);
delay(50);
digitalWrite(10, LOW);
delay(0);
digitalWrite(7, HIGH);
delay(100);
digitalWrite(7, LOW);
delay(50);
digitalWrite(7, HIGH);
delay(50);
digitalWrite(7, LOW);
delay(100);
digitalWrite(7, HIGH);
delay(50);
digitalWrite(7, LOW);
delay(0);
} // if it's a 1 lights turn on and flash on the given speed
if( INBYTE == '0' ){
digitalWrite(10,LOW);
digitalWrite(7, LOW);} // if it's a 0 lights turn off
}
I have also added how I have wired my lights.
Many thanks in advance.
