~josealberto4444/arduino-quiz

d5eaefd5530689ab21814ecdebe5abcda1f84738 — josealberto4444 2 years ago 5397023
Add welcome and link it to motion event
1 files changed, 29 insertions(+), 2 deletions(-)

M questionsAndAnswers/questionsAndAnswers.ino
M questionsAndAnswers/questionsAndAnswers.ino => questionsAndAnswers/questionsAndAnswers.ino +29 -2
@@ 26,13 26,40 @@ void scrollVMessage(String message) {
  }
}

volatile bool motion = 0;

void detectMotion() {
  motion = true;
}

void welcome() {
  tone(8, 4978, 40);
  delay(100);
  tone(8, 4978, 40);
  lcd.clear();
  lcd.noBacklight();
  delay(300);
  lcd.backlight();
  delay(300);
  lcd.noBacklight();
  delay(300);
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("Hello!");
  delay(1000);
  motion = false;
}

void setup() {
  attachInterrupt(0, detectMotion, RISING);
  lcd.init();
  lcd.backlight();
}

void loop() {
  scrollVMessage("This is quite a long message to show in this tiny screen. =P");
  scrollHMessage("This is quite a long message to show in this tiny screen. =P");
  if (motion) welcome();
  delay(100);
//  scrollVMessage("This is quite a long message to show in this tiny screen. =P");
//  scrollHMessage("This is quite a long message to show in this tiny screen. =P");
}