Hello,
I am a beginner and this will most likely be an easy question for most of you. I am trying to have my buzzer sound when the analog input from my pot gets too low. Just messing around with some tutorials ive watched.
So I programmed my LED to adjust brightness as the voltage changed thru the pot and it works. Then I thought itd be cool if the buzzer would sound as the LED got dimmer so I tried to wire it up and program it and I had no luck.
So the buzzer is wired correctly because if I load sunfounders buzzer program the buzzer sounds correctly. The lef and pot are also wired correctly and the led functions as expected, adjusting brightness as the pot is turned.
I just cant get the buzzer to sound when the led gets too dim.
here is my code;
const int potINPUT = A0;
const int ledPin = 9;
int outputVALUE = 0;
int inputVALUE = 0;
int digitalBUZZ = 12;
void setup(){
digitalBUZZ= LOW;
pinMode(digitalBUZZ,OUTPUT);
}
void loop()
{
inputVALUE = analogRead(potINPUT);
outputVALUE = map(inputVALUE, 0, 1023, 0, 255);
analogWrite(ledPin, outputVALUE);
if(inputVALUE < 150){
digitalWrite(digitalBUZZ, HIGH);
}
}
Any help is appreciated and please dont assume I know anything, haha.
Thanks again