[Solved] Arduino 8 Buttons, 8 LED's Problem

Hello

I have the Following Problem

I have an Arduino Nano where i have connected 8 Buttons and 8 LED's

My Problem now is that i cannot Press every Button individually.

Its kinda hard to explain, so i recorded it Arduino 8 Buttons - YouTube

I also attached a Fritzing schematic file of my Circuit

I have used a 100kOHM Resistor for all 8 Pull-up buttons.

What is my fault that this won't work?

BR
Hitmare

chansw.zip (21.5 KB)

I think you mean 100 ohm resistor. Not 100k ohm. If 100k, THAT would be your problem. You would also benefit by posting your code. Just be sure to use the forum's code tagsso it looks like this

And have a read through "How to use this forum".

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom.. :slight_smile:

DangerToMyself:
I think you mean 100 ohm resistor. Not 100k ohm. If 100k, THAT would be your problem.

100k pull up is ok. 100ohm wastes too much current.

But why use pull up resistors at all.
They are already inside the Nano chip.
You just have to enable them in code.

I would have connected the buttons between pin and ground.
NO resistors.

And use this in setup()

pinMode(buttonPin1, INPUT_PULLUP);
etc.

Leo..

Wawa:
100k pull up is ok. 100ohm wastes too much current.

But why use pull up resistors at all.
They are already inside the Nano chip.
You just have to enable them in code.

I would have connected the buttons between pin and ground.
NO resistors.

And use this in setup()

pinMode(buttonPin1, INPUT_PULLUP);
etc.

Leo..

Interesting. Never had a need to go over a 10k (yet). Just seems, with the small voltages and currents the Arduino uses, that a 100k would almost make it like there wasn't a connection at all. Guess I'll go do some math now.

DangerToMyself:
I think you mean 100 ohm resistor. Not 100k ohm. If 100k, THAT would be your problem. You would also benefit by posting your code. Just be sure to use the forum's code tagsso it looks like this

Hello and thanks for the fast replay.

Yes i used 100k Resistors

Here is my Code:

#include <EEPROM.h>



void setup() {
  // put your setup code here, to run once:
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
pinMode(8, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP);


pinMode(A0, OUTPUT);
pinMode(A1, OUTPUT);
pinMode(A2, OUTPUT);
pinMode(A3, OUTPUT);
pinMode(A4, OUTPUT);
pinMode(A5, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);

eepromWriteInt(2, 0); 
eepromWriteInt(3, 0);
eepromWriteInt(4, 0);
eepromWriteInt(5, 0);
eepromWriteInt(6, 0);
eepromWriteInt(7, 0);
eepromWriteInt(8, 0);
eepromWriteInt(9, 0);
Serial.begin(115200);
}

void loop() {


  // put your main code here, to run repeatedly:

if (digitalRead(2) == LOW) {
  change(2);
}
if (digitalRead(3) == LOW) {
  change(3);
}
if (digitalRead(4) == LOW) {
  change(4);
}
if (digitalRead(5) == LOW) {
  change(5);
}
if (digitalRead(6) == LOW) {
  change(6);
}
if (digitalRead(7) == LOW) {
  change(7);
}
if (digitalRead(8) == LOW) {
  change(8);
}
if (digitalRead(9) == LOW) {
  change(9);
}




}

void change(int port) {

if (eepromReadInt(port) == 0) {
    Serial.print(port);
    Serial.print("0");
    analogpin(port, 0);
    eepromWriteInt(port, 1);
    while (digitalRead(port) == LOW) { delay(200); } 
    //delayMicroseconds(500);
    return;
  }
if (eepromReadInt(port) == 1) {
    Serial.print(port);
    Serial.print("1");
    analogpin(port, 1);
    eepromWriteInt(port, 0);
    while (digitalRead(port) == LOW) { delay(200); } 
    //delayMicroseconds(500);
    return;
  }
}

void analogpin(int analog, int val) {
  if ( analog == 2 && val == 0 ) { digitalWrite(11, HIGH);}
  if ( analog == 2 && val == 1 ) { digitalWrite(11, LOW); }
  if ( analog == 3 && val == 0 ) { digitalWrite(10, HIGH); }
  if ( analog == 3 && val == 1 ) { digitalWrite(10, LOW); }
  if ( analog == 4 && val == 0 ) { digitalWrite(A5, HIGH); }
  if ( analog == 4 && val == 1 ) { digitalWrite(A5, LOW); }
  if ( analog == 5 && val == 0 ) { digitalWrite(A4, HIGH); }
  if ( analog == 5 && val == 1 ) { digitalWrite(A4, LOW); }
  if ( analog == 6 && val == 0 ) { digitalWrite(A3, HIGH); }
  if ( analog == 6 && val == 1 ) { digitalWrite(A3, LOW); }
  if ( analog == 7 && val == 0 ) { digitalWrite(A2, HIGH); }
  if ( analog == 7 && val == 1 ) { digitalWrite(A2, LOW); }
  if ( analog == 8 && val == 0 ) { digitalWrite(A1, HIGH); }
  if ( analog == 8 && val == 1 ) { digitalWrite(A1, LOW); }
  if ( analog == 9 && val == 0 ) { digitalWrite(A0, HIGH); }
  if ( analog == 9 && val == 1 ) { digitalWrite(A0, LOW); }
  
}

void eepromWriteInt(int adr, int wert) {
// 2 Byte Integer Zahl im EEPROM ablegen an der Adresse
// Eingabe: 
//   adr: Adresse +0 und +1 wird geschrieben
//   wert: möglicher Wertebereich -32,768 bis 32,767
// Ausgabe: 
//   -
// 2 Byte Platz werden belegt.
//
// Matthias Busse 5.2014 V 1.0

byte low, high;

  low=wert&0xFF;
  high=(wert>>8)&0xFF;
  EEPROM.write(adr, low); // dauert 3,3ms 
  EEPROM.write(adr+1, high);
  return;
} //eepromWriteInt

int eepromReadInt(int adr) {
// 2 Byte Integer Zahl aus dem EEPROM lesen an der Adresse
// Eingabe: 
//   adr: Adresse +0 und +1 wird gelesen
// Ausgabe: int Wert
//
// Matthias Busse 5.2014 V 1.0

byte low, high;

  low=EEPROM.read(adr);
  high=EEPROM.read(adr+1);
  return low + ((high << 8)&0xFF00);
} //eepromReadInt

Wawa:
100k pull up is ok. 100ohm wastes too much current.

But why use pull up resistors at all.
They are already inside the Nano chip.
You just have to enable them in code.

I would have connected the buttons between pin and ground.
NO resistors.

And use this in setup()

pinMode(buttonPin1, INPUT_PULLUP);
etc.

Leo..

Didn't work for me without the resistor

Hi,
OPs pics


Tom... :slight_smile: