Write a program that turns on an LED attached to Pin3 for 5 seconds then turns it off. The light should stay off for 3 seconds and then the LED should blink 10 times at a rate of 1 Hz (on and off each second).
This is what I have so far and I've tried looking at tutorials but not seeing any that specifically address the hertz aspect of it. Please help.
premobowei:
Write a program that turns on an LED attached to Pin3 for 5 seconds then turns it off. The light should stay off for 3 seconds and then the LED should blink 10 times at a rate of 1 Hz (on and off each second).
If the style of program you have shown is acceptable then to get 1 Hz you just need a sequence of delay(1000); statements. Maybe something like
for (byte n = 0; n < 10; n++) {
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
delay(1000);
}
Or maybe the delay()s should just be 500 each for a combined total of 1 second.
Note that the functions delay() and delayMicroseconds() block the Arduino until they complete and prevent it from doing other tasks. If that matters have a look at how millis() is used to manage timing without blocking in Several Things at a Time.
I don't think I do. I'm not trying to ask anyone to do my school work for me because this is schoolwork and I established that from the start. I'm just trying to get a scope of it so I can do it myself becuase we have our final project that I'll need this for too so I need to understand the scope of it not just in this instance. Thanks
Robin2:
If the style of program you have shown is acceptable then to get 1 Hz you just need a sequence of delay(1000); statements. Maybe something like
Or maybe the delay()s should just be 500 each for a combined total of 1 second.
Note that the functions delay() and delayMicroseconds() block the Arduino until they complete and prevent it from doing other tasks. If that matters have a look at how millis() is used to manage timing without blocking in [Several Things at a Time](http://forum.arduino.cc/index.php?topic=223286.0).
And see [Using millis() for timing. A beginners guide](http://forum.arduino.cc/index.php?topic=503368.0) if you need more explanation.
...R
Hi, thanks for your quick response. This is where I'm confused because he first says the led should stay on for certain time lengths and then also said frequency so I don't get it because it feels like 2 different time for the same tasks?
Does he mean he wants the sequence of on delay off delay (which equals to a blink) to be repeated 10 times in one second? So sorry but I'm slow. Does I hertz mean one second?
for those who have helped, thank you so so much. For those who seem rather uncomfortable and want to be micro-aggressive, I'm guessing you're doing so because perhaps you've answered the same question too many times, but I also wonder if you could just....not respond? Maybe?
premobowei: Does he mean he wants the sequence of on delay ....
The only way to get an answer to that question is to ask the person who set the assignment - none of us knows the answer.
Accidentally ambiguous assignments are not unusual and if you can't ask then in the paper you write describe the interpretation that you put on the question and the program that implements that interpretation.
Robin2:
Accidentally ambiguous assignments are not unusual and if you can't ask then in the paper you write describe the interpretation that you put on the question and the program that implements that interpretation.
Often put in the question as "State your assumptions..." or words to that effect.
Designed to prove to the examiner that even if you weren't able to get every single fact in the available time, you at least realised what you should be trying to find out, and answered as well as you could given imperfect facts.
And you explain how you might have handled a certain fact, had you known it.
Have you taken the advice to investigate for loops to improve your program ?
Remove the leading zeroes from your delay() parameters they cause the compiler to interpret the numbers as base 8 (ie octal) numbers instead of being decimal numbers