Skip to content

Instantly share code, notes, and snippets.

Created August 21, 2016 13:58
Show Gist options
  • Save anonymous/cf7e7317381b61d33da926967f1105fa to your computer and use it in GitHub Desktop.
Save anonymous/cf7e7317381b61d33da926967f1105fa to your computer and use it in GitHub Desktop.
int panel_1 = 10;
int panel_2 = 12;
int panel_3 = 8;
int panel_4 = 9;
int panel_5 = 6;
int panel_6 = 7;
int bottomLight = 11;
int topLight = 5;
int backLight = 4;
int coinInput = 2;
int resetPin = 3;
void setup() {
// the setup routine runs once when you press reset:
digitalWrite(resetPin, HIGH);
delay(200);
pinMode(resetPin, OUTPUT);
delay(200);
//The reset function can only be triggered when the machine has completed its run and everything is back to its station
//this means setting up a boolean machineRunning = TRUE
//so the reset can only be triggered at machineRunning = !TRUE
//the coin mechanism will send a reset signal
pinMode(coinInput, INPUT_PULLUP);
pinMode(panel_1, OUTPUT);
pinMode(panel_2, OUTPUT);
pinMode(panel_3, OUTPUT);
pinMode(panel_4, OUTPUT);
pinMode(panel_5, OUTPUT);
pinMode(panel_6, OUTPUT);
pinMode(bottomLight, OUTPUT);
pinMode(topLight, OUTPUT);
pinMode(backLight, OUTPUT);
}
//------------------- Bottom Light -----------------------//
int bottomLight_On(int timeStart_on, int timeFinish_on) {
unsigned long currentMillis = millis();
int seconds = currentMillis / 1000;
if (seconds > timeStart_on && seconds < timeFinish_on) {
digitalWrite(bottomLight, HIGH);
}
}
int bottomLight_Off(int timeStart_off, int timeFinish_off) {
unsigned long currentMillis = millis();
int seconds = currentMillis / 1000;
if (seconds > timeStart_off && seconds < timeFinish_off) {
digitalWrite(bottomLight, LOW);
}
}
//------------------- Top Light -----------------------//
int topLight_On(int timeStart_on, int timeFinish_on) {
unsigned long currentMillis = millis();
int seconds = currentMillis / 1000;
if (seconds > timeStart_on && seconds < timeFinish_on) {
digitalWrite(topLight, HIGH);
}
}
int topLight_Off(int timeStart_off, int timeFinish_off) {
unsigned long currentMillis = millis();
int seconds = currentMillis / 1000;
if (seconds > timeStart_off && seconds < timeFinish_off) {
digitalWrite(topLight, LOW);
}
}
//------------------- Panel 1 -------------------------------//
int panel_1_On(int timeStart_on, int timeFinish_on) {
unsigned long currentMillis = millis();
int seconds = currentMillis / 1000;
if (seconds > timeStart_on && seconds < timeFinish_on) {
digitalWrite(panel_1, HIGH);
}
}
int panel_1_Off(int timeStart_off, int timeFinish_off) {
unsigned long currentMillis = millis();
int seconds = currentMillis / 1000;
if (seconds > timeStart_off && seconds < timeFinish_off) {
digitalWrite(panel_1, LOW);
}
}
//------------------- Panel 2 -------------------------------//
int panel_2_On(int timeStart_on, int timeFinish_on) {
unsigned long currentMillis = millis();
int seconds = currentMillis / 1000;
if (seconds > timeStart_on && seconds < timeFinish_on) {
digitalWrite(panel_2, HIGH);
}
}
int panel_2_Off(int timeStart_off, int timeFinish_off) {
unsigned long currentMillis = millis();
int seconds = currentMillis / 1000;
if (seconds > timeStart_off && seconds < timeFinish_off) {
digitalWrite(panel_2, LOW);
}
}
//------------------- Panel 3 -------------------------------//
int panel_3_On(int timeStart_on, int timeFinish_on) {
unsigned long currentMillis = millis();
int seconds = currentMillis / 1000;
if (seconds > timeStart_on && seconds < timeFinish_on) {
digitalWrite(panel_3, HIGH);
}
}
int panel_3_Off(int timeStart_off, int timeFinish_off) {
unsigned long currentMillis = millis();
int seconds = currentMillis / 1000;
if (seconds > timeStart_off && seconds < timeFinish_off) {
digitalWrite(panel_3, LOW);
}
}
//------------------- Panel 4 -------------------------------//
int panel_4_On(int timeStart_on, int timeFinish_on) {
unsigned long currentMillis = millis();
int seconds = currentMillis / 1000;
if (seconds > timeStart_on && seconds < timeFinish_on) {
digitalWrite(panel_4, HIGH);
}
}
int panel_4_Off(int timeStart_off, int timeFinish_off) {
unsigned long currentMillis = millis();
int seconds = currentMillis / 1000;
if (seconds > timeStart_off && seconds < timeFinish_off) {
digitalWrite(panel_4, LOW);
}
}
//------------------- Panel 5 -------------------------------//
int panel_5_On(int timeStart_on, int timeFinish_on) {
unsigned long currentMillis = millis();
int seconds = currentMillis / 1000;
if (seconds > timeStart_on && seconds < timeFinish_on) {
digitalWrite(panel_5, HIGH);
}
}
int panel_5_Off(int timeStart_off, int timeFinish_off) {
unsigned long currentMillis = millis();
int seconds = currentMillis / 1000;
if (seconds > timeStart_off && seconds < timeFinish_off) {
digitalWrite(panel_5, LOW);
}
}
//------------------- Panel 6 -------------------------------//
int panel_6_On(int timeStart_on, int timeFinish_on) {
unsigned long currentMillis = millis();
int seconds = currentMillis / 1000;
if (seconds > timeStart_on && seconds < timeFinish_on) {
digitalWrite(panel_6, HIGH);
}
}
int panel_6_Off(int timeStart_off, int timeFinish_off) {
unsigned long currentMillis = millis();
int seconds = currentMillis / 1000;
if (seconds > timeStart_off && seconds < timeFinish_off) {
digitalWrite(panel_6, LOW);
}
}
//------------------- Back Light -------------------------------//
int backLight_On(int timeStart_on, int timeFinish_on) {
unsigned long currentMillis = millis();
int seconds = currentMillis / 1000;
if (seconds > timeStart_on && seconds < timeFinish_on) {
digitalWrite(backLight, HIGH);
}
}
int backLight_Off(int timeStart_off, int timeFinish_off) {
unsigned long currentMillis = millis();
int seconds = currentMillis / 1000;
if (seconds > timeStart_off && seconds < timeFinish_off) {
digitalWrite(backLight, LOW);
}
}
void loop() {
//INSTEAD OF A RESET -- consider placing a currentmillis - previousmillis = seconds
// at the start of the program, making seconds a global variable, so that the seconds does not start counting until
//the coinacceptor sends a signal + machine is !Running
//the seconds can be reset at the start of the program sending everything back to begginning
int sensorVal = digitalRead(2);
if (sensorVal == HIGH) {
panel_1_On(1, 5);
panel_1_Off(5, 8);
panel_2_On(7, 10);
panel_2_Off(10, 13);
panel_3_On(13, 15);
panel_3_Off(15, 18);
panel_4_On(15, 20);
panel_4_Off(20, 25);
panel_5_On(24, 30);
panel_5_Off(30, 35);
panel_6_On(34, 38);
panel_6_Off(38, 40);
return;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment