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.

What Does the Exclamation Mark Mean in This Line of C18 Code?

Status
Not open for further replies.
Hi there,
It means 'not equal to'. So the succeeding code (in the while loop) will repeat as long as switch_pin is not equal to 1 (ie while the pin logic value is low).
Hope that helps!
Ant
 
Depends on what the voice inside of your head tells you! Both answers are right. While not equal to something would be how I do it. While I'm not dry , keep using the towel vs. When I'm dry don't use the towel.

Something to think about!
 
Ok, thanks. So (Switch_Pin == 0); would do it.

Cheers.

Some coders would write the comparison like this: (0 == Switch_Pin)
So if you accidentally mistype it: (0 = Switch_Pin)
The compiler will detect that and give you an errror, but if you mistype it: (Switch_Pin = 0)
The compiler cannot detect the error you made.

And,
(Switch_Pin == 0)
is not the same as:
(Switch_Pin != 1)

They may produce the same behavior depending how the variable is defined.. and depending on the compiler.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top