Skip to content

Instantly share code, notes, and snippets.

@vishal-rana
Created April 13, 2017 02:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vishal-rana/813f807b7b375557e9636fc374361fa3 to your computer and use it in GitHub Desktop.
Save vishal-rana/813f807b7b375557e9636fc374361fa3 to your computer and use it in GitHub Desktop.
#include <Wire.h> // Enable this line if using Arduino Uno, Mega, etc.
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
#include "NerdyTimer.h"
// set pin numbers
const int resetButtonPin = A6; //reset pin for all tracks
//define start pin, stop pin, and i2c address for 7-segment display
NerdyTimer track_1(A0,A1,0x71);
NerdyTimer track_2(A2,A3,0x70);
NerdyTimer track_3(A4,A5,0x72);
void setup() {
Serial.begin(9600);
pinMode(resetButtonPin, INPUT_PULLUP);
// set laser trip wire threshholds
track_1.calibrateSolarPanels();
track_2.calibrateSolarPanels();
track_3.calibrateSolarPanels();
track_1.start_display();
track_2.start_display();
track_3.start_display();
}
void loop() {
check_reset_button_status();
track_1.update_race_status();
track_2.update_race_status();
track_3.update_race_status();
delay(50); //a faster display write rate (aka smaller delay) causes jitter on the seven segment screen.
}
void check_reset_button_status(){
int button_status = digitalRead(resetButtonPin);
if(button_status == HIGH){
track_1.reset_status();
track_2.reset_status();
track_3.reset_status();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment