LED Won't Light Up Issue (Push Buttons & FSR)

Hey guys, hope someone able to enlighten me on this issue.

Basically i have a Mega, and my setup is:

  1. 12 push buttons
  2. LED 1 to 4 controlled by 12 push buttons
  3. FSR
  4. LED 5 controlled by FSR (Brightness depend on force exerted on FSR)

Everything is working fine if i do not use the push buttons and FSR together.

For e.g.

  1. I'm able to control LED 1 to 4 using the 12 push buttons through 12 digital inputs.
  2. I'm able to control LED 5 brightness using the FSR through 1 analog input.

But if i connect both the push buttons and FSR together, the circuit doesn't work. FSR controlling LED is working fine. But out of the 12 push buttons, only 4 are working, when i pressed the other 8 buttons, the LED won't light up, it blinks dimly and very fast.

What could be the issue? Coding? Or not enough power to power up 12 buttons with 1 FSR?

hack1409:
What could be the issue? Coding? Or not enough power to power up 12 buttons with 1 FSR?

Guess we may never know, without any idea what your code looks like, how you have wired it, or what a "FSR" is in your suburb. :astonished:

By the way, the forum instructions may be useful. :grinning:

This is my circuit.

And my coding:

// constants won't change. They're used here to set pin numbers:
const int buttonPin40 = 40; // the number of the RED pushbutton pin
const int buttonPin41 = 41; // the number of the YELLOW pushbutton pin
const int buttonPin42 = 42; // the number of the GREEN pushbutton pin
const int buttonPin43 = 43; // the number of the BLUE pushbutton pin
const int buttonPin44 = 44; // the number of the ALPABET A pushbutton pin
const int buttonPin45 = 45; // the number of the ALPABET B pushbutton pin
const int buttonPin46 = 46; // the number of the ALPABET C pushbutton pin
const int buttonPin47 = 47; // the number of the ALPABET D pushbutton pin
const int buttonPin48 = 48; // the number of the NUMERIC 1 pushbutton pin
const int buttonPin49 = 49; // the number of the NUMERIC 2 pushbutton pin
const int buttonPin50 = 50; // the number of the NUMERIC 3 pushbutton pin
const int buttonPin51 = 51; // the number of the NUMERIC 4 pushbutton pin
const int ledPin22 = 22; // the number of the RED LED pin
const int ledPin23 = 23; // the number of the YELLOW LED pin
const int ledPin24 = 24; // the number of the GREEN LED pin
const int ledPin25 = 25; // the number of the BLUE LED pin
const int ledPin6 = 6; // the number of the BLUE LED pin

int fsrAnalogPin = A0; // FSR is connected to analog 0
int fsrReading; // the analog reading from the FSR resistor divider
int LEDbrightness;

// variables will change:
int buttonState40 = 0; // variable for reading the pushbutton status
int buttonState41 = 0; // variable for reading the pushbutton status
int buttonState42 = 0; // variable for reading the pushbutton status
int buttonState43 = 0; // variable for reading the pushbutton status
int buttonState44 = 0; // variable for reading the pushbutton status
int buttonState45 = 0; // variable for reading the pushbutton status
int buttonState46 = 0; // variable for reading the pushbutton status
int buttonState47 = 0; // variable for reading the pushbutton status
int buttonState48 = 0; // variable for reading the pushbutton status
int buttonState49 = 0; // variable for reading the pushbutton status
int buttonState50 = 0; // variable for reading the pushbutton status
int buttonState51 = 0; // variable for reading the pushbutton status

void setup() {
// initialize the LED pin as an output:
pinMode(ledPin22, OUTPUT);
pinMode(ledPin23, OUTPUT);
pinMode(ledPin24, OUTPUT);
pinMode(ledPin25, OUTPUT);
pinMode(ledPin6, OUTPUT);

// initialize the pushbutton pin as an input:
pinMode(buttonPin40, INPUT);
pinMode(buttonPin41, INPUT);
pinMode(buttonPin42, INPUT);
pinMode(buttonPin43, INPUT);
pinMode(buttonPin44, INPUT);
pinMode(buttonPin45, INPUT);
pinMode(buttonPin46, INPUT);
pinMode(buttonPin47, INPUT);
pinMode(buttonPin48, INPUT);
pinMode(buttonPin49, INPUT);
pinMode(buttonPin50, INPUT);
pinMode(buttonPin51, INPUT);

Serial.begin(9600); // We'll send debugging information via the Serial monitor

}

void loop() {
// read the state of the pushbutton value:
buttonState40 = digitalRead(buttonPin40);
buttonState41 = digitalRead(buttonPin41);
buttonState42 = digitalRead(buttonPin42);
buttonState43 = digitalRead(buttonPin43);
buttonState44 = digitalRead(buttonPin44);
buttonState45 = digitalRead(buttonPin45);
buttonState46 = digitalRead(buttonPin46);
buttonState47 = digitalRead(buttonPin47);
buttonState48 = digitalRead(buttonPin48);
buttonState49 = digitalRead(buttonPin49);
buttonState50 = digitalRead(buttonPin50);
buttonState51 = digitalRead(buttonPin51);

// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (buttonState40 == HIGH) {
// turn LED on:
digitalWrite(ledPin22, HIGH);
} else {
// turn LED off:
digitalWrite(ledPin22, LOW);
}

if (buttonState41 == HIGH) {
// turn LED on:
digitalWrite(ledPin23, HIGH);
} else {
// turn LED off:
digitalWrite(ledPin23, LOW);
}

if (buttonState42 == HIGH) {
// turn LED on:
digitalWrite(ledPin24, HIGH);
} else {
// turn LED off:
digitalWrite(ledPin24, LOW);
}

if (buttonState43 == HIGH) {
// turn LED on:
digitalWrite(ledPin25, HIGH);
} else {
// turn LED off:
digitalWrite(ledPin25, LOW);
}

if (buttonState44 == HIGH) {
// turn LED on:
digitalWrite(ledPin22, HIGH);
} else {
// turn LED off:
digitalWrite(ledPin22, LOW);
}

if (buttonState45 == HIGH) {
// turn LED on:
digitalWrite(ledPin22, HIGH);
} else {
// turn LED off:
digitalWrite(ledPin22, LOW);
}

if (buttonState46 == HIGH) {
// turn LED on:
digitalWrite(ledPin23, HIGH);
} else {
// turn LED off:
digitalWrite(ledPin23, LOW);
}

if (buttonState47 == HIGH) {
// turn LED on:
digitalWrite(ledPin23, HIGH);
} else {
// turn LED off:
digitalWrite(ledPin23, LOW);
}

if (buttonState48 == HIGH) {
// turn LED on:
digitalWrite(ledPin24, HIGH);
} else {
// turn LED off:
digitalWrite(ledPin24, LOW);
}

if (buttonState49 == HIGH) {
// turn LED on:
digitalWrite(ledPin24, HIGH);
} else {
// turn LED off:
digitalWrite(ledPin24, LOW);
}

if (buttonState50 == HIGH) {
// turn LED on:
digitalWrite(ledPin25, HIGH);
} else {
// turn LED off:
digitalWrite(ledPin25, LOW);
}

if (buttonState51 == HIGH) {
// turn LED on:
digitalWrite(ledPin25, HIGH);
} else {
// turn LED off:
digitalWrite(ledPin25, LOW);
}

fsrReading = analogRead(fsrAnalogPin);
Serial.print("Analog reading = ");
Serial.println(fsrReading);

if (fsrReading > 50) {
// we'll need to change the range from the analog reading (0-1023) down to the range
// used by analogWrite (0-255) with map!
LEDbrightness = map(fsrReading, 0, 1023, 0, 255);
// LED gets brighter the harder you press
analogWrite(ledPin6, LEDbrightness);
} else {
analogWrite(ledPin6, LOW);
}

delay(100);

}

Edited my coding my removing these 2 lines:

Serial.print("Analog reading = ");
Serial.println(fsrReading);

And everything is working fine now. Why does the Serial.print cause the issue?

Ah, so you are ethically opposed to reading the forum instructions and end up talking only to yourself. With that attitude, I fear you may face many problems in life. :grinning: