79 lines
1.7 KiB
C++
79 lines
1.7 KiB
C++
#include <LiquidCrystal.h>
|
|
|
|
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
|
|
|
|
const int switchPin = 6;
|
|
int switchState = 0;
|
|
int prevSwitchState = 0;
|
|
int reply;
|
|
|
|
void setup()
|
|
{
|
|
Serial.begin(9600);
|
|
lcd.begin(16, 2);
|
|
pinMode(switchPin, INPUT);
|
|
}
|
|
|
|
void scroll(char message[], int position)
|
|
{
|
|
int n;
|
|
n = 15;
|
|
char *ptr = message;
|
|
while (n != -14)
|
|
{
|
|
lcd.clear();
|
|
lcd.setCursor(n, position);
|
|
if (n < 0)
|
|
{
|
|
ptr++;
|
|
}
|
|
lcd.print(ptr);
|
|
n--;
|
|
delay(250);
|
|
}
|
|
lcd.clear();
|
|
}
|
|
|
|
void loop()
|
|
{
|
|
scroll("Un mec entre dans un café", 0);
|
|
scroll("Plouf !", 1);
|
|
// switchState = digitalRead(switchPin);
|
|
// if (switchState != prevSwitchState)
|
|
// {
|
|
// if (switchState == LOW)
|
|
// {
|
|
// reply = random(8);
|
|
// lcd.clear();
|
|
// lcd.setCursor(0, 0);
|
|
// lcd.print("The ball says:");
|
|
// lcd.setCursor(0, 1);
|
|
// switch (reply)
|
|
// {
|
|
// case 0:
|
|
// lcd.print("Yes");
|
|
// break;
|
|
// case 2:
|
|
// lcd.print("No");
|
|
// break;
|
|
// case 3:
|
|
// lcd.print("Most likely");
|
|
// break;
|
|
// case 4:
|
|
// lcd.print("Certainly");
|
|
// break;
|
|
// case 5:
|
|
// lcd.print("Unsure");
|
|
// break;
|
|
// case 6:
|
|
// lcd.print("Ask again");
|
|
// break;
|
|
// case 7:
|
|
// lcd.print("Doubtful");
|
|
// break;
|
|
// }
|
|
// }
|
|
// }
|
|
// prevSwitchState = switchState;
|
|
}
|