more than 4 cars

This commit is contained in:
Jeff Clement 2016-02-13 13:30:31 -07:00
parent 1d978cb224
commit e238d40bdd
1 changed files with 10 additions and 6 deletions

View File

@ -1,7 +1,10 @@
/*
* Blink
* Turns on an LED on for one second,
* then off for one second, repeatedly.
_ __ _ _ __ _____ ___
| |/ _ _| |__ | |/ /__ _ _ __|_ _|_ _|_ __ ___ ___ _ __
| ' | | | | '_ \| ' // _` | '__ | | | || '_ ` _ \ / _ | '__|
| . | |_| | |_) | . | (_| | | | | | || | | | | | __| |
|_|\_\__,_|_.__/|_|\_\__,_|_| |_| |___|_| |_| |_|\___|_|
*/
#include "Arduino.h"
@ -13,6 +16,7 @@ LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
#define PIN_RESET 2
#define PIN_CAR1 3
#define PIN_LED LED_BUILTIN
#define DISPLAY_LINES 4
typedef struct {
// input pin for this car
@ -25,7 +29,7 @@ typedef struct {
#define PIN_CAR_STARTING 3
// number of cars (4 max)
#define CAR_COUNT 2
#define CAR_COUNT 4
// array of cars
Car cars[CAR_COUNT];
@ -48,7 +52,7 @@ void setup()
}
// initialize LCD
lcd.begin(20, 4);
lcd.begin(20, DISPLAY_LINES);
lcd.backlight();
lcd.setCursor(1,1);
lcd.print("Jeff's Inept");
@ -72,7 +76,7 @@ void displayTimers() {
seenCar[i] = false;
}
for(short place=0; place<CAR_COUNT; place++) {
for(short place=0; place<min(CAR_COUNT, DISPLAY_LINES); place++) {
// find which is the fastest car that hasn't already been processed
short currentCar = -1;