Can I use 'on' and 'off' as variable names?

I notice that the words on and off show up in red in the Arduino IDE. Does that mean they already represent something else? For ease of reading, I thought about using them as variables. here’s a quick example of what I mean:

const boolean on = true;
const boolean off = false;
void setup() {
  // put your setup code here, to run once:

}

void loop() {
Lights(on);
delay(1000);
Lights(off);
}

void Lights(boolean val) {
  digitalWrite(13,val);
}

Would there be any reason NOT to do this, that would cause unforeseen problems?
Thanks.

You can do it. I would personally pick different names just because I don't like to use the really common stuff like that. It's too easy to mess up and try to reuse the same name. Something like lightOn and lightOff might give a little more information when you see them later.

But in answer to your question, as long as you don't get a multiple definition error (if some library you included already uses those names) there's nothing stopping you from using those.

But why not just use true and false?

Thanks for the quick reply. Maybe it would be better not to use something so common. I'll use something more specific.

"on" and "off" don't make much sense as variable names, because they are going to look more like the status of something.

I notice that the words on and off show up in red in the Arduino IDE.

That is because the words appear in a keywords.txt file belonging to a library. The colour coding occurs whether or not you are using the library in the program.

UKHeliBob:
The colour coding occurs whether or not you are using the library in the program.

We live and learn: I had assumed it was for libraries involved in the program. Good to know.