need help with programming errors

I've been writing and debugging this for over 6 hours today alone and my head hurts. I'm no longer efficient and I can't think straight but I really want to get this done. My project could be viewed as dumb by some, but for the most part it's irrelevant. I'm making a band that goes around your wrist and shocks you if you don't wake up normally from your alarm. It's supposed to keep shocking you every 3 minutes and increasing the shock time every time untill you plug it into a hub located on the other side of the room.

I want this thing to be small so i was programming it on a ATtiny85 but it's annoying to debug on it since i can't test it until its plugged in and i don't have the circuit board 100% done yet. So i got to a point finally where I wasn't getting any errors at all. Then i decided it would be easier to debug on an uno, so i simply tried uploading the SAME code to that and i got like 20 errors somehow. So i debugged a lot and the program still doesn't work and i feel like im starting from scratch so i'm annoyed and need a break.

obviously i won't ask anyone to debug my entire code for me since there are so many problems and I already wasted a bunch your time reading this but if someone could help me fix at least one or two, or give me any other helpful tips that would be great. Absolutely any help, or criticism at all would be greatly appreciated. And yah ik a delay was the wrong way to go for waiting 3 minutes but it didn't need to be accurate and It already had so many problems that that was the least of my worries.

int relay = 2;
int buttonPin = 3;
boolean relaystat = LOW;

int buttonOff = 2;


const int hour = 13600;
const int tenminutes = 600;
int timeneeded = 0;
boolean hourchange = HIGH;
boolean minutechange = LOW;
boolean timeron = LOW;
boolean disablebuttons = LOW;

int shockIncrease = 250;

// Button variables
int buttonVal = 0; // value read from button
int buttonLast = 0; // buffered value of the button's previous state
long btnDnTime; // time the button was pressed down
long btnUpTime; // time the button was released
boolean ignoreUp = false; // whether to ignore the button release because the click+hold was triggered

#define debounce 20 
#define holdTime 2000 


void setup() {
pinMode(relay, OUTPUT);
pinMode(buttonPin, INPUT);
pinMode(buttonOff, INPUT);
digitalWrite(buttonOff, LOW);
digitalWrite(buttonPin, HIGH);
digitalWrite(relay, LOW);


cli();//stop interrupts
//set timer1 interrupt at 1kHz
TCCR1A = 0;// set entire TCCR1A register to 0
TCCR1B = 0;// same for TCCR1B
TCNT1  = 0;//initialize counter value to 0
// set timer count for 1khz increments
OCR1A = 1999;// = (16*10^6) / (1000*8) - 1
//had to use 16 bit timer1 for this bc 1999>255, but could switch to timers 0 or 2 with larger prescaler
// turn on CTC mode
TCCR1B |= (1 << WGM12);
// Set CS11 bit for 8 prescaler
TCCR1B |= (1 << CS11);  
// enable timer compare interrupt
TIMSK1 |= (1 << OCIE1A);
sei();//allow interrupts
}

void loop() {
  


  // Read the state of the button
buttonVal = digitalRead(buttonPin);

// Test for button pressed and store the down time
if (buttonVal == LOW && buttonLast == HIGH && (millis() - btnUpTime) > long(debounce))
{
btnDnTime = millis();
}

// Test for button release and store the up time
if (buttonVal == HIGH && buttonLast == LOW && (millis() - btnDnTime) > long(debounce))
{
if (ignoreUp == false) event1();
else ignoreUp = false;
btnUpTime = millis();
}

// Test for button held down for longer than the hold time
if (buttonVal == LOW && (millis() - btnDnTime) > long(holdTime))
{
event2();
ignoreUp = true;
btnDnTime = millis();
}

buttonLast = buttonVal;

//---------------------------------------------



  if (timeneeded == 0) && (timeron == HIGH)
  {
 while (digitalRead(buttonOff) == LOW) //if its not connected to the hub, it will shock me every 3 minutes until it is connected
 {
  delay(180000);
  digitalWrite(relay, HIGH);
  delay(shockIncrease);
  digitalWrite(relay, LOW);
  shockIncrease = shockIncrease + 300; //it will increase the amount of time it shocks me for every time i ignore it.
 }
  }
 
 if (digitalRead(buttonOff) == HIGH) //if connected to the hub it will turn off everything
 {
  digitalWrite(relay, LOW);
  disablebuttons = LOW;
  hourchange = HIGH;
  minutechange = LOW;
  timeron == LOW;
 }

  }

 
   

} 
// not sure if a "}" should go here



//------------
ISR(TIMER1_COMPA_vect){
 if ((timeron == HIGH) && (timeneeded > 0)) //when the timer is turned on and the timers not already done, it will count backwards from the time that was added in event 1
  {
   timeneeded = timeneeded - 1;
        }
   }

void event1() //if the button is clicked
{
  if ((hourchange == HIGH) && (disablebuttons == LOW))
  {
  timeneeded = timeneeded + hour; //an hour is added to the timer that didnt start yet
  }
  else if ((minutechange = HIGH) && (disablebuttons == LOW))
  {
  timeneeded = timeneeded + tenminutes; //10 minutes is added to the timer to the timer that didnt start yet
  }
}

void event2() //if the button is held
{
 if (minutechange == LOW) 
 {
 minutechange = HIGH;  //sets the program to start changing the minutes if the minutes havent already been chosen
 }
 else if (minutechange == HIGH)
 {
  timeron = HIGH; // turns the timer on if both the hours and minutes have been chosen
  disablebuttons = HIGH;
 }
}

Here are the errors

Arduino: 1.8.3 (Windows Store 1.8.6.0) (Windows 10), Board: "Arduino/Genuino Uno"

C:\Users\Neil\AppData\Local\Temp\arduino_modified_sketch_318260\sketch_jul20d.ino: In function 'void loop()':

sketch_jul20d:71: error: 'event1' was not declared in this scope

 if (ignoreUp == false)event1();

                              ^

sketch_jul20d:79: error: 'event2' was not declared in this scope

 event2();

        ^

sketch_jul20d:90: error: expected identifier before '(' token

   if (timeneeded == 0) && (timeron == HIGH)

                           ^

C:\Users\Neil\AppData\Local\Temp\arduino_modified_sketch_318260\sketch_jul20d.ino: At global scope:

sketch_jul20d:116: error: expected declaration before '}' token

 } 

 ^

exit status 1
'event1' was not declared in this scope

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Check to see if you have non-printable characters anywhere.

.

Get rid of the " } " on line 116 and try it, the great value of "Auto Format" ( [CTRL + T] ) :wink:

larryd:
Check to see if you have non-printable characters anywhere.

.

edgemoron:
Get rid of the " } " on line 116 and try it, the great value of "Auto Format" ( [CTRL + T] ) :wink:

Thanks :slight_smile: