PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Aug 27, 2014 1:33 pm |
|
|
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);
} |
|
|