ATtiny 85 Analog read issue

thegoodhen:
Where are you setting the button as input?

I thought that all digital pins defaulted to input in Arduino?

EmanEric:
I thought that all digital pins defaulted to input in Arduino?

Yea, I corrected myself, and edited my answer. Please reread it.

change

if (stopBuzz==HIGH){ //if the button is pushed
while(true); //run this empty loop
}

to

if (stopBuzz==HIGH){ //if the button is pushed
digitalWrite(buzzerPin,LOW);
while(true); //run this empty loop
}

but be aware that this will lock the Attiny85 up, till you restart it.

thegoodhen:
change

if (stopBuzz==HIGH){ //if the button is pushed
while(true); //run this empty loop
}

to

if (stopBuzz==HIGH){ //if the button is pushed
digitalWrite(buzzerPin,LOW);
while(true); //run this empty loop
}

but be aware that this will lock the Attiny85 up, till you restart it.

Yeah thanks, I got it. It is very weird, becuase even with that change the buzzer doesn't really stop, but it is quite intermittent. I think it might be the ATtiny chip. I'm going to replace it and see what happens.

EmanEric:
Yeah thanks, I got it. It is very weird, becuase even with that change the buzzer doesn't really stop, but it is quite intermittent. I think it might be the ATtiny chip. I'm going to replace it and see what happens.

I find the tiny85 highly unlikely to be the cause of that. What is going on exactly?

thegoodhen:
I find the tiny85 highly unlikely to be the cause of that. What is going on exactly?

Well, replacing the chip had no effect. When I input a voltage way below the alarm voltage (alert at 5V, input at 3.4) the device works as expected. It stops buzzing when the button is pressed for good until restarted. However, when I input 3.4V and have the alarm voltage set to 3.6V, then the device doesn't work as it should. It buzzes like it should, but pressing the button stops the ringing while the button is held down, and then the ringing just returns when the button is released. If the button is pressed down many times, sometimes the ringing stops permanently.

EmanEric:
Well, replacing the chip had no effect. When I input a voltage way below the alarm voltage (alert at 5V, input at 3.4) the device works as expected. It stops buzzing when the button is pressed for good until restarted. However, when I input 3.4V and have the alarm voltage set to 3.6V, then the device doesn't work as it should. It buzzes like it should, but pressing the button stops the ringing while the button is held down, and then the ringing just returns when the button is released. If the button is pressed down many times, sometimes the ringing stops permanently.

What do you mean by "alarm voltage" ?
Edit: nvm, I see. Let me think.

What are you using as a power source? How high is the current draw from the buzzer?

thegoodhen:
What do you mean by "alarm voltage" ?
Edit: nvm, I see. Let me think.

What are you using as a power source? How high is the current draw from the buzzer?

I am using an arduino nano's built in 3.3V regulator (mine was more like 3.4V). The specs on the buzzer say 30mA at 5V. Actually yeah, that was causing the problem, when I use an actual battery it works ok and pressing the button does stop it for good. I guess that the current draw was too high for the regulator, and was causing the ATtiny to brown out. Looks like the project is all done! :smiley: Thanks for all of the help!