I am confident I solved themthe problem and think I know why it occurs.
PB1 on the digispark Attiny85 has a built in LED. This LED is still active when I run my code. The LED is dim, but consuming power. My hypothesis is that is is consuming enough current to drive that pin low when digital_read is called on PB1. Therefore, PB1 always evaluates to true, because of the internal LED (despite the fact that input_pullup should drive it false by default).
Here is how I tested this hypothesis:
- If I plug
PB1into 5v+, the internal LED gets brighter, and my project LED never lights up. i.e., my firstifis now!true, so the conditional fails to execute. - If I recode to exclude
PB1and instead map toPB3, my code runs as intended.
All of this is to say, I think that even when you specify PB1 as input_pullup, it does not behave as expected because of the internal LED.
@jsotola, thank you for your kindness and patience. What do you think?