Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

switch case help!!!!

Status
Not open for further replies.

paddy_p

Member level 2
Joined
May 31, 2012
Messages
47
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
Mumbai India
Activity points
1,669
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?
 

can u post the full code and what is excepted output......
 

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.
 

the code looks fine but what is output u are getting now
 

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.
 

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?



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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top