@@ 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");
}