Digitalread declare?

hi im trying to code for an ac and dc motor in aurduino, but it keeps flagging my digital read, im not sure why, i tried installing DigitalReadFast but its still being flagged.

int buzzerPin = 8;
int buttonPin = 7;
int buzzerPin2 = 12;

void setup() {
pinMode(buzzerPin, OUTPUT);
pinMode(buttonPin, INPUT_PULLUP);

pinMode(buzzerPin2, OUTPUT);
tone(buzzerPin, 1000, 2000);
}

void loop() {
int buttonState = digitalread(buttonPin);

 if(buttonState ==HIGH) {

digitalWrite(buzzerPin, LOW);
}
if (buttonState == LOW) {
digitalWrite(buzzerPin, HIGH);
}
if(buttonState ==HIGH) {
digitalWrite(buzzerPin2, LOW);
}

    if (buttonState == LOW) {
  digitalWrite(buzzerPin2, HIGH);
    }

tone(buzzerPin2, 440); // A4
delay(1000);

tone(buzzerPin2, 494); // B4
delay(1000);

tone(buzzerPin2, 523); // C4
delay(1000);

tone(buzzerPin2, 587); // D4
delay(1000);

tone(buzzerPin2, 659); // E4
delay(1000);

tone(buzzerPin2, 698); // F4
delay(1000);

tone(buzzerPin2, 784); // G4
delay(1000);

      noTone(buzzerPin);
      delay(1000);

}

that is the code

C:\Users\SScer\OneDrive\Documents\Arduino\buzzers\buzzers.ino: In function 'void loop()':
C:\Users\SScer\OneDrive\Documents\Arduino\buzzers\buzzers.ino:16:23: error: 'digitalread' was not declared in this scope
int buttonState = digitalread(buttonPin);
^~~~~~~~~~~
C:\Users\SScer\OneDrive\Documents\Arduino\buzzers\buzzers.ino:16:23: note: suggested alternative: 'digitalRead'
int buttonState = digitalread(buttonPin);
^~~~~~~~~~~
digitalRead

exit status 1

Compilation error: 'digitalread' was not declared in this scope

that is my error

digitalRead. Note the capital letter.

3 Likes

@sscerca

It shows in the error you received (edited for shortness)

I have given up on expecting people to actually read the error messages.

1 Like

sorry... meant to "send" to OP.