I want to display the date on my serial monitor with the value of sensor
heres the code:
int redpin= 13;
int greenled = 7;
int buzzer = 11;
int gasA0 = A0;
// Your threshold value
int sensorThres = 400;
int date = date;
void setup() {
pinMode(greenled, OUTPUT);
pinMode(redpin, OUTPUT);
pinMode(buzzer, OUTPUT);
pinMode(gasA0, INPUT);
Serial.begin(9600);
}
void loop() {
int analogSensor = analogRead(gasA0);
Serial.print(" ");
Serial.println(analogSensor);
// Checks if it has reached the threshold value
if (analogSensor > sensorThres)
{
digitalWrite(greenled,LOW);//green led stay
digitalWrite(redpin,HIGH); //turns on led and buzzer
tone(buzzer,100);
}
else
{
digitalWrite(redpin,LOW); //turns off led and buzzer
digitalWrite(greenled,HIGH);//green led stay
noTone(buzzer);
}
delay(400);
}
I try to create a device that will detect a gas but I want to display the current date in my serial monitor continuously
The time value is prepended by the Arduino Serial Monitor to every line received from Arduino. If you copy the lines from Serial Monitor to Excel, just add a column with the date in Excel directly.
If you want the Arduino to print the timestamp, then you can use the Arduino Time library and some source of time. The source of time can be manual entry, a RTC module or with a.networking module you could retrieve time from a time server. See the examples of the Time library
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.