/* clue post used for treasure hunts V2.4 - Eric Linville
* box type construction with drawer exiting at bottom, to be mounted on a vertical surface
* single servo that opens and closes locks
* 4x20 LCD screen with I2C interface connected to sda and scl on mega
* four keys with magnetic reed switches connected to 23,23,24,25
* final code to be sum of riddle-enter 4 digit code to open (compared to openCode)
* servo to control latch (servoLock) connected to 6
* If correct then the servo opens releasing the drawer to decend slowly with a gas shock.
* written for the arduino mega, one servo, two LEDs, one I2C LCD(4x20, address 0x26) one 4x4 keypad and five reed switches
* To conserve power a Pololu switch is attached to power supply, output from 12 turns power off after timer elapses
* keypad button presses or insert of keys resets timer to prevent autoshut off
* battery power needed will depend on how fast the servo and LCD consumes the battery.
* sealed led acid 6 volt battery to feed system should have enough capacity to operate for several hours
* auto shutoff writes program location to EEPROM before power off to save power
* upon restart program resumes at previous location by reading EEPROM back into Step
* to reset EEPROM press and hold A on keypad during startup. EEPROM will clear to 0 then set Step to 0 and then run program (used for testing)
* to reset EEPROM for the actual hunt press and hold B on keypad. EEPROM will reset to 0 then shutdown. when restarted with ring of power the program will start from 0
*/
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <Servo.h>
#include <EEPROM.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
Servo servoLock; //name of the servo attached to the locking mechanism, connected to pin 6 PWM
const int row1 = 2; //rows and collums of the keypad
const int row2 = 3;
const int row3 = 4;
const int row4 = 5;
const int col1 = 8;
const int col2 = 9;
const int col3 = 10;
const int col4 = 11;
const int ledG = A0; //green LED
const int ledR = A1; //red LED
const int Off = 12; //output that controls the auto off sequence, connected to Pololu switch that controls power to arduino, auto off works only with external power, not usb power
const int key1 = 53; //reed swtich 1 connected to gnd and this input
const int key2 = 51; //reed swtich 2 connected to gnd and this input
const int key3 = 49; //reed swtich 3 connected to gnd and this input
const int key4 = 47; //reed swtich 4 connected to gnd and this input
int button = 0; //stores which button was pressed to be acted on
int digit = 0; //stores which position of the four digit code you are entering
int code = 0; //stores all numbers entered added together to be compared to open code when all four are entered
int Step = 0; //variable used to determine location of program, saved to EEPROM before shut down
int openCode = 1984; //adjust this number to change final code that opens lock
int autoOffCount = 0; // variable that is indexed +1 everytime loop cycles
int autoOff = 10; //value that is subracted from everyime autoOffCount reaches 200 (200 = ~ 1sec) depending on cycle time,
int servoClosed=1250; //adjust this number for servo position to be locked
int servoOpen=1850;//adjust this numer for servo position to be unlocked
int relock_delay = 30;
int run_once = 0;
//if this is altered also adjust numbers at repeat clue button pushes to match (line )
//count of autoOffCount is sent to serial monitor so you can time how long it takes loop cycle time for your arduino and adjust accordingly.
void setup() {
lcd.init();
lcd.backlight();
Serial.begin(9600); //start the serial monitor
//EEPROM is 0,step#
EEPROM.write(0,0); //-------I reset the step to test each one--------------remove this prior to final operation for EEPROM to operate in step as opposed to starting from 0 at every startup
pinMode(row1, OUTPUT); //set the pin modes of the keypad
pinMode(row2, OUTPUT);
pinMode(row3, OUTPUT);
pinMode(row4, OUTPUT);
pinMode(col1, INPUT_PULLUP);
pinMode(col2, INPUT_PULLUP);
pinMode(col3, INPUT_PULLUP);
pinMode(col4, INPUT_PULLUP);
pinMode(ledR, OUTPUT); //red LED
pinMode(ledG, OUTPUT); //green LED
pinMode(Off, OUTPUT); //Output that controls auto off sequence, connected to mosfet that controls source power
pinMode(key1, INPUT_PULLUP);
pinMode(key2, INPUT_PULLUP);
pinMode(key3, INPUT_PULLUP);
pinMode(key4, INPUT_PULLUP);
// pinMode(door, INPUT_PULLUP);
digitalWrite(Off, LOW); //verify that off pulse output is low
/////////("---------20---------") this is used for spacing of the 20 digits on the LCD screen
lcd.print(" Contact Initiating");
delay(500);
lcd.print(".");
delay(500);
lcd.print(".");
delay(500);
lcd.print(".");
delay(500);
lcd.clear();
lcd.print(" Link Established");
delay(500);
lcd.clear();
servoLock.attach(13); //attach servo to pin 13 PWM
//Locking at power on may not be desirable
servoLock.writeMicroseconds(servoClosed);//adjust this number to set the servo to close the lock
//the following is where the EEPROM is reset back to zero when holding either A button or B buton during startup
//Check for button A
digitalWrite(row1, LOW); //engage key pad row 1
if (digitalRead(col4) == LOW)//a button pressed
{
Serial.print("a button pressed");
EEPROM.write(0, 0);//reset EEPROM back to 0 and run program
lcd.clear();
lcd.print("EEPROM set to 0");
}
digitalWrite(row1, HIGH);//disengage key pad row 1
delay(250);
//Check for button B
digitalWrite(row2, LOW);//engage keypad row2
if (digitalRead(col4) == LOW)//b button pressed
{
Serial.print("b button pressed");
EEPROM.write(0, 0);//reset EEPROM back to 0 and shutdown
lcd.clear();
lcd.print("EEPROM set to 0");
delay(1000);
autoOff = 0;
autoOFF();
}
digitalWrite(row2, HIGH);//disengage keypad row 2
delay(250);
//Check for Button D
digitalWrite(row1, LOW);//engage keypad row4
if (digitalRead(col1) == LOW)//d button pressed
{
Serial.print("d button pressed");
EEPROM.write(0, 0);//reset EEPROM back to 0 and shutdown
lcd.clear();
lcd.print("EEPROM set to 0");
lcd.setCursor(0, 1);
lcd.print(" Opening");
lcd.print(". ");
delay(500);
lcd.print(". ");
delay(500);
lcd.print(". ");
delay(500);
lcd.print(". ");
delay(500);
servoLock.writeMicroseconds(servoOpen);
delay(1000);
lcd.clear();
lcd.setCursor(0, 1);
lcd.print(" Relocking in:");
//lcd.setCursor(16, 1);
//lcd.print(relock_delay);
while (relock_delay > 0) {
if (relock_delay < 10) {
lcd.setCursor(16, 1);
lcd.print(" ");
}
lcd.setCursor(16, 1);
lcd.print(relock_delay);
Serial.print(relock_delay);
relock_delay--;
delay(1000);
}
lcd.clear();
lcd.setCursor(0, 1);
lcd.print(" Relocking now!");
delay(1000);
servoLock.writeMicroseconds(servoClosed);
delay(1000);
//lcd.clear();
//lcd.print("Shutting down now");
//delay(1000);
autoOff = 0;
autoOFF();
}
digitalWrite(row1, HIGH); //disengage keypad row 2
delay(250);
//end reset EEPROM by A or B button hold on startup
Step = (EEPROM.read(0)); //when restarted afer auto poweroff, set Step to last step saved to EEPROM
Serial.print("EEPROM address 0 == ");
Serial.println(Step);
}//setup
void loop() {
if (Step == 0) //this forces the clue post to be locked when first powered up
{
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print("Greetings Mr. Blauch");
delay(2000);
lcd.clear();
lcd.setCursor(0, 0); //set cursor to first digit on the first line
/////////("---------20---------")
lcd.print("We have been waiting");
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print("for you for a long, ");
lcd.setCursor(0, 2); //set cursor to first digit on the third line
/////////("---------20---------")
lcd.print(" long time. We hope ");
lcd.setCursor(0, 3); //set cursor to first digit on the fourth line
lcd.print(" you can help us. >");
delay(1000);
for (int i = 0; i < 4; i++) // this for action blinks arrow the same number of times as the center number
{
lcd.setCursor(19, 3); //set cursor last row last space
lcd.print(" ");
delay(500);
lcd.setCursor(19, 3); //set cursor last row last space
lcd.print(">");
delay(500);
}
lcd.clear();
lcd.setCursor(0, 0); //set cursor to first digit on the first line
/////////("---------20---------")
lcd.print("We came from another");
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print("world far from yours");
lcd.setCursor(0, 2); //set cursor to first digit on the third line
/////////("---------20---------")
lcd.print("to learn about your ");
lcd.setCursor(0, 3); //set cursor to first digit on the fourth line
lcd.print(" people and ways. >");
delay(1000);
for (int i = 0; i < 4; i++) // this for action blinks arrow the same number of times as the center number
{
lcd.setCursor(19, 3); //set cursor last row last space
lcd.print(" ");
delay(500);
lcd.setCursor(19, 3); //set cursor last row last space
lcd.print(">");
delay(500);
}
lcd.clear();
lcd.setCursor(0, 0); //set cursor to first digit on the first line
/////////("---------20---------")
lcd.print(" The Aurora damaged ");
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print(" our ship terribly ");
lcd.setCursor(0, 2); //set cursor to first digit on the third line
/////////("---------20---------")
lcd.print(" we were in stasis ");
lcd.setCursor(0, 3); //set cursor to first digit on the fourth line
lcd.print("for over 100 years.>");
delay(1000);
for (int i = 0; i < 4; i++) // this for action blinks arrow the same number of times as the center number
{
lcd.setCursor(19, 3); //set cursor last row last space
lcd.print(" ");
delay(500);
lcd.setCursor(19, 3); //set cursor last row last space
lcd.print(">");
delay(500);
}
lcd.clear();
lcd.setCursor(0, 0); //set cursor to first digit on the first line
/////////("---------20---------")
lcd.print(" We only wish to go ");
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print(" home, but pieces of");
lcd.setCursor(0, 2); //set cursor to first digit on the third line
/////////("---------20---------")
lcd.print("our ship have fallen");
lcd.setCursor(0, 3); //set cursor to first digit on the fourth line
lcd.print(" to Earth. >");
delay(1000);
for (int i = 0; i < 4; i++) // this for action blinks arrow the same number of times as the center number
{
lcd.setCursor(19, 3); //set cursor last row last space
lcd.print(" ");
delay(500);
lcd.setCursor(19, 3); //set cursor last row last space
lcd.print(">");
delay(500);
}
lcd.clear();
lcd.setCursor(0, 0); //set cursor to first digit on the first line
/////////("---------20---------")
lcd.print("They contain signals");
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print("that are our people.");
lcd.setCursor(0, 2); //set cursor to first digit on the third line
/////////("---------20---------")
lcd.print("we must recover them");
lcd.setCursor(0, 3); //set cursor to first digit on the fourth line
lcd.print(" to take them home >");
delay(1000);
for (int i = 0; i < 4; i++) // this for action blinks arrow the same number of times as the center number
{
lcd.setCursor(19, 3); //set cursor last row last space
lcd.print(" ");
delay(500);
lcd.setCursor(19, 3); //set cursor last row last space
lcd.print(">");
delay(500);
}
lcd.clear();
lcd.setCursor(0, 0); //set cursor to first digit on the first line
/////////("---------20---------")
lcd.print(" We helped DeForest ");
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print("build this radio to ");
lcd.setCursor(0, 2); //set cursor to first digit on the third line
/////////("---------20---------")
lcd.print(" transmit them back ");
lcd.setCursor(0, 3); //set cursor to first digit on the fourth line
lcd.print(" to us, but alas >");
delay(1000);
for (int i = 0; i < 4; i++) // this for action blinks arrow the same number of times as the center number
{
lcd.setCursor(19, 3); //set cursor last row last space
lcd.print(" ");
delay(500);
lcd.setCursor(19, 3); //set cursor last row last space
lcd.print(">");
delay(500);
}
lcd.clear();
lcd.setCursor(0, 0); //set cursor to first digit on the first line
/////////("---------20---------")
lcd.print("He was unsuccessful.");
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print("Find and connect our");
lcd.setCursor(0, 2); //set cursor to first digit on the third line
/////////("---------20---------")
lcd.print("people to the radio ");
lcd.setCursor(0, 3); //set cursor to first digit on the fourth line
lcd.print(" and save us all! >");
delay(1000);
for (int i = 0; i < 4; i++) // this for action blinks arrow the same number of times as the center number
{
lcd.setCursor(19, 3); //set cursor last row last space
lcd.print(" ");
delay(500);
lcd.setCursor(19, 3); //set cursor last row last space
lcd.print(">");
delay(500);
}
lcd.clear();
lcd.setCursor(0, 0); //set cursor to first digit on the first line
/////////("---------20---------")
lcd.print(" Our Scanners have ");
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print("little power but can");
lcd.setCursor(0, 2); //set cursor to first digit on the third line
/////////("---------20---------")
lcd.print(" direct you to the ");
lcd.setCursor(0, 3); //set cursor to first digit on the fourth line
lcd.print(" pieces you need >");
delay(1000);
for (int i = 0; i < 4; i++) // this for action blinks arrow the same number of times as the center number
{
lcd.setCursor(19, 3); //set cursor last row last space
lcd.print(" ");
delay(500);
lcd.setCursor(19, 3); //set cursor last row last space
lcd.print(">");
delay(500);
}
lcd.clear();
lcd.setCursor(0, 0); //set cursor to first digit on the first line
/////////("---------20---------")
lcd.print("Leave the radio here");
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print(" or we will lose ");
lcd.setCursor(0, 2); //set cursor to first digit on the third line
/////////("---------20---------")
lcd.print("contact with it and");
lcd.setCursor(0, 3); //set cursor to first digit on the fourth line
lcd.print("be unable to help. >");
delay(1000);
for (int i = 0; i < 4; i++) // this for action blinks arrow the same number of times as the center number
{
lcd.setCursor(19, 3); //set cursor last row last space
lcd.print(" ");
delay(500);
lcd.setCursor(19, 3); //set cursor last row last space
lcd.print(">");
delay(500);
}
theFollowing(); // function call-lcd print" The following is your next clue, prepare to write" blinkArrow();
repeat1: //marker to come back to if the repeat clue 1 option is used
lcd.clear();
// lcd.print("clue 1");
lcd.setCursor(0, 0); //set cursor to first digit on the first line
/////////("---------20---------")
lcd.print("Goto GPS cordinates");//vet memorial
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print(" 40.2774978 "); //alter this to where you want your team to go
lcd.setCursor(0, 2); //set cursor to first digit on the third line
/////////("---------20---------")
lcd.print(" -78.9221961 "); //alter this to where you want your team to go
lcd.setCursor(0, 3); //set cursor to first digit on the fourth line
lcd.print(" on mobile GPS >");
arrowBlink(); //combination blink the arrow and pause so the team has time to write the clue down
arrowBlink(); //second call of the arrow blink to give more time to write the clue down
lcd.clear();
lcd.setCursor(0, 0); //set cursor to first digit on the first line
/////////("---------20---------")
lcd.print(" In the roots of a ");
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print(" tree you will find ");
lcd.setCursor(0, 2); //set cursor to first digit on the third line
/////////("---------20---------")
lcd.print("a cache of documents");
lcd.setCursor(0, 3); //set cursor to first digit on the fourth line
lcd.print(" The first piece >");
arrowBlink(); //combination blink the arrow and pause so the team had time to write the clue down
lcd.clear();
//lcd.print("clue 2");
lcd.setCursor(0, 0); //set cursor to first digit on the first line
/////////("---------20---------")
lcd.print(" will be found on a ");
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print(" large boulder. When");
lcd.setCursor(0, 2); //set cursor to first digit on the third line
/////////("---------20---------")
lcd.print(" You find it, return");
lcd.setCursor(0, 3); //set cursor to first digit on the fourth line
lcd.print("here and install it>");
arrowBlink(); //combination blink the arrow and pause so the team had time to write the clue down
//// add additional clue screens before here if desired
lcd.clear();
lcd.setCursor(0, 0); //set cursor to first digit on the first line
/////////("---------20---------")
lcd.print(" press # to ");
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print(" repeat scan ");
autoOFF(); //start auto off sequence
Step = 1; //index to next step so the previous is not displayed upon next run through loop
Serial.print("Step ");
Serial.println(Step);
}//Step ==0
if (Step == 1)
{
digitalWrite(row4, LOW); //engage row 4 on the keypad to search for # button press
Step = 2; //index to the next step so the previous is not acted on the next loop cycle
Serial.print("Step ");
Serial.println(Step);
}
if (Step == 2 && digitalRead(col3) == LOW) //if the # button is pressed...
{
autoOff = 10; //reset auto off counter to 10 sec
goto repeat1; //if the # button is pressed go back to the start of the clue and do over
Serial.println("auto off reset");
}
if (Step == 2)
{
autoOFF(); //goto autoOFF, index counter, if elapsed, index to next step, save step to EEPROM then turn off pololu switch by turning output12 HIGH
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////where 1st restart begins
if (Step == 3)
{
lcd.clear();
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print(" Insert Piece 1 ");
Step = 4; //advance to the next step so the previous is not acted upon on the next loop cycle
Serial.print("Step ");
Serial.println(Step);
autoOff = 10; //reset auto off back to 10 seconds
}
if (Step == 4 && digitalRead(key1) == LOW)
{
lcd.clear();
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print(" Piece 1 Inserted ");
delay(1500);
Step = 5; //advance to the next step so the previous is not acted upon on the next loop cycle
}//Step==4
if (Step == 4)
{
//lcd.setCursor(0, 1);
if (run_once == 0)
{
lcd.setCursor(0, 1);
/////////("---------20---------")
lcd.print(" Insert Piece 1 ");
run_once = 1;
}
// Overflow display 100 times
// if (run_once <= 100)
// {
// lcd.print("Feed me a stray cat");
// run_once++;
// }
autoOFF();
}
////////////////////////////////////////////////////////////////////////give clue number 2
if (Step == 5)
{
theFollowing(); //" The following is your next clue, prepare to write" blinkArrow();
repeat2: //marker to come back to if repeat clue 2 is option is used
lcd.clear();
//lcd.print("clue 2");
lcd.setCursor(0, 0); //set cursor to first digit on the first line
/////////("---------20---------")
lcd.print("Goto GPS cordinates"); // alter this for where you want your team to go
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print(" 40.3426895 ");
lcd.setCursor(0, 2); //set cursor to first digit on the third line
/////////("---------20---------")
lcd.print(" -78.9340183 ");
lcd.setCursor(0, 3); //set cursor to first digit on the fourth line
lcd.print(" on mobile GPS >");
arrowBlink(); //combination blink the arrow and pause so the team had time to write the clue down
arrowBlink(); //second call of blink arrow for more time
lcd.clear();
//lcd.print("clue 2");
lcd.setCursor(0, 0); //set cursor to first digit on the first line
/////////("---------20---------")
lcd.print(" Find a way inside ");
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print(" To the place where ");
lcd.setCursor(0, 2); //set cursor to first digit on the third line
/////////("---------20---------")
lcd.print(" bronze mouths used ");
lcd.setCursor(0, 3); //set cursor to first digit on the fourth line
lcd.print(" to sing. Search up>");
arrowBlink(); //combination blink the arrow and pause so the team had time to write the clue down
lcd.clear();
//lcd.print("clue 2");
lcd.setCursor(0, 0); //set cursor to first digit on the first line
/////////("---------20---------")
lcd.print("there to find cache ");
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print("of documents and the");
lcd.setCursor(0, 2); //set cursor to first digit on the third line
/////////("---------20---------")
lcd.print("third piece. Return ");
lcd.setCursor(0, 3); //set cursor to first digit on the fourth line
lcd.print("here and install it>");
arrowBlink(); //combination blink the arrow and pause so the team had time to write the clue down
// add any additional clue screens for this clue above here
lcd.clear();
lcd.setCursor(0, 0); //set cursor to first digit on the first line
/////////("---------20---------")
lcd.print(" press # to ");
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print(" repeat scan. ");
autoOFF(); //start auto shutdown sequence
Step = 6; //advance to the next step so the previous is not acted upon on the next loop cycle
Serial.print("Step ");
Serial.println(Step);
}//Step ==5
if (Step == 6)
{
digitalWrite(row4, LOW); //engage row 4 on the keypad to search for # button press
Step = 7; //advance to the next step so the previous is not acted upon on the next loop cycle
Serial.print("Step ");
Serial.println(Step);
}
if (Step == 7 && digitalRead(col3) == LOW)
{
autoOff = 10; //reset auto off counter to 10 sec
goto repeat2; //if the # button is pressed go back to the start of the clue and do over
Serial.println("auto off reset");
}
if (Step == 7)
{
autoOFF(); //goto autoOFF, index counter, if elapsed, index to next step, save step to EEPROM then turn off pololu switch by turning output12 HIGH
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////where 2nd restart begins
if (Step == 8)
{
lcd.clear();
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print(" Insert Piece 2 ");
Step = 9;//advance to the next step so the previous is not acted upon on the next loop cycle
Serial.print("Step ");
Serial.println(Step);
autoOff = 10; //reset auto off counter to 10 sec
}
if (Step == 9 && digitalRead(key2) == LOW)
{
lcd.clear();
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print(" Piece 2 Inserted ");
delay(1500);
Step = 10;//advance to the next step so the previous is not acted upon on the next loop cycle
}
if (Step == 9)
{
//lcd.setCursor(0, 1);
if (run_once == 0)
{
lcd.setCursor(0, 1);
lcd.print(" Insert Piece 2 ");
run_once = 1;
}
// Overflow display 100 times
// if (run_once <= 100)
// {
// lcd.print("Feed me a stray cat");
// run_once++;
// }
autoOFF();
}
//////////////////////////////////////////////////////////////////////////////////////////give clue 3
if (Step == 10)
{
theFollowing(); //" The following is your next clue, prepare to write"
repeat3:
lcd.clear();
//lcd.print("clue 3");
lcd.setCursor(0, 0); //set cursor to first digit on the first line
/////////("---------20---------")
lcd.print("Goto GPS cordinates"); // alter this for where you want your team to go
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print(" 40.1571957 ");
lcd.setCursor(0, 2); //set cursor to first digit on the third line
/////////("---------20---------")
lcd.print(" -78.9827980 ");
lcd.setCursor(0, 3); //set cursor to first digit on the fourth line
lcd.print(" on mobile GPS >");
arrowBlink(); //combination blink the arrow and pause so the team had time to write the clue down
arrowBlink(); //second call of blink arrow for more time
lcd.clear();
//lcd.print("clue 3");
lcd.setCursor(0, 0); //set cursor to first digit on the first line
/////////("---------20---------")
lcd.print(" Seek out the Rat. ");
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print("At its feet you will");
lcd.setCursor(0, 2); //set cursor to first digit on the third line
/////////("---------20---------")
lcd.print("find the documents. ");
lcd.setCursor(0, 3); //set cursor to first digit on the fourth line
lcd.print(" From this vantage >");
arrowBlink(); //combination blink the arrow and pause so the team had time to write the clue down
lcd.clear();
//lcd.print("clue 3");
lcd.setCursor(0, 0); //set cursor to first digit on the first line
/////////("---------20---------")
lcd.print(" You will be able to");
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print(" To see the third ");
lcd.setCursor(0, 2); //set cursor to first digit on the third line
/////////("---------20---------")
lcd.print(" piece. Return here ");
lcd.setCursor(0, 3); //set cursor to first digit on the fourth line
lcd.print(" and install it. >");
arrowBlink(); //combination blink the arrow and pause so the team had time to write the clue down
// add any additional clue screens for this clue above here
lcd.clear();
lcd.setCursor(0, 0); //set cursor to first digit on the first line
/////////("---------20---------")
lcd.print(" press # to ");
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print(" repeat scan. ");
autoOFF();//begin auto shut down sequence
Step = 11;//advance to the next step so the previous is not acted upon on the next loop cycle
Serial.print("Step ");
Serial.println(Step);
}//Step ==10
if (Step == 11)
{
digitalWrite(row4, LOW); //engage row 4 on the keypad to search for # button press
Step = 12;//advance to the next step so the previous is not acted upon on the next loop cycle
Serial.print("Step ");
Serial.println(Step);
}
if (Step == 12 && digitalRead(col3) == LOW)
{
autoOff = 10; //reset auto off counter
goto repeat3; //if the # button is pressed go back to the start of the clue and do over
Serial.println("auto off reset");
}
if (Step == 12)
{
autoOFF(); //goto autoOFF, index counter, if elapsed, index to next step, save step to EEPROM then turn off pololu switch by turning output12 HIGH
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////where 3rd restart begins
if (Step == 13)
{
lcd.clear();
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print(" Insert Piece 3 ");
Step = 14;//advance to the next step so the previous is not acted upon on the next loop cycle
Serial.print("Step ");
Serial.println(Step);
autoOff = 10; //reset auto off counter to 10 sec
}
if (Step == 14 && digitalRead(key3) == LOW)
{
lcd.clear();
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print(" Piece 3 Inserted ");
delay(1500);
Step = 15;//advance to the next step so the previous is not acted upon on the next loop cycle
}
if (Step == 14)
{
//lcd.setCursor(0, 1);
if (run_once == 0)
{
lcd.setCursor(0, 1);
lcd.print(" Insert Piece 3 ");
run_once = 1;
}
// Overflow display 100 times
// if (run_once <= 100)
// {
// lcd.print("Feed me a stray cat");
// run_once++;
// }
autoOFF();
}
//////////////////////////////////////////////////////////////////////////////////////////give clue 4
if (Step == 15)
{
theFollowing(); //" The following is your next clue, prepare to write"
repeat4:
lcd.clear();
//lcd.print("clue 3");
lcd.setCursor(0, 0); //set cursor to first digit on the first line
/////////("---------20---------")
lcd.print("Goto GPS cordinates"); // alter this for where you want your team to go
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print(" 40.2212050 ");
lcd.setCursor(0, 2); //set cursor to first digit on the third line
/////////("---------20---------")
lcd.print(" -78.0293276 ");
lcd.setCursor(0, 3); //set cursor to first digit on the fourth line
lcd.print(" on mobile GPS >");
arrowBlink(); //combination blink the arrow and pause so the team had time to write the clue down
arrowBlink(); //second call of blink arrow for more time
lcd.clear();
//lcd.print("clue 3");
lcd.setCursor(0, 0); //set cursor to first digit on the first line
/////////("---------20---------")
lcd.print(" Enter the Gate and ");
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print(" seek out the three ");
lcd.setCursor(0, 2); //set cursor to first digit on the third line
/////////("---------20---------")
lcd.print(" unknown. Stand ");
lcd.setCursor(0, 3); //set cursor to first digit on the fourth line
lcd.print("among them and seek>");
arrowBlink(); //combination blink the arrow and pause so the team had time to write the clue down
lcd.clear();
//lcd.print("clue 3");
lcd.setCursor(0, 0); //set cursor to first digit on the first line
/////////("---------20---------")
lcd.print(" two sisters. Walk ");
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print("between them to find");
lcd.setCursor(0, 2); //set cursor to first digit on the third line
/////////("---------20---------")
lcd.print(" The last cache and ");
lcd.setCursor(0, 3); //set cursor to first digit on the fourth line
lcd.print("piece in the corner>");
arrowBlink(); //combination blink the arrow and pause so the team had time to write the clue down
lcd.clear();
lcd.setCursor(0, 0); //set cursor to first digit on the first line
/////////("---------20---------")
lcd.print(" press # to ");
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print(" repeat scan ");
autoOFF();
Step = 16;//advance to the next step so the previous is not acted upon on the next loop cycle
Serial.print("Step ");
Serial.println(Step);
}//Step ==15
if (Step == 16)
{
digitalWrite(row4, LOW); //engage row 4 on the keypad to search for # button press
Step = 17;//advance to the next step so the previous is not acted upon on the next loop cycle
Serial.print("Step ");
Serial.println(Step);
}
if (Step == 17 && digitalRead(col3) == LOW)
{
autoOff = 10; //reset auto off counter to 10 sec
goto repeat4; //if the # button is pressed go back to the start of the clue and do over
Serial.println("auto off reset");
}
if (Step == 17)
{
autoOFF(); //goto autoOFF, index counter, if elapsed, index to next step, save step to EEPROM then turn off pololu switch by turning output12 HIGH
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////where 4th restart begins
if (Step == 18)
{
lcd.clear();
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print(" Insert Piece 4 ");
Step = 19;//advance to the next step so the previous is not acted upon on the next loop cycle
Serial.print("Step ");
Serial.println(Step);
autoOff = 10;
}
if (Step == 19 && digitalRead(key4) == LOW)
{
lcd.clear();
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print(" Piece 4 inserted ");
delay(1500);
Step = 20;//advance to the next step so the previous is not acted upon on the next loop cycle
}
if (Step == 19)
{
//lcd.setCursor(0, 1);
if (run_once == 0)
{
lcd.setCursor(0, 1);
lcd.print(" Insert Piece 4 ");
run_once = 1;
}
// Overflow display 100 times
// if (run_once <= 100)
// {
// lcd.print("Feed me a stray cat");
// run_once++;
// }
autoOFF();
}
/////////////////////////////////////////////////////////////////////////////////give final clue
if (Step == 20)
{
theFollowing(); //" The following is your next clue, prepare to write"
repeat5: //marker to come back to if repeat clue 5 option is used
lcd.clear();
//lcd.print("final clue");
lcd.setCursor(0, 0); //set cursor to first digit on the first line
/////////("---------20---------")
lcd.print(" We are so close to ");
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print(" being one with the ");
lcd.setCursor(0, 2); //set cursor to first digit on the third line
/////////("---------20---------")
lcd.print("rest of our brethren");
lcd.setCursor(0, 3); //set cursor to first digit on the fourth line
lcd.print("after so long. They>");
arrowBlink(); //combination blink the arrow and pause so the team has time to write the clue down
lcd.clear();
lcd.setCursor(0, 0); //set cursor to first digit on the first line
/////////("---------20---------")
lcd.print(" Reside within the ");
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print(" radio. Please enter");
lcd.setCursor(0, 2); //set cursor to first digit on the third line
/////////("---------20---------")
lcd.print(" the transmit code ");
lcd.setCursor(0, 3); //set cursor to first digit on the fourth line
lcd.print(" to send them back >");
arrowBlink(); //combination blink the arrow and pause so the team has time to write the clue down
lcd.clear();
lcd.setCursor(0, 0); //set cursor to first digit on the first line
/////////("---------20---------")
lcd.print(" To us so we may ");
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print(" return home. We do ");
lcd.setCursor(0, 2); //set cursor to first digit on the third line
/////////("---------20---------")
lcd.print(" not know what the ");
lcd.setCursor(0, 3); //set cursor to first digit on the fourth line
lcd.print(" code is. DeForest >");
arrowBlink(); //combination blink the arrow and pause so the team has time to write the clue down
lcd.clear();
lcd.setCursor(0, 0); //set cursor to first digit on the first line
/////////("---------20---------")
lcd.print(" did but he is long ");
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print(" gone. Perhaps there");
lcd.setCursor(0, 2); //set cursor to first digit on the third line
/////////("---------20---------")
lcd.print(" is an answer among ");
lcd.setCursor(0, 3); //set cursor to first digit on the fourth line
lcd.print(" the documents? >");
arrowBlink(); //combination blink the arrow and pause so the team has time to write the clue down
lcd.clear();
lcd.setCursor(0, 0); //set cursor to first digit on the first line
/////////("---------20---------")
lcd.print("We thank you for the");
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print("help and have a gift");
lcd.setCursor(0, 2); //set cursor to first digit on the third line
/////////("---------20---------")
lcd.print("if you send us home");
lcd.setCursor(0, 3); //set cursor to first digit on the fourth line
lcd.print(" >");
arrowBlink(); //combination blink the arrow and pause so the team has time to write the clue down
lcd.clear();
lcd.setCursor(0, 0); //set cursor to first digit on the first line
/////////("---------20---------")
lcd.print(" press # to ");
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print(" repeat message ");
autoOFF(); // begin the auto shutdown sequence
Step = 21;//advance to the next step so the previous is not acted upon on the next loop cycle
Serial.print("Step ");
Serial.println(Step);
}//Step ==20
if (Step == 21)
{
digitalWrite(row4, LOW); //engage row 4 on the keypad to search for # button press
Step = 22;//advance to the next step so the previous is not acted upon on the next loop cycle
Serial.print("Step ");
Serial.println(Step);
}
if (Step == 22 && digitalRead(col3) == LOW)
{
autoOff = 10; //reset auto off counter to 10 sec
goto repeat5; //if the # button is pressed go back to the start of the clue and do over
Serial.println("auto off reset");
}
if (Step == 22)
{
autoOFF(); //goto autoOFF, index counter, if elapsed, index to next step, save step to EEPROM then turn off pololu switch by turning output12 HIGH
///////////////////////////////////////////////////////////////////////////////////////////restart after final clue
}
if (Step == 23)
{
lcd.clear();
lcd.setCursor(0, 0);//set cursor to first digit on the First line
/////////("---------20---------");
lcd.print(" Enter Transmission ");
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print(" Code ");
Step = 24;//advance to the next step so the previous is not acted upon on the next loop cycle
Serial.print("Step== ");
Serial.print(Step);
autoOff = 5; // reset auto off counter to 10 seconds
}
if (Step == 24)//scan keypad for number entries then goto action() for what to do with it.
{
if (run_once == 0)
{
lcd.setCursor(0, 0);
lcd.print(" Enter Transmission ");
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print(" Code ");
autoOff = 5;
run_once = 1;
}
Serial.print("Step== ");
Serial.print(Step);
keyScan();//goto keyscan and look for 4 button presses then continue
//step indexed to 25 inside the keyscan function
}
if (Step == 25)/////compare code entered vs open code
{
if (code != openCode)//if the code entered is not the same as opencode...
{
lcd.clear();
lcd.setCursor(0, 0);//set cursor to first digit on the first line
/////////("---------20---------")
lcd.print(" Incorrect code ");
lcd.setCursor(0, 1);
/////////("---------20---------")
lcd.print(" examine the signal ");
lcd.setCursor(0, 2);
/////////("---------20---------")
lcd.print(" and try again. ");
delay(2500);
code = 0; digit = 0; //clear the entered code and reset the digit entry to first digit for another try
Step = 23;//advance to the next step so the previous is not acted upon on the next loop cycle
}
if (code == openCode)//if the code entered is the same as opencode...
{
lcd.clear();
lcd.setCursor(0, 0);//set cursor to first digit on the first line
/////////("---------20---------")
lcd.print("Code accepted, begin");
lcd.setCursor(0, 1);
/////////("---------20---------")
lcd.print(" Transmission! ");
digitalWrite(ledG, HIGH);
delay(2500);
//lcd.clear();
//lcd.setCursor(0, 0);//set cursor to first digit on the first line
/////////("---------20---------")
//lcd.print(" After you have ");
//lcd.setCursor(0, 1);
/////////("---------20---------")
//lcd.print(" gotten your prize ");
//lcd.setCursor(0, 2);
/////////("---------20---------")
//lcd.print("close the lid and it");
//lcd.setCursor(0, 3);
/////////("---------20---------")
//lcd.print(" will relock ");
arrowBlink(); //combination blink the arrow and pause so the team has time to read
lcd.clear();
lcd.setCursor(0, 1);//set cursor to first digit on the second line
/////////("---------20---------")
lcd.print(" Transmitting");
lcd.print(". ");
delay(500);
lcd.print(". ");
delay(500);
lcd.print(". ");
delay(500);
lcd.print(". ");
delay(500);
servoLock.writeMicroseconds(servoOpen);//adjust this number to set the servo to open the lock
//Disable re-locking
//delay(2000); //adjust for time needed for servo to unlock and door to start opening to release door before reclosing
//servoLock.writeMicroseconds(servoClosed);//adjust this number to set the servo to close the lock
Step = 26;//advance to the next step so the previous is not acted upon on the next loop cycle
}//code==opencode
}//Step==25
if (Step == 26)
{
lcd.clear();
lcd.setCursor(0, 1);//set cursor to first digit on the second line
lcd.print("Thank you, Goodbye!");
Step = 27;//advance to the next step so the previous is not acted upon on the next loop cycle
}
while (Step == 27)
{
//end of treausre hunt, lock system here until power reset and reset of EEPROM by hold down of A button to reset and run or B button to reset and shutdown
autoOFF(); //goto autoOFF, index counter, if elapsed, index to next step, save step to EEPROM then turn off pololu switch by turning output12 HIGH
}
}//loop
void keyScan() //arrive here from loop to scan keypad for button presses
{
Serial.println("keyScan");
Serial.print("code =");
Serial.print(code);
//scan keypad for button press
Serial.print("row 1");
digitalWrite(row1, LOW); //scan row 1 for button press
digitalWrite(row2, HIGH);
digitalWrite(row3, HIGH);
digitalWrite(row4, HIGH);
if (digitalRead(col1) == LOW) //if the 1 button is pressed
{
delay(15); //wait
if (digitalRead(col1) == LOW) //check again to see that the button is still pressed
{
while (digitalRead(col1) == LOW) //wait here until the button is released
{
//do nothing
}
button = 1;
Serial.print("button==");
Serial.println(button);
action(); //goto action to see what to do with button press
}
}
if (digitalRead(col2) == LOW) //if the 2 button is pressed
{
delay(15);
if (digitalRead(col2) == LOW)
{
while (digitalRead(col2) == LOW)
{
//do nothing
}
button = 2;
Serial.print("button==");
Serial.println(button);
action(); //goto action to see what to do with button press
}
}
if (digitalRead(col3) == LOW) //if the 3 button is pressed
{
delay(15);
if (digitalRead(col3) == LOW)
{
while (digitalRead(col3) == LOW)
{
//do nothing
}
button = 3;
Serial.print("button==");
Serial.println(button);
action(); //goto action to see what to do with button press
}
}
if (digitalRead(col4) == LOW) //if the A button is pressed
{
delay(15);
if (digitalRead(col4) == LOW)
{
while (digitalRead(col4) == LOW)
{
//do nothing
}
button = 13;
Serial.print("button==");
Serial.println(button);
action(); //goto action to see what to do with button press
}
}
Serial.print("row 2");
digitalWrite(row1, HIGH); //scan row 2 for button press
digitalWrite(row2, LOW);
digitalWrite(row3, HIGH);
digitalWrite(row4, HIGH);
if (digitalRead(col1) == LOW) //if the 4 button is pressed
{
delay(15);
if (digitalRead(col1) == LOW)
{
while (digitalRead(col1) == LOW)
{
//do nothing
}
button = 4;
Serial.print("button==");
Serial.println(button);
action(); //goto action to see what to do with button press
}
}
if (digitalRead(col2) == LOW) //if the 5 button is pressed
{
delay(15);
if (digitalRead(col2) == LOW)
{
while (digitalRead(col2) == LOW)
{
//do nothing
}
button = 5;
Serial.print("button==");
Serial.println(button);
action(); //goto action to see what to do with button press
}
}
if (digitalRead(col3) == LOW) //if the 6 button is pressed
{
delay(15);
if (digitalRead(col3) == LOW)
{
while (digitalRead(col3) == LOW)
{
//do nothing
}
button = 6;
Serial.print("button==");
Serial.println(button);
action(); //goto action to see what to do with button press
}
}
if (digitalRead(col4) == LOW) //if the B button is pressed
{
delay(15);
if (digitalRead(col4) == LOW)
{
while (digitalRead(col4) == LOW)
{
//do nothing
}
button = 14;
Serial.print("button==");
Serial.println(button);
action(); //goto action to see what to do with button press
}
}
Serial.print("row 3");
digitalWrite(row1, HIGH); //scan row 3 for button press
digitalWrite(row2, HIGH);
digitalWrite(row3, LOW);
digitalWrite(row4, HIGH);
if (digitalRead(col1) == LOW) //if the 7 button is pressed
{
delay(15);
if (digitalRead(col1) == LOW)
{
while (digitalRead(col1) == LOW)
{
//do nothing
}
button = 7;
Serial.print("button==");
Serial.println(button);
action(); //goto action to see what to do with button press
}
}
if (digitalRead(col2) == LOW) //if the 8 button is pressed
{
delay(15);
if (digitalRead(col2) == LOW)
{
while (digitalRead(col2) == LOW)
{
//do nothing
}
button = 8;
Serial.print("button==");
Serial.println(button);
action(); //goto action to see what to do with button press
}
}
if (digitalRead(col3) == LOW) //if the 9 button is pressed
{
delay(15);
if (digitalRead(col3) == LOW)
{
while (digitalRead(col3) == LOW)
{
//do nothing
}
button = 9;
Serial.print("button==");
Serial.println(button);
action(); //goto action to see what to do with button press
}
}
if (digitalRead(col4) == LOW) //if the C button is pressed
{
delay(15);
if (digitalRead(col4) == LOW)
{
while (digitalRead(col4) == LOW)
{
//do nothing
}
button = 15;
Serial.print("button==");
Serial.println(button);
action(); //goto action to see what to do with button press
}
}
Serial.print("row 4");
digitalWrite(row1, HIGH); //scan row 4 for button press
digitalWrite(row2, HIGH);
digitalWrite(row3, HIGH);
digitalWrite(row4, LOW);
if (digitalRead(col1) == LOW) //if the * button is pressed
{
delay(15);
if (digitalRead(col1) == LOW)
{
while (digitalRead(col1) == LOW)
{
//do nothing
}
button = 11;
Serial.print("button==");
Serial.println(button);
action(); //goto action to see what to do with button press
}
}
if (digitalRead(col2) == LOW) //if the 0 button is pressed
{
delay(15);
if (digitalRead(col2) == LOW)
{
while (digitalRead(col2) == LOW)
{
//do nothing
}
button = 10;
Serial.print("button==");
Serial.println(button);
action(); //goto action to see what to do with button press
}
}
if (digitalRead(col3) == LOW) //if the # button is pressed
{
delay(15);
if (digitalRead(col3) == LOW)
{
while (digitalRead(col3) == LOW)
{
//do nothing
}
button = 12;
Serial.print("button==");
Serial.println(button);
action(); //goto action to see what to do with button press
}
}
if (digitalRead(col4) == LOW) //if the D button is pressed
{
delay(15);
if (digitalRead(col4) == LOW)
{
while (digitalRead(col4) == LOW)
{
//do nothing
}
button = 16;
Serial.print("button==");
Serial.println(button);
action(); //goto action to see what to do with button press
}
}
Serial.print("end");
autoOFF();
}//keyScan
void action() //come here from keyScan after a button press has been recorded
{
Serial.print("action()");
digitalWrite(ledR, HIGH); //flash the red light every time a button is pressed as confirmation of press
delay(15);
digitalWrite(ledR, LOW);
autoOff = 10; //reset auto shut off counter each time a button is pressed
Serial.println(button);
//digit determins which of the four digits of the code are being entered to, button is recorded above and if it is between 1&9...
if (digit == 0 && button >= 1 && button <= 9) //1-9 pressed
{
code = button * 1000; //button x 1000 equals the thousands place of the code or first digit of 4 digit code
digit = 1; //move the digit to the next place
button = 0; //clear the button press
Serial.print("code" );
Serial.println(code);
Serial.print("digit ");
Serial.println(digit);
return; //exit back to keyScan
}
if (digit == 0 && button == 10) //zero button pressed
{
digit = 1;
button = 0;
//nothing is added to code but digit is indexed +1
Serial.print("code" );
Serial.println(code);
Serial.print("digit ");
Serial.println(digit);
return; //exit back to keyScan
}
if (digit == 1 && button >= 1 && button <= 9) //1-9 pressed
{
code = code + button * 100;
digit = 2;
button = 0;
Serial.print("code" );
Serial.println(code);
Serial.print("digit ");
Serial.println(digit);
return; //exit back to keyScan
}
if (digit == 1 && button == 10) //zero button pressed
{
digit = 2;
button = 0;
//nothing is added to code but digit is indexed +1
Serial.print("code" );
Serial.println(code);
Serial.print("digit ");
Serial.println(digit);
return; //exit back to keyScan
}
if (digit == 2 && button >= 1 && button <= 9) //1-9 button pressed
{
code = code + button * 10;
digit = 3;
button = 0;
Serial.print("code" );
Serial.println(code);
Serial.print("digit ");
Serial.println(digit);
return; //exit back to keyScan
}
if (digit == 2 && button == 10) //zero button pressed
{
digit = 3;
button = 0;
//nothing is added to code but digit is indexed +1
Serial.print("code" );
Serial.println(code);
Serial.print("digit ");
Serial.println(digit);
return; //exit back to keyScan
}
if (digit == 3 && button >= 1 && button <= 9) // 1-9 button pressed
{
code = code + button;
button = 0;
digit = 4;
Serial.print("code" );
Serial.println(code);
Serial.print("digit ");
Serial.println(digit);
}
if (digit == 3 && button == 10) //zero button pressed
{
digit = 4;
button = 0;
//nothing is added to code but digit is indexed +1
Serial.print("code" );
Serial.println(code);
Serial.print("digit ");
Serial.println(digit);
}
if (digit == 4) //after the last digit is entered, index to next step to compare entered code with fixed codes
{
if (Step == 4) {
Step = 5;
}
if (Step == 24) {
Step = 25;
}
//if (Step ==4){Step=5;}
//if (Step ==4){Step=5;}
}
//if any other button is pressed which brings you to action() but is not used for the code
button = 0;
}//action
void autoOFF() // arrive here from loop when Arduino counting down to auto shut down
{
//autoOffCount is index up +1 every time loop passes
//autoOff is subtracted from -1 everytime autoOffCount counts up to 250. add or subract from this number below to make the timer count dowm at about 1 per second
if (autoOffCount == 0)//if timer has elapsed then acitvate shut down sequence
{
lcd.setCursor(0, 3);//set cursor to first digit on the forth line
lcd.print("AutoOff in ");
lcd.print(autoOff);
lcd.print(" ");//aditional space after auto off is printed to erase last digit when changing from three digit number to two digit number
Serial.println("");
Serial.print("AutoOff ");
Serial.println(autoOff);
}
autoOffCount++; //index autoOffCount up 1 every time loop passes by
Serial.println(autoOffCount);
if (autoOffCount >= 250) // this is 250 runs through the loop per 1 number count down. Adjust this number up or down to make countdown move at one per second
{
autoOffCount = 0;
autoOff = autoOff - 1;
}
if (autoOff <= 0) //if timer has elapsed then turn off
{
// the following is where the step is indexed up one just before the shutdown
if (Step == 2) {
Step = 3;
} Serial.print("step==3");
if (Step == 7) {
Step = 8;
} Serial.print("step==8");
if (Step == 12) {
Step = 13;
} Serial.print("step==13");
if (Step == 17) {
Step = 18;
} Serial.print("step==18");
if (Step == 22) {
Step = 23;
} Serial.print("step==23");
EEPROM.write(0, Step); // write the current step to the EEPROM's address #0
lcd.clear();
lcd.setCursor(0, 1);//set cursor to first digit on the second line
/////////("---------20---------")
lcd.print(" Shutting Down");
delay(500);
lcd.print(".");
delay(500);
lcd.print(".");
delay(500);
lcd.print(".");
delay(500);
digitalWrite(Off, HIGH);//set pin #12 high to turn off pololu switch
while (autoOff <= 0)
{
//you are stuck here until the power is cycled, you should never get here but if the pololu switch fails you will be trapped here
}
}//if (autoOff <= 0)
}//autoOFF
void arrowBlink() //arrive here from loop, blinks arrow at lower right side of LCD screen when more is to be printed after a pause
{
for (int i = 0; i < 7; i++) //adjust center number for amount of times you want arrow to flash on and off
{
lcd.setCursor(19, 3); //set cursor last row last space
lcd.print(" ");//turn arrow off
delay(500);
lcd.setCursor(19, 3); //set cursor last row last space
lcd.print(">");//turn arrow on
delay(500);
//go back and do it again until i = the middle number
}
}//arrowBlink
void theFollowing()//"the following is your next clue. Prepare to write" then bottom line of stars count backward from 10
{
lcd.clear();
lcd.setCursor(0, 0); //set cursor to first digit on the first line
/////////("---------20---------")
lcd.print("Scanner Initializing");
lcd.setCursor(0, 1); //set cursor to first digit on the second line
/////////("---------20---------")
lcd.print("Scanning for pieces");
lcd.setCursor(0, 2); //set cursor to first digit on the third line
/////////("---------20---------")
lcd.print(" Prepare to write ");
lcd.setCursor(0, 3); //set cursor to first digit on the third line
/////////("---------20---------")
lcd.print("* * * * * * * * * * ");
delay(1000);
lcd.setCursor(0, 3); //set cursor to first digit on the third line
/////////("---------20---------")
lcd.print("* * * * * * * * * ");
delay(1000);
lcd.setCursor(0, 3); //set cursor to first digit on the third line
/////////("---------20---------")
lcd.print("* * * * * * * * ");
delay(1000);
lcd.setCursor(0, 3); //set cursor to first digit on the third line
/////////("---------20---------")
lcd.print("* * * * * * * ");
delay(1000);
lcd.setCursor(0, 3); //set cursor to first digit on the third line
/////////("---------20---------")
lcd.print("* * * * * * ");
delay(1000);
lcd.setCursor(0, 3); //set cursor to first digit on the third line
/////////("---------20---------")
lcd.print("* * * * * ");
delay(1000);
lcd.setCursor(0, 3); //set cursor to first digit on the third line
/////////("---------20---------")
lcd.print("* * * * ");
delay(1000);
lcd.setCursor(0, 3); //set cursor to first digit on the third line
/////////("---------20---------")
lcd.print("* * * ");
delay(1000);
lcd.setCursor(0, 3); //set cursor to first digit on the third line
/////////("---------20---------")
lcd.print("* * ");
delay(1000);
lcd.setCursor(0, 3); //set cursor to first digit on the third line
/////////("---------20---------")
lcd.print("* ");
delay(1000);
lcd.setCursor(0, 3); //set cursor to first digit on the third line
/////////("---------20---------")
lcd.print(" ");
delay(1000);
//go back to loop
}