Code from started kit book not working

The code is

int buttons[3];
buttons[0] = 2;
int notes [] = {262,294,330,349};

void setup() {
  Serial.begin(9600);
  }

void loop() {
  int keyVal = analougRead(A0);
  Serial.println(keyVal);

  if (keyVal == 1023) {
    tone(8, notes[0]);
  }
  else if(keyVal >= 990 && keyVal <= 1010) {
    tone(8, notes[1]);
  }
  else if(keyVal >= 505 && keyVal <= 515) { 
    tone(8, notes[2]);
  }
  else if(keyVal >= 5 && keyVal <= 15) { 
    tone(8, notes[3]);
  }
  else {
    noTone(8);
  }
  
}

and the error is

sketch_jul07a:2:1: error: 'buttons' does not name a type
buttons[0] = 2;
^~~~~~~
C:\Users\Armaan\OneDrive\Documents\Arduino\sketch_jul07a\sketch_jul07a.ino: In function 'void loop()':
sketch_jul07a:12:16: error: 'analougRead' was not declared in this scope
int keyVal = analougRead(A0);
^~~~~~~~~~~
C:\Users\Armaan\OneDrive\Documents\Arduino\sketch_jul07a\sketch_jul07a.ino:12:16: note: suggested alternative: 'analogRead'
int keyVal = analougRead(A0);
^~~~~~~~~~~
analogRead
exit status 1
'buttons' does not name a type

Someone please help me!

All errors are described in compiler output, just read it...

get rid the second line and check spelling of "analougRead"

Did you mean

int buttons [3] {2};

?

Thanks! This is one of my first projects, I am still learning how to read the compiler text

Hi,
Why these lines if this array is not used in the code?
It must be a book printing error.
Delete both lines.

Did you mean "the source code"?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.