Add skeleton of the game

This commit is contained in:
Gabriel Augendre 2021-04-28 23:27:30 +02:00
parent 71a19c0cb2
commit fac1fbdd1e
3 changed files with 58 additions and 3 deletions

View file

@ -12,3 +12,4 @@
platform = atmelavr
board = uno
framework = arduino
lib_deps = arduino-libraries/LiquidCrystal@^1.0.7

View file

@ -1,8 +1,51 @@
#include <Arduino.h>
#include <LiquidCrystal.h>
#include <main.h>
LiquidCrystal lcd(12, 11, 2, 3, 4, 5);
void setup() {
// write your initialization code here
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
randomSeed(analogRead(0));
lcd.begin(16, 2);
}
void loop() {
// write your code here
}
displayCountdown();
delay(1000);
byte randomWait = random(6, 32);
lcd.clear();
for (byte i = 0; i < randomWait; i++) {
if (i == 16) {
lcd.setCursor(0, 1);
}
lcd.print(".");
delay(500);
}
lcd.clear();
lcd.print("Maintenant !");
// TODO add code to determine winner, maybe use interrupts?
delay(2000);
lcd.clear();
}
void displayCountdown() {
lcd.setCursor(0, 0);
lcd.print("Prets ?");
lcd.setCursor(0, 1);
displayDigit("3");
delay(600);
displayDigit("2");
delay(600);
displayDigit("1");
}
void displayDigit(const char *digit) {
lcd.print(digit);
for (byte i = 0; i < 3; i++) {
delay(200);
lcd.print(".");
}
lcd.print(" ");
}

View file

@ -0,0 +1,11 @@
//
// Created by Gabriel Augendre on 28/04/2021.
//
#ifndef FASTEST_PRESSER_MAIN_H
#define FASTEST_PRESSER_MAIN_H
void displayCountdown();
void displayDigit(const char *digit);
#endif //FASTEST_PRESSER_MAIN_H