Hi.... My Uno R4 Wifi is NOT sending words or letters in the Serial Monitor. Like for the word detected it is sending the numbers 1668572516.
int LED = 13;
int IR = 3;
void setup() {
pinMode(LED, OUTPUT);
pinMode(IR, INPUT);
Serial.begin(9600);
}
void loop() {
int IR = digitalRead(3);
if(digitalRead(IR == 0)){
digitalWrite(LED, HIGH);
Serial.println('Detected');
}
else{
digitalWrite(LED, LOW);
}
}
Hi @Samar2013
Single quotes ('
) can only be used with a single character literal (e.g., Serial.println('D')
). You must wrap string literals in double quotes ("
):
Serial.println("Detected");
This is the cause of the unexpected output you saw in Serial Monitor.
There is also a bug in your code here:
Please carefully study the Arduino language reference for digitalRead
to learn how to use the function correctly:
system
Closed
3
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.