save
This commit is contained in:
parent
5cd636a032
commit
fd81e95b14
58
Kitt/Kitt.ino
Normal file
58
Kitt/Kitt.ino
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
#include <LiquidCrystal.h>
|
||||||
|
|
||||||
|
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
|
||||||
|
|
||||||
|
const int switchPinA = 8;
|
||||||
|
const int switchPinB = 13;
|
||||||
|
int switchState = 0;
|
||||||
|
int menuA = 0;
|
||||||
|
int menuB = 0;
|
||||||
|
|
||||||
|
void setup()
|
||||||
|
{
|
||||||
|
lcd.begin(16, 2);
|
||||||
|
Serial.begin(9600);
|
||||||
|
pinMode(switchPinA, INPUT);
|
||||||
|
pinMode(switchPinB, INPUT);
|
||||||
|
lcd.clear();
|
||||||
|
lcd.setCursor(1, 0);
|
||||||
|
lcd.print("WELCOME");
|
||||||
|
lcd.setCursor(0, 1);
|
||||||
|
lcd.print("NIGHT RIDER!");
|
||||||
|
delay(500);
|
||||||
|
lcd.clear();
|
||||||
|
lcd.setCursor(0, 1);
|
||||||
|
lcd.print("Computing....");
|
||||||
|
delay(500);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop()
|
||||||
|
{
|
||||||
|
menuA = digitalRead(switchPinA);
|
||||||
|
Serial.print(menuA);
|
||||||
|
menuB = digitalRead(switchPinB);
|
||||||
|
lcd.setCursor(0, 1);
|
||||||
|
lcd.print("Waiting for instructions...");
|
||||||
|
lcd.clear();
|
||||||
|
lcd.setCursor(0, 0);
|
||||||
|
if (menuA == HIGH)
|
||||||
|
{
|
||||||
|
Serial.print("Menu A ");
|
||||||
|
Serial.print(menuA);
|
||||||
|
Serial.print("\n");
|
||||||
|
lcd.clear();
|
||||||
|
lcd.print("Hello...");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (menuB == HIGH)
|
||||||
|
{
|
||||||
|
Serial.print("Menu B ");
|
||||||
|
Serial.print(menuB);
|
||||||
|
Serial.print("\n");
|
||||||
|
lcd.clear();
|
||||||
|
lcd.setCursor(0, 1);
|
||||||
|
lcd.print("Sylvain!");
|
||||||
|
}
|
||||||
|
|
||||||
|
delay(250);
|
||||||
|
}
|
|
@ -9,70 +9,50 @@ int reply;
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
Serial.begin(9600);
|
|
||||||
lcd.begin(16, 2);
|
lcd.begin(16, 2);
|
||||||
pinMode(switchPin, INPUT);
|
pinMode(switchPin, INPUT);
|
||||||
}
|
lcd.print("ASK THE");
|
||||||
|
lcd.setCursor(0, 1);
|
||||||
void scroll(char message[], int position)
|
lcd.print("Crystal Ball!");
|
||||||
{
|
|
||||||
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()
|
void loop()
|
||||||
{
|
{
|
||||||
scroll("Un mec entre dans un café", 0);
|
switchState = digitalRead(switchPin);
|
||||||
scroll("Plouf !", 1);
|
if (switchState != prevSwitchState)
|
||||||
// switchState = digitalRead(switchPin);
|
{
|
||||||
// if (switchState != prevSwitchState)
|
if (switchState == LOW)
|
||||||
// {
|
{
|
||||||
// if (switchState == LOW)
|
reply = random(8);
|
||||||
// {
|
lcd.clear();
|
||||||
// reply = random(8);
|
lcd.setCursor(0, 0);
|
||||||
// lcd.clear();
|
lcd.print("The ball says:");
|
||||||
// lcd.setCursor(0, 0);
|
lcd.setCursor(0, 1);
|
||||||
// lcd.print("The ball says:");
|
switch (reply)
|
||||||
// lcd.setCursor(0, 1);
|
{
|
||||||
// switch (reply)
|
case 0:
|
||||||
// {
|
lcd.print("Yes");
|
||||||
// case 0:
|
break;
|
||||||
// lcd.print("Yes");
|
case 2:
|
||||||
// break;
|
lcd.print("No");
|
||||||
// case 2:
|
break;
|
||||||
// lcd.print("No");
|
case 3:
|
||||||
// break;
|
lcd.print("Most likely");
|
||||||
// case 3:
|
break;
|
||||||
// lcd.print("Most likely");
|
case 4:
|
||||||
// break;
|
lcd.print("Certainly");
|
||||||
// case 4:
|
break;
|
||||||
// lcd.print("Certainly");
|
case 5:
|
||||||
// break;
|
lcd.print("Unsure");
|
||||||
// case 5:
|
break;
|
||||||
// lcd.print("Unsure");
|
case 6:
|
||||||
// break;
|
lcd.print("Ask again");
|
||||||
// case 6:
|
break;
|
||||||
// lcd.print("Ask again");
|
case 7:
|
||||||
// break;
|
lcd.print("Doubtful");
|
||||||
// case 7:
|
break;
|
||||||
// lcd.print("Doubtful");
|
}
|
||||||
// break;
|
}
|
||||||
// }
|
}
|
||||||
// }
|
prevSwitchState = switchState;
|
||||||
// }
|
|
||||||
// prevSwitchState = switchState;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue