I'm working on an Arduino project for multiple switches to be turned on in a sequence (4,3,1,2). I've been able to find a code that would work but I am struggling to understand what is happening.
Its a return function that makes sense, however the "?" and ":0" is where I get lost
Here is the code
uint8_t readSwitches()
{
return (analogRead(A1) > 500 ? (1<<1) : 0)
| (analogRead(A2) > 500 ? (1<<2) : 0)
| (analogRead(A3) > 500 ? (1<<3) : 0)
| (analogRead(A4) > 500 ? (1<<4) : 0);
}
Can someone explain what is happening