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!