9 years, 8 months ago.

How do I convert this statement "digitalWrite(s0Pin,(num & 1) ? HIGH : LOW);"

Hello again, I'm trying to convert a library I'd written for the Arduino for an analog multiplexer and use the above statement to set a pin high or low depending on a bit in the selector number. I thought something like (num&1)?s0Pin=HIGH:s0Pin=LOW; might work.

Cheers Mike

1 Answer

9 years, 8 months ago.

DigitalOut s0Pin(p0); // p0 is valid pinName for NXP targets, use platform specific PinName

s0Pin = (num & 1) ? 1: 0; // considering that 1 is HIGH and 0 is LOW.

Regards,
0xc0170

Accepted Answer