Tactile switch on attiny85

Hi everyone, I’m both new to this forum, and kinda new to arduino, so if I seem to break any rules I apologize in advance…
However I have been searching for a way to use a tactile switch on an arduino ide compatible attiny85 board without using an external resistor, as I’ve been told it has an internal resistor and it would not be necessary.

What I would eventually want to do ideally would be if the button is pressed once, it runs the first block of code, if it’s pressed twice in a row it runs the second, if it’s 3 times it runs the third, etc etc…
However so far I haven’t even gotten to one, since every time I plug one of the boards in, they just smoke, burn up and die…

Here’s a picture of what I tried (I must be a moron) and I will also include the sketch I was trying along with it.

#include <KEY.h>

int buttonpin = 2;

void setup() {
pinMode(buttonpin, INPUT_PULLUP);
}

void loop() {
  if (digitalRead(buttonpin) == HIGH){
    KEY.delay(300);
    KEY.Stroke(r, GUI);
    KEY.delay(1500);
    KEY.print("cmd");
    KEY.delay(300);
    KEY.Stroke(ENTER);
    KEY.delay(3000);
    KEY.print("mkdir C:\Once")
    KEY.Stroke(ENTER);
    KEY.delay(1500);
    KEY.print("exit");
    KEY.Stroke(ENTER);
}
}

If anyone can point me in the right direction, or tell me what I’m doing wrong, I would really appreciate it, I’m starting to run out of boards to experiment with

Lastofthetukkers: so if I seem to break any rules I apologize in advance..

That would have been easy to know in advance by simply reading the big fat How to sue the forum. ;) And in fact, you are, please add code-tags to your post.

Other then that, it's no difference then on a normal Arduino like an Uno. Just connect it between a pin and GND. Look like you shorted Vcc and GND in this configuration. After that, turn on the internal pull up resistor with pinMode(pin, INPUT_PULLUP).

Okay thanks man I will try straight away.. I'll fix that, sorry

Disconnect that 5V line from the button. When you press it now it shorts 5V to ground and that’s going to let the magic smoke out of your board.

septillion: That would have been easy to know in advance by simply reading the big fat How to sue the forum. ;) And in fact, you are, please add code-tags to your post.

Other then that, it's no difference then on a normal Arduino like an Uno. Just connect it between a pin and GND. Look like you shorted Vcc and GND in this configuration. After that, turn on the internal pull up resistor with pinMode(pin, INPUT_PULLUP).

Oh man you are a savior, that works like a charm.. Is it normal that high and low is reversed though? Because if I say if (digitalRead (pin) == HIGH) {godosomething}, it will do it when the button is not pressed.. When I set it to == LOW however it works like it's supposed to, runs only when the button is pressed, but I thought LOW meant no signal, and HIGH meant signal..

Maybe I'm asking a bit much now, but is there any chance it's possible to make it distinguish between one or two consecutive presses? And make it do 2 different things depending on the number of presses? Or is that not possible?

@Delta_G I did that, it works great now :)

You need to switch between stages: high and low. Connecting your button to GND pulls the pin low, the internal resistor pulls it high when you're not connected.

If you would connect the button to Vcc, you'd be pulling the pin high, but you'd also need an external resistor to pull it low when your button is off. Otherwise you can't be sure of the state the pin is in, as you'd be leaving it floating.

Lastofthetukkers: Is it normal that high and low is reversed though?

Yep, that's normal. But it's just flipped logic (aka active low), nothing scary/hard/wrong about it, just your newbie brain who thinks it's weird ;)

Ohh haha okay, good, I thought there was something weird going on Thanks again for the help man