NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Project Help and Ideas » LED blink with variable flash
March 30, 2011 by Ace |
I'm trying to alter the led blink code so I can use a pot to adjust the flash rate. Here's my modification:
I have the center of the pot connected to PC0, left lug to GND, and right lug to AREF. When I turn the pot, nothing happens. Any suggestions? Thank you. |
---|---|
March 31, 2011 by 6ofhalfdozen |
Hiya Ace, I am not an expert in C, but I see a few problems. The most important one that I see is that you don't ever actually call ADC_Read in your main loop, so the ADC is never actually read. You do initialize the ADC on line 33, but never call to read it. On line 42, your comments claim that you set the LED Off time dependant on the pot. In actuality, since you have the value set to (500) it will always be 500ms off. You need to somehow put the ADC result into that value.. If this were my code, I would use the following as my "main" code. Again, the warning, I am not a C programmer. This "should" work but might need some minor C related code tweeking, so fyi. hopefully this helps get you on the right track to where you need to go.
|
Please log in to post a reply.
Did you know that binary numbers use base 2 to represent numbers, and these are important for understanding microcontroller registers? Learn more...
|