Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

switch case

Status
Not open for further replies.

sankar mass

New Member
friends pls give me some example programs make use of switch case statement for pic micro controller .

eg port p1 -p4 =1110 means output is to display " hello "

eg port p1-p4 =1101 means output is to display " bye " .
this is just example .

want to display two names from two different data.

please guys
 
Why don't you have a try first and then we can tell you if/where you went wrong.

Mike.
 
Here is an example
Code:
var = PORT;
switch (var & 0x0F) {
case 0b00001110:
  display(" hello ");
  break;
case 0b00001101:
  display(" bye ");
  break;
default:
  break;
}

I would rather use if/else statements than switch/case. It is safer.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top