🚀 Hurry! Offer Ends In
00 Days
00 Hours
00 Mins
00 Secs
Enroll Now
X

यदि "पिन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
1110
B
0100
C
1111
D
1011
Explanation

The code reads the value on pin2 and sets pin1 based on that:

  • If pin2 is HIGH (5V), pin1 is set to LOW (0V).
  • If pin2 is LOW (0V), pin1 is set to HIGH (5V).

For the sequence "1011" sent to pin2:

  • pin2 = 1 (HIGH)pin1 = LOW (0V)
  • pin2 = 0 (LOW)pin1 = HIGH (5V)
  • pin2 = 1 (HIGH)pin1 = LOW (0V)
  • pin2 = 1 (HIGH)pin1 = LOW (0V)

Thus, the output of pin1 will be 0100.

The correct answer is:

(B) 0100.

Correct Answer: B) 0100

Latest Updates