/* Blinky for LED's turns on and off with every 100ms ,500ms and 1s using delay function
*/
#include <18F4455.h>
#device ICD=TRUE
#fuses HS,NOLVP,NOWDT,PUT
#use delay(clock=20000000, crystal=20 MHz) // using 20 MHz crystal oscillator
/*Pin Configurations*/
#define FIRST_LED PIN_A0
#define SECOND_LED PIN_A1
#define THIRD_LED PIN_A2
void turn_on(int led)
{
switch (led) {
case 0 :
output_toggle(FIRST_LED);
break;
case 1 :
output_toggle(SECOND_LED);
break;
case 2 :
output_toggle(THIRD_LED);
break;
}
}
void main()
{
int count=1;
while (TRUE){
turn_on(0);
if (count ==5) {
turn_on(0);
turn_on(1);
}
else if (count ==10){
turn_on(0);
turn_on(1);
turn_on(2);
count =1;
}
count=count+1;
delay_ms(100);
}
}
*/
#include <18F4455.h>
#device ICD=TRUE
#fuses HS,NOLVP,NOWDT,PUT
#use delay(clock=20000000, crystal=20 MHz) // using 20 MHz crystal oscillator
/*Pin Configurations*/
#define FIRST_LED PIN_A0
#define SECOND_LED PIN_A1
#define THIRD_LED PIN_A2
void turn_on(int led)
{
switch (led) {
case 0 :
output_toggle(FIRST_LED);
break;
case 1 :
output_toggle(SECOND_LED);
break;
case 2 :
output_toggle(THIRD_LED);
break;
}
}
void main()
{
int count=1;
while (TRUE){
turn_on(0);
if (count ==5) {
turn_on(0);
turn_on(1);
}
else if (count ==10){
turn_on(0);
turn_on(1);
turn_on(2);
count =1;
}
count=count+1;
delay_ms(100);
}
}
No comments:
Post a Comment