i was given a task by my teacher.
I have to control the brightness of LED on pin 13 of Arduino Uno Board , i.e dimming&brightening it in a continuous fashion.
But i cannot use the analogWrite()/timer library
I have to do it using timers.
Can anybody give me a headstart as to how can i go about it or any sort of references/links/codes?
Have a look at the blink without delay example in the IDE, and speed it up a bit, and make the duty cycle variable.
And please don't SHOUT
OK, now come on! This is not your first query and the second time you are seeking assistance with an assignment. :smiley-eek:
You now know how the forum works. Please go and select "More"->"Modify" to the bottom right of your first post above and correct the subject title. :smiley-roll-sweat: Hint: AWOL has done it for you, you can cut and paste it easily (if you do it in the right order). :smiley-lol:
But the next thing I - we - want you to do, is to report in detail how your assessment went with the previous assignment.
Having done that, explain what you mean by "I have to do it using timers." What functions are you or are you not permitted to use? AWOL has given you the basis but it require the use of millis() (and no other).
Hey! I already posted my final working code on my previous query.It went very well & was approved by my teacher as well!
Regarding this one, I cannot use the analogWrite() function.
i have generate a pwm using timers and via that dim&brighten the led in a continuous fashion.Im supposed to use timer registers. i dont want it to blink, Its brightness is supposed to vary from Lowest to highest to again lowest continuously.
I hope i was able to frame my question & post the details in a proper manner! :)
I cannot use the analogWrite() function.
...because pin 13 isn't a PWM pin.
You don't even need to mess with the timer registers.
No no, im aware of that. Its a task assigned to me that i have to do it using timer registers only .
i have to do it using timer registers only .
That is simply not possible.
Well, that is what I was asking. Do you specifically have to mess around with the timer registers, or just use the millis() function?
Using millis(), you can easily execute a PWM in 20 steps with a 20 ms or 50 Hz cycle. Even without millis(), you can use loops to execute PWM with even more steps.
Set registers to get interrupt in given intervals (or wait for some TCNT value in loop) a toggle the LED on pin 13 when this happens. Such as
if (TCNT>someValue) turnLEDOn();
if (something) update_someValue();