The buttons that will grade up all

this project is a bit different from the regular p5js jargon. its Arduino and c++, the goal is to make a grading system for the lesson. students walk past the machine and press a button representing how they feel about the lesson. the Arduino then takes all the inputs and uses it to create a mean lesson grade. that way you can see how the students perceive the lessons.

// constants won't change. They're used here to set pin numbers:

const int LED1 = 2;     // GREEN the number of the pushbutton pin
const int LED2 = 4;     //ORANGE
const int LED3 = 7;     //RED
const int BUTTON1 =  9;      // the number of the LED pin
const int BUTTON2 =  12;
const int BUTTON3 =  13;

int val1 = 0; // variable for reading the pushbutton status
int old_val1 = 0;
int state1 = 0;
int val2 = 0; // variable for reading the pushbutton status
int old_val2 = 0;
int state2 = 0;
int val3 = 0; // variable for reading the pushbutton status
int old_val3 = 0;
int state3 = 0;
int c = 1;
int n = 1;
int lessonscore = (c/n);

//lesson score is score/number of students-> makes the average of student scores 

void setup() {
  pinMode(LED1, OUTPUT);   // initialize the LED pin as an output:
  pinMode(LED2, OUTPUT);
  pinMode(LED3, OUTPUT);
  pinMode(BUTTON1, INPUT); // initialize the pushbutton pin as an input:
  pinMode(BUTTON2, INPUT);
  pinMode(BUTTON3, INPUT);
}

void loop() {

  // read the state of the pushbutton value:
  val1 = digitalRead(BUTTON1);
  val2 = digitalRead(BUTTON2);
  val3 = digitalRead(BUTTON3);


//switches the lights on when button pressed till pressed again
  if (( val1 == LOW ) && ( old_val1 == HIGH)) {
    delay(10);
  }
  if ((val1 == HIGH ) && (old_val1 == LOW)) {
    state1 = 1 - state1;
    delay(10);
  }
  old_val1 = val1;

  if (( val2 == LOW ) && ( old_val2 == HIGH)) {
    delay(10);
  }
  if ((val2 == HIGH ) && (old_val2 == LOW)) {
    state2 = 1 - state2;
    delay(10);
  }
  old_val2 = val2;

  if (( val3 == LOW ) && ( old_val3 == HIGH)) {
    delay(10);
  }
  if ((val3 == HIGH ) && (old_val3 == LOW)) {
    state3 = 1 - state3;
    delay(10);
  }
  old_val3 = val3;

//if button 1 is pressed add three to the lesson counter (1 is good)
//if button 1 is pressed add one to the student counter 
  if (state1 == 1) {
    c=+3;
    n++;
    digitalWrite(LED1, LOW);
    delay(100);
    digitalWrite(LED1, HIGH);
    state1 = 0;
    }
    
//if button 2 is pressed nothing is added to the lesson counter (2 is mehh)
//if button 2 is pressed add one to the student counter
    if (state2 == 1) {
    n++;
    digitalWrite(LED2, LOW);
    delay(100);
    digitalWrite(LED2, HIGH);
    state2 = 0;
    }
   //if button 3 is pressed subtract three from the lesson counter (2 is BAD)
//if button 1 is pressed add one to the student counter
    if (state3 == 1) {
    c=-3;
    n++;
    digitalWrite(LED3, LOW);
    delay(60);
    digitalWrite(LED3, HIGH);
    state3 = 0;
    }
    
}