2

I have a Digispark Rev.3 Kickstarter with ATTiny85 (see pinout below) and a three pin slide switch (see example below). I want to use the slide switch to control a task running on the Digispark, with the example code below.

The center pin of the slide switch will be connected to GND, one pin will be soldered to pin 2 on the Digispark (pinMode(2, INPUT_PULLUP);) and the remaining pin will be unused.

To install the switch, I want to have the center pin of the switch go through P3 on the pinout, one pin through P2 (which will be addressed in the code) and the remaining pin through P4. This means, P3 will be soldered to GND and depending on the switches position, P2 or P4 will connect to GND as well.

Could these connections between P2, P3 or P4 and GND interfere with the functionality or damage the Digispark?

int switchPos;
void setup() {
  pinMode(2, INPUT_PULLUP);
}

void loop() {
  switchPos = digitalRead(2);
  if (sensorVal == HIGH) {
    runCode();
  } else {
    delay(1000);
  }
}

Digispark Rev.3 Kickstarter with ATTiny85 Three pin slide switch

1 Answer 1

4

Yes, you will lose the USB connection, since PB3 and PB4 are used for the USB communication. Normally you wouldn't solder a component directly onto a board if it doesn't fit with all pins. Instead you would use wires or a breakout PCB to do the job.

If you really want to to that and you don't need any of the other pins, then you can use PB0 and PB1. Set PB1 to OUTPUT LOW and PB0 as input. The OUTPUT LOW is basically the same as ground and configuring a pin as INPUT will make it high resistance, so it doesn't interfere with the circuit.

3
  • Thank you for the feedback! By USB connection loss you mean via the pins 3 and 4 or in general? Because I am using the USB male plug to emulate a keyboard on this project. As for your suggestion about the pins 0 and 1, you'd say I could solder the switch like so i.imgur.com/67Uhvu2.png and use the OUTPUT LOW on pin 1 as an alternative to ground, correct?
    – emma.makes
    May 30, 2022 at 16:19
  • 1
    Pins PB3 and 4 are the data pins for the USB connection (emulated via software). When you want to send any data over USB you cannot use these. And yes, thats the wiring that I suggested (besides using wires)
    – chrisl
    May 30, 2022 at 18:37
  • Thank you for the feedback and your patience @chrisl! I've just checked the schematics of the Digispark and I understand how it makes sense, that the USB connection is impaired if I meddle with those pins.
    – emma.makes
    May 31, 2022 at 15:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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