Hello. I was wondering how I could make an LED blink and then stop it, when pressing a certain key on the keyboard. Similar to a power switch. Any ideas for a source code ? Thank you !
Hello. I was wondering how I could make an LED blink and then stop it, when pressing a certain key on the keyboard. Similar to a power switch. Any ideas for a source code ? Thank you !
My initial thoughts are yes. Yes you can.
Hi George,
While you won't find source code that does exactly what you want (it is like the Tower of Hanoi - as simple as the Arduino is, it could take longer than the life of the planet for people to write up all combinations of things people might want to do with the board!), so why not go through a tutorial concerned with controlling an LED, and a tutorial concerned with button presses, and perhaps an Arduino programming and C programming tutorial. These should provide sufficient information to get you started - there are no short-cuts to learning in this world : ( Give a man a fish and he eats for just one day..
You'll learn more through going through the tutorials, and any issues, post them here, there are Arduino experts here who could help with an inspection if you can be specific about the issue you're seeing.
Very nicely put shabaz.
We are more than happy to assist any member on here, but we need a bit of a starting point. For example, you say "the keyboard", which means very little to us without knowing what kind of keyboard you have in front of you.
The best advice I can give you is to follow the advice given by shabaz, and follow some tutorials, then try to combine what you've learned. If you have come back to us at this point we will be in a much better possition to assist you.
Yes you can but my advice it's the same from my other partners (paul and shabaz). I can put here a little piece of pseudo-code to guide you.
bool last_state_on = false; void setup(){ pinMode(pin_to_stop_blink, INPUT); pinMode(pin_led, OUTPUT); } void loop(){ if(digitalRead(pin_to_stop_blink) == LOW) //ACTIVATE IN HIGH { if(last_state_on == false){ last_state_on = true; digitalWrite(pin_led,HIGH); }else{ last_state_on = false; digitalWrite(pin_led,LOW); } }else{ digitalWrite(pin_led,LOW); } }
The code is tooooooo simply but i think that for the first step is better go piecemeal. If you continue with Arduino you will discover a many things to improve in this code.
Agree with Paul. Frankly I don't understand the sense of expecting to have a code as needed, already working. Why not sending a pre programmed Arduino? I don't want to offend anyone, but I think that it is the worth that "making a project" is something implying a bit of independent thinking, not an exercise of copy and paste ...