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 CCS Technical Support

Rotate LED

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



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Aug 27, 2014 1:33 pm     Reply with quote

This code lights up LEDs on PortB, bits 0 to 3. They are turned on
sequentially. Once turned on, the Leds stay on. This program
shows how to read from an array. I used PortB because that's the
way my hardware board is setup.
Code:

#include <18F452.h>
#fuses XT, BROWNOUT, PUT, NOWDT, NOLVP
#use delay(clock=4M)
#use rs232(baud=9600, UART1, ERRORS)

 int LED_LookupTable[8]={0,1,2,3,4,5,6,7};

#byte PORTB = getenv("SFR:PORTB")

//===================================
void main()
{
int i;

output_b(0x00);  // All Leds off initially, and PortB TRIS = all outputs

for(i = 0; i < 4; i++)
   {
    bit_set(PORTB, LED_LookupTable[i]);
    delay_ms(500);
   }

while(1);
}
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