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

Switch Case won't work

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



Joined: 22 Apr 2006
Posts: 87

View user's profile Send private message

Switch Case won't work
PostPosted: Fri Feb 10, 2012 9:47 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Feb 10, 2012 10:00 am     Reply with quote

Code:
switch (CAR_POWER)

replace
Code:
switch (Input(CAR_POWER))
deltatech



Joined: 22 Apr 2006
Posts: 87

View user's profile Send private message

PostPosted: Fri Feb 10, 2012 11:32 am     Reply with quote

tea you are a star many thanks it is working now Very Happy
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