0

Everything i read about the chinese Digispark attiny85 clones says you can use p0-5 as digitlal I\O (p5 as after fuse reset)

Simple test code for a button will not let me use P1 as an input tied to a simple button.

The code below works on p0,p2,p5 but will only interrupt the LED that is set to on, on P1.

#include "DigiKeyboard.h"

//pins 3 & 4 used for usb connection
bool buttonState1 = 0;

void setup() {
  pinMode(1, INPUT);
  digitalWrite(1, HIGH); //turn on pull-up resistor
}

void loop() {

  
    if (digitalRead(1)!= buttonState1){
      buttonState1 = digitalRead(1);
      if (buttonState1 == LOW)DigiKeyboard.print("test1");
    }

}
0
2

I had a quick look into the Schematics of a digisparc board. P1 is hardwired over an LED and a resistor to GND. If you turn on the PULL UP resistor for P1 the LED should light up and the voltage at P1 would be very low (it depends on the voltage divider that is built from the PULL UP resistor and the LED resistor); so the P1 reading should be LOW. If you connected the Button to GND and press it, the voltage at P1 drops to 0. But, that does not affect the LOW state. The program does not react. The LED turns off, because it is not powered anymore.

You could try to connect the button to +5V and do not setup a PULL UP resistor for P1. If you press the button the LED should light up and +5V should be at P1. It should change its state from high to low. (I did not tried that; but I see no reason, why it would not work).

Not the answer you're looking for? Browse other questions tagged or ask your own question.