यदि "पिन2" को "1011" भेजा जाता है जहां 1 5V है और 0 0V है तो "पिन1" का आउटपुट क्या है?
What is the output of “pin1” if “pin2” is sent “1011” where 1 is 5V and 0 is 0V?
int pin1 = 12;
int pin2 = 11;
void setup() {
pinMode(pin1, OUTPUT);
pinMode(pin2, INPUT);
Serial.begin(9600);
}
void loop() {
if(digitalRead(pin2)==1) {
digitalWrite(pin1,LOW);
}
else if(digitalRead(pin2)==0) {
digitalWrite(pin1,HIGH);
}
}
A)
B)
C)
D)
Explanation:
For each bit sent to pin2 ("1011"):
- First bit (1): pin2 is HIGH → pin1 is LOW (0V).
- Second bit (0): pin2 is LOW → pin1 is HIGH (5V).
- Third bit (1): pin2 is HIGH → pin1 is LOW (0V).
- Fourth bit (1): pin2 is HIGH → pin1 is LOW (0V).
Final output of pin1: "0100".
Correct Answer: (A) 0100.