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.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…