I am a new newbie. I wrote this very small code, but it doesn’t work. It turns the LED on, but it will not turn it off. Could someone please indicate why this happening? I am receiving no errors when uploading or checking the program. Thanks so much.
int led = 9;
void setup() {
// put your setup code here, to run once:
pinMode(9, OUTPUT);
No, I have not fixed it. I am doing research online to find out how to make it do what I want it to do. I am trying to make a laser detector trip wire. I would like for it to be on all the time, trip and send signal, and then immediately rearm.
You can leave the laser on continuously and detect a break - or (better) modulate it with a square wave
turn LED on
(short delay say 2msec)
turn LED off
(short delay say 2msec)
repeat for ever
but that would be better done with an external circuit or the Arduino timer. Its the signal from the sensor you need to detect a break with.
Yes, aarg, I'm starting to understand what reply #1 meant. I see why that won't work. As for what johnerrington said, I'm starting to understand the bigger picture. The problem is I don't know, what I don't know... Thank you guys for your help. What I do understand is that I have a lot more reading to do!
You don’t really have to go online for that, check the “blink” example sketch that ships with the IDE. The kind folks at Arduino even made a tutorial for you:
Yes, I understand now how it works. aarg, I did not the blink program, the one I used wasn't explained like the link you provided. That link really clears up a lot for me. Thank you guys so much!