I'm extremely new to arduino and I'm trying to get my feet wet by doing some simple LED exercises. I have a breadboard setup to where I have 3 LEDS and two switches--- I want to program the arduino to power up all 3 LEDs once I press down a switch but have only one of them blink off/on every second.
The problem that I'm having is when I press my other switch button to turn off the LEDs, my 'blinking LED' doesn't turn off. I'm going to safely assume it has something to do with my void loop and it not telling the arduino to stop that specific blinking loop when I press the 'off' switch. I just dont know how to implement that in my code. I've pasted my code here:
int ledPin = 5;
int ledPin1 = 4;
int ledPin2 = 13;
int buttonApin = 9;
int buttonBpin = 8;
remove digitalWrite(ledPin2,LOW) from your last if statement
change the blinking led code to something like (psuedo code)
if (digitalRead(pin2)) //if on
digitalWrite(pin2)=low; //turn off
else
digitalWrite(pin2)=high; //if off, turn on
put a delay at the end of your code so it slows down the looping a bit so you can see the blinking otherwise the loop exutes so quickly it looks like the led2 is dimmed.