ATTINY85 / INPUT_PULLUP

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi everyone! I am trying to use the internal resistors on an ATTINY85 / Digispark board. The sketch DOES work on e.g. a Mega 2560.

The idea is to detect keypresses on each of four pins and use one pin for writing on the serial console (which is WRITE ONLY, i.e. I do not need to read it and could "save" that pin). The problem is, it PERMANENTLY reads one or two pins, lately printing "B" WITHOUT the key being pressed. Given that the same thing works on a MEGA 2560, I assume no hardware error in the setup of the physical keys.

 

What should I do? Which pins shall I use? Here is the sketch - help! :)


// #define SRL Serial3
#include <SoftwareSerial.h>
SoftwareSerial SRL(1,1);

void setup() {
  SRL.begin(300);

  // whatever pins, as long as no conflict appears with the serial port:
  pinMode(0, INPUT_PULLUP);
  pinMode(5, INPUT_PULLUP);
  pinMode(2, INPUT_PULLUP);
  pinMode(3, INPUT_PULLUP);

}

void loop() {

  if (digitalRead(0) == LOW) {
    SRL.print("A ");
  }

  if (digitalRead(5) == LOW) {
    SRL.print("B ");
  }

  if (digitalRead(2) == LOW) {
    SRL.print("C ");
  }

  if (digitalRead(3) == LOW) {
    SRL.print("D ");
  }

  SRL.println();

  delay(200);

}

Thank you in advance for your kind help!

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I notice DigitalPin 5 is shared with ATtiny85 RESET. Can we assume you have disabled the RESET function on your board ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

* blush * Yeah, PIN 5 was not such a brilliant idea.

 

What is more, I notice also PIN 3 behaves weirdly. Basically, if I connect anything on PIN 3, then all the other pins start to be read as "read". Is there anything special about PIN 3 that I need to set up for it to work "normally"? - (Otherwise, I am really left with only FOUR "normally working" pins.)

 

Push button detection works "normally" if it happens on pins 0, 1, 2 and 4.

 

Is there any way I can make pin 3 "behave normally", i. e. like 0, 1, 2 and 4?

 

Thank you so much for your kind help!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OK, I read that it has internally a 1.5 kOhm resistor to pull it up. Now: what does that mean for my setup? Can I use pin 3 as TX normally, i.e. to let the board print to serial from there?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

KedalionDaimon wrote:
OK, I read that it has internally a 1.5 kOhm resistor to pull it up. Now: what does that mean for my setup? Can I use pin 3 as TX normally, i.e. to let the board print to serial from there?

I'm surprised the datasheet has no information about using the /RESET pin for other uses.  And surely the effect on your usage of that pin for other than /RESET will depend on the c0onnections and needs.

 

How do you reprogram the unit if you have no /RESET for ISP?

 

[edit]  My datasheet says something a bit different than yours, so your app may act differently:

https://www.avrfreaks.net/forum/...

 

 

 

 

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

Last Edited: Sun. Feb 21, 2021 - 10:51 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have NO IDEA what you are trying to tell me. :)

 

That 1.5 kOhm resistor is on PIN3, reset is PIN5... Essentially, 2 out of 6 pins are behaving "strangely". I give up hope on PIN5, OK, I will not lose the "reset" capability. It is PIN3 I was having certain hope for.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I really don't see why folks go for these Unofficial Dev boards with highly crippled micro-controllers just because they're a few [pence/cents) cheaper than a regular UNO.

 

Anyway: I found a comprehensive guide on getting the thing to work properly with Arduino

https://gist.github.com/Ircama/22707e938e9c8f169d9fe187797a2a2c

It seems there are quite a few hoops to jump through, to say the least.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


KedalionDaimon wrote:
an ATTINY85 / Digispark board.

Here is the schematic:

So two of the pins are used by the bit banged USB interface, one is reset, that leaves three pins available for your sketch to use, although one has an LED attached so may limit it's use as an output pin.

How are the sketch pins mapped to the available pins you want to use.

Jim

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"