switch case help!!!!

Status
Not open for further replies.

paddy_p

Member level 2
Joined
May 31, 2012
Messages
48
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
Mumbai India
Visit site
Activity points
1,680
Hello,

I am using switch case function in code.

Can i use multiple statements in each case or it should be single statement in each case?

thanks,
paddy
 

Please refer below mentioned code

Code:
switch(i)
            {
               case 0:
               output_high(pin_B7);        //turn on LED               
               output_high(pin_A2);        //clock to latch
               delay_us(100);
               output_low(pin_A2);
               delay_us(100);
               output_low(pin_B7);        //turn off LED               
               output_high(pin_A2);       //clock to latch
               delay_us(100);
               output_low(pin_A2);
               delay_us(100);
               break; 
               
               case 1:
               output_high(pin_B6);               
               output_high(pin_A2);        //clock to latch
               delay_us(100);
               output_low(pin_A2);
               delay_us(100);
               output_low(pin_B6);               
               output_high(pin_A2);        //clock to latch
               delay_us(100);
               output_low(pin_A2);
               delay_us(100);
               break;
        }

Is it valid?
 

I am just checking for alarm condition and if it occurs i have to blink the LED.

To do this i am toggling port pins in every case.

So i have written same cases for 8 values.
 

I just want to confirm that switch case supports multiple statements or not.

And i don't have hardware ready with me to check the output.
 




Yes, it's fine.

I like to keep the statements in the case within parentheses. But, that's a matter of personal preference and isn't necessary. Your code is fine.
 

Hello,

I have to make an indication device which has 120 LED's.

I have connected that LED's to one port of micro controller via 74HCT574 and ULN2004.

i.e Micro controller port -> 74HCT574-> ULN2004 -> LED's

For 120 LED's I have used multiple 74HCT574 IC'c and ULN2004 IC's.

I am sending common data on all 74HCT574 and enabling particular 74HCT574 by giving clock to it.

Is this circuit okay? And should I get enough intensity?

Please suggest.

thanks,
paddy
 
Last edited:

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…