Error /302 , /240

My teacher emailed me this code but when I paste it into the program it gives me the errors, here is the code

//Repeat after me starter file

int led1 = 7; // LED 1
int led2 = 9;
int btn1 = 6;
int btn2 = 5;
int buzzer = 12;
int curBtn = 0;
int bThresh = 100;
int bVal1, bVal2;
int lastBtn = millis();
int step = 1;
int i = 1;
int k = 1;
int mode = 0;
const int maxStep = 5;
int pat[maxStep + 1];

void setup() {

pinMode(led1, OUTPUT);
pinMode(led1, OUTPUT);
pinMode(btn1, INPUT);
pinMode(btn2, INPUT);
pinMode(buzzer, OUTPUT);
Serial.begin(9600);
randomSeed(analogRead(0));
for (int p = 1; p <= maxStep; p++) {
pat[p] = random(1, 3);
Serial.println(pat[p]);
}

}
// the loop function runs over and over again forever
void loop() {

switch (mode) {
case 0: // DISPLAY LIGHT PATTERN

if (i <= step) {

switch (pat*) {*

  • case 1:*
  • light1();*
  • break;*
  • case 2:*
  • light2();*
  • break;*
  • }*
  • i++;*
  • } else {*
  • mode = 1;*
  • k = 1;*
  • }*
  • break;*
  • case 1:// READ BUTTONS*
  • if (k <= step) {*
  • bVal1 = digitalRead(btn1);*
  • bVal2 = digitalRead(btn2);*
  • if ((bVal1 == HIGH) || (bVal2 == HIGH)) {*
  • if ((millis() - lastBtn) > bThresh) {*
  • if (bVal1 == HIGH) {*
  • light1();*
  • curBtn = 1;*
  • }*
  • if (bVal2 == HIGH) {*
  • light2();*
  • curBtn = 2;*
  • }*
  • lastBtn = millis();*
  • }*
  • if (curBtn == pat[k]) { //correct button pressed*
  • Serial.println("match");*
  • k++;*
  • }*
  • else {*
  • Serial.println("you blew it!!!");*
  • loser();*
  • step = 1;*
  • mode = 0;*
  • i = 1;*
  • // generate a new random sequence for a new game*
  • }*
  • }*
  • }*
  • else {*
  • winner();*
  • Serial.println("NEW ROUND!");*
  • step ++;*
  • mode = 0;*
  • i = 1;*
  • }//*
  • break;*
  • }*
  • delay(50);*
    }
    void light1() {
  • tone(buzzer, 261);*
  • digitalWrite(led1, HIGH);*
  • delay(500);*
  • digitalWrite(led1, LOW);*
  • delay(500);*
  • noTone(buzzer);*
    }
    void light2() {
  • tone(buzzer, 523);*
  • digitalWrite(led2, HIGH);*
  • delay(500);*
  • digitalWrite(led2, LOW);*
  • delay(500);*
  • noTone(buzzer);*
    }
    void loser() {
  • // you make a loser sound and light sequence*
  • Serial.println("LOSER!");*
    }
    void winner() {
  • // you make a winner sound and light sequence*
  • Serial.println("WINNER!");*
    }

Use code tags please... your code is in italic after a while... weird isn't it? (thats why you need code tags) ==> there is a post at the top of the forum called 'Read this before posting a programming question ..' did you read it?

You probably have stray characters from your copy paste. Can you post the exact compiler message ? That will tell you way more than you are sharing here

For those playing at home, this is the only error I get when trying to compile it:

C:\Arduino-1.6.9\Sketchbook\sketch_jun16b\sketch_jun16b.ino: In function 'void loop()':

sketch_jun16b:45: error: switch quantity not an integer

         switch (pat) {

                    ^

exit status 1
switch quantity not an integer

You say your teacher wrote this? There are some glaring mistakes in there (in addition to the one causing this error)

That's because of the @&*#!! Missing code Tags in the original post....

see the italic exactly after that switch? That's because in the original code it was written switch (pat[i]) { but the [i] got interpreted as get the text in italic by the forum parser which would not happen if the code was posted properly

The reason you don't see the other errors is that by posting here in the forum the stray character got discarded and so copying back from here works

Agree the code is clearly not best practice, but hey not all teachers are software engineers...(better fix the double pinMode(led1, OUTPUT); at the start of setup() one of them ought to be for led2 as Arduino (Atmega) pins default to inputs and make lastBtn an unsigned long for this to work more than 32 seconds somewhat reliably...)