Aduino
как исправить
#include
#include
#include
#include
#include
#define ledPin 8
#define btnPin 4
double number;
long sTime;
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
void setup() {
lcd.init();
Serial.begin(9600);
lcd.begin(16,2);
lcd.setCursor(0,0);
pinMode(btnPin, INPUT);
pinMode(ledPin, OUTPUT);
}
void loop() {
number = random(500, 5000);
lcd.print("Wait for the LED");
delay(number);
lcd.clear();
lcd.print(" PRESS!");
digitalWrite(ledPin, HIGH);
sTime = millis();
while (digitalRead(btnPin) == LOW);
lcd.clear();
lcd.print(" Reaction time: ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.print((millis() - sTime) / 1000.0);
lcd.print(" s");
delay(2000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" Another test");
lcd.setCursor(0, 1);
lcd.print(" in 5 seconds");
delay(5000);
lcd.clear();
digitalWrite(8, LOW);
}