🚀 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 given Arduino code reads the input from pin2 and changes the output on pin1 based on whether the value from pin2 is HIGH (1) or LOW (0).

Explanation:

  • For each bit in 1011 sent to pin2:
    • 1 means pin2 is HIGH → pin1 is set to LOW.
    • 0 means pin2 is LOW → pin1 is set to HIGH.

Thus, for the sequence 1011:

  • pin2 (1) → pin1 = LOW
  • pin2 (0) → pin1 = HIGH
  • pin2 (1) → pin1 = LOW
  • pin2 (1) → pin1 = LOW

The resulting output for pin1 will be 0100.

Final Answer:

(B) 0100

Correct Answer: B) 0100

Latest Updates