Could not convert from void to bool??

Having trouble with if(digitalWrite(13,HIGH)){

fm_receiver.ino (1.37 KB)

digitalWrite does not return any value so testing it is meaningless.

If you are thinking that you want to test whether pin 13 is HIGH, either set/clear a flag when you set/clear pin 13 and then test the flag, or you can read it's value on PINB:PB5.

A flag uses more memory ;) But is more future proof.

If needed, I directly read pin 13 with a digitalRead.

Does digitalRead work with a pin configured for output? Sorry, I don't use the Arduino language.

DKWatson: Does digitalRead work with a pin configured for output?

Yes, it does. Possibly in a more convoluted way for compatibility reasons (code works both on ARM and AVR).

PS not sure if it works on both architectures for the specific purpose.

The fact it works on AVR and ARM does not make it convoluted. The code for AVR and ARM just is different. It is a bit more convoluted because of the pin to port and bit conversion but that's the same as with a write. Rest isn't rocket science.

I like to just use the digitalRead() instead of a variable because with a variable you have to pay attention to keep the variable and the pin in sync.

I like to just use the digitalRead() instead of a variable because with a variable you have to pay attention to keep the variable and the pin in sync.

If you never write anything but the contents of the variable to the pin, that is NOT at all even close to remotely difficult.

And, shouldn't you being paying attention as a programmer? It's been my experience that paying attention is cheaper than not paying attention.

PaulS: If you never write anything but the contents of the variable to the pin, that is NOT at all even close to remotely difficult.

Not for us, but to newbies the urge of directly calling digitalWrite() seems to be huge.

PaulS: And, shouldn't you being paying attention as a programmer? It's been my experience that paying attention is cheaper than not paying attention.

Tell that the newbies ;)