What is the output of the output on the Serial Monitor for the program given below if the input supplied to pin1 is of the form 0111? [code] int

Pham Quỳnh

New member
What is the output of the output on the Serial Monitor for the program given below if the input supplied to pin1 is of the form 0111?
Code:
int pin1=11;
void setup() {
    pinMode(pin1,INPUT);
    Serial.begin(9600);
}
void loop() {
    if(digitalRead(pin1)==1) {
        Serial.print(“1 0”);
    }
    else {
        Serial.print(“-1 0”);
    }
}
A. -1 0 1 1
B. -1 0 0 1 0 1 0
C. 1 0 1 1 0 1 1
D. -1 1 1 0 1 1 0
 
Answer: B
Explanation: The above code prints a 1 and a 0 for every digital HIGH signal that it receives and prints a -1 and 0 for every digital LOW that it receives. This is the premise for the method of RZ Encoding. It is used in telecommunications for sending and receiving signals.
 

Tìm kiếm

Back
Top