CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Potentiometer and change time of sequential leds.

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Marcusfbi1



Joined: 18 Feb 2011
Posts: 1
Location: Brazil

View user's profile Send private message Yahoo Messenger MSN Messenger

Potentiometer and change time of sequential leds.
PostPosted: Sat Feb 19, 2011 4:40 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Feb 19, 2011 6:51 pm     Reply with quote

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:
Code:

output_high(LED1);
delay_ms(led_delay);
output_low(LED1);
delay_ms(led_delay);


Read the CCS manual for all the functions that you use. Make sure
you are using parameters that the function can accept. Link to manual:
http://www.ccsinfo.com/downloads/ccs_c_manual.pdf

This is a basic outline of one way to do it. But you need to do this
program. We don't want to do it for you.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group