So I am trying to mess around creating a kind of central locking system and I want the lock button on my key fob to turn on a LED (BLINKS using a ATTINY85) I want this to latch on powering the ATTINY85 blink feature. Then to turn it off I press unlock on the key fob. I have this working however once I press the lock button it blinks and works fine but I can press lock again and it breaks the latch. Really lost on how to solve this any help is appreciated.!!!
Welcome to the group.
Use CTRL T to format your code.
Attach your ‘complete’ sketch between code tags, use the </> icon in the posting menu.
[code]Paste your sketch here[/code]
Show us a good schematic of your circuit.
Show us a good image of your wiring.
Give links to components.
Posting images:
https://forum.arduino.cc/index.php?topic=519037.0
chrism98:
So I am trying to mess around creating a kind of central locking system and I want the lock button on my key fob to turn on a LED (BLINKS using a ATTINY85) I want this to latch on powering the ATTINY85 blink feature. Then to turn it off I press unlock on the key fob. I have this working however once I press the lock button it blinks and works fine but I can press lock again and it breaks the latch. Really lost on how to solve this any help is appreciated.!!!
You need to blink a led and watch a button at the same time. You can't do that with delay() but you can do,
--- pseudocode: this allows things to not happen without blocking the rest from running.
void loop()
{
if ( blink is ON )
{
if ( it's time to change the led pin )
{
// code to blink the led and set the timer up for next blink
}
}
// button code which includes debouncing, maybe use a button library
if ( button pressed )
{
// change blink state between ON and OFF, if turning ON then set timer
}
} // ---- you can size this window with the lower right corner --->
Nick Gammon (not me) has a blog walk-through written in simple terms and then the code to show how, all splained easy.