I need to build a program of sequential leds with a change time for potentiometer (A/D).
I have a pic16F877A.
Would anybody help me?
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
Posted: Sat Feb 19, 2011 6:51 pm
1. Setup the ADC using CCS functions. Search the forum for 'read_adc'
for sample code. Here is a link to forum's search page:
http://www.ccsinfo.com/forum/search.php
2. Make a continuous while() loop with beginning and ending braces, like this:
Code:
while(1)
{
}
3. At the start of the while loop, read the ADC value. Put it in a variable
named 'led_delay'.
4. The ADC will give you a number from 0 to 255 (or 0 to 1023, if you
set it up that way). Multiply the ADC value by some number, to give the
desired range of delays (in milliseconds). Make sure you declare a
variable with a size that is big enough to hold the number.
5. Put in one or more sets of statements as shown below in the while()
loop. This will turn each LED on and off for the desired period:
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum