In the video [“Hello, world” from scratch on a 6502 — Part 1] by youtuber Ben Eater he shows a line of code 10 minutes 30 seconds into the video that uses an expressioin I simply can't find.
I've tried finding it in the arduino documentation website, tried searching it directly and I haven't found it on stackoverflow either... here is the code:
const char ADDR[]={22, 24, 26...} // these are pins in the Arduino Mega
void setup() {
for (int n = 0; n < 16; n += 1) {
pinMode(ADDR[n], INPUT);
}
Serial.begin(57600);
}
void loop() {
for (int n = 0; n < 16; n +=1) {
int bit = digitalRead(ADDR[n]) ? 1 : 0;
Serial.print(bit);
}
Serial.println();
}
In the line of code int bit = digitalRead(ADDR[n]) ? 1 : 0;
is the expression I haven't seen anywhere else. It's supposed to mean if digitalRead(ADDR[n]) is true then add a 1 if not add a 0 then asign it to the integer variable bit. I haven't seen the ? True : False
expression anywhere else and I want to know where its reference is and where to use it and stuff like that. I don't even know what it's called!
Thank you if you answered! I'm still learning and I think tricks like these will help me immensely.