Hi there
I am trying to make a digispark read a pin that has been pulled up and then act if the pin has been grounded. I read that attiny does have internal pullup resistors. In my following code, if I test for input on sw1 being LOW, it never activates. Where is if I test for high, understandably, it runs all the time. May be I got something wrong. However similar code, with bza changed to 13, runs on arduino uno and behaves with the onboard led as expected. Turning on the LED when the sw1 is grounded and off when pulled high, that is.
Am I missing something or attiny does not have the pullup resistors ?
int sw1=5; //momentary switch to pull down the pin 1
int bza=1; //ping buzzer/led is connected to LED on digistump
void setup() {
pinMode(sw1, INPUT_PULLUP);
pinMode(bza,OUTPUT);
}
void buzzer(){
digitalWrite(bza, HIGH);
delay(500);
digitalWrite(bza, LOW);
delay(500);
}
void monpins(){
if (digitalRead(sw1)==LOW) {buzzer();}
}
void loop() {
monpins();
}
Thanks a lot.