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.

A simple logic question

Status
Not open for further replies.

Vizier87

Active Member
Hi guys,

Is this correct?

Code:
case ('p'||'P'):
         digit(0xce);
         break;

Basically, what I'm trying to do is to display the same thing when I enter either a "p" or "P".

This goes like Display("PpPpP") and it goes about showing the same characters. However when used this, it doesn't work and the 7-segment display just omitted the entire character.

However, if it is like this:
Code:
case ('p'):
         digit(0xce);
         break;
It works just fine but I have to put only a small "p" in my string.

What did I miss?

Thanks.
Vizier87.
 
Thanks NG. I'll try that out when I get back. Mind telling me what's wrong with the previous one though?

"||" is a boolean operation which evaluates to 0 if both operands are 0, or 1 otherwise.

'p'||'P' evaluates to 1

C:
case 'p'||'P':

is the same as:

C:
case 0x01:
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top