View previous topic :: View next topic |
Author |
Message |
deltatech
Joined: 22 Apr 2006 Posts: 87
|
Switch Case won't work |
Posted: Fri Feb 10, 2012 9:47 am |
|
|
Hi All, I am having a problem getting Switch Case to work I don’t know what I am doing wrong but i am sure CCS Gurus will know what is problem something very simple but I can’t figure it . Many thanks in advance for any help
what I am trying to do is Flash LED1 if PIN_5B goes high and flash LED2 If PIN5B goes Low . but it is not working
Code: | #include <16F877A.h>
#device adc=16
#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=PORT1)
#define CAR_POWER PIN_B5
#define LED1 PIN_B4
#define LED2 PIN_B3
void main()
{
int1 last_button_1=FALSE;
while( TRUE )
{
switch (CAR_POWER) {
case 1:
output_high (LED1);
delay_ms(500);
output_low (LED1);
break;
case 0:
output_high (LED2);
delay_ms(500);
output_low (LED2);
break;
}
}
} |
|
|
|
tae
Joined: 15 Jan 2010 Posts: 11
|
|
Posted: Fri Feb 10, 2012 10:00 am |
|
|
replace
Code: | switch (Input(CAR_POWER)) |
|
|
|
deltatech
Joined: 22 Apr 2006 Posts: 87
|
|
Posted: Fri Feb 10, 2012 11:32 am |
|
|
tea you are a star many thanks it is working now |
|
|
|