I have an Arduino UNO R3 Plus with 14 digital pins, but they don't function well. Or maybe they do, but the point is, I think I am overusing them. I have an LCD connected to ports 13-7, 4 LED lights connected to 5-2 and 2 buttons connected to 0-1. But I'm only using one button, so it is technically 1 button connected to port 1. The LED + button is an LED game, and I'm trying to make the LCD screen a counter for it. The LCD and and the LED "power cords" share the same breadboard segments, the LED is the one going up to the 5V power pin. The problem is that I can only make one work at a time, so I don't know if its the programming or the hardware. So please tell me how I can reprogram/rewire this (or else explain why it is impossible).
My code:
int currentLED = 2;
int delayValue = 200;
int numberShown = 0;
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(13, 12, 10, 9, 8, 7);
void setup() {
pinMode(1, INPUT); //Button
pinMode(2, OUTPUT); //White LED
pinMode(3, OUTPUT); //Yellow LED
pinMode(4, OUTPUT); //Green LED
pinMode(5, OUTPUT); //RED LED
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("hello, world!");
}
int checkInput() {
if(digitalRead(1)==0) {
return 1;
} else {
return 0;
}
}
}
void loop(){
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis()/1000);
if(digitalRead(1) == 0){
if(currentLED == 4) {
digitalWrite(4, HIGH);
delay(200);
digitalWrite(4, LOW);
delay(200);
digitalWrite(4, HIGH);
delay(200);
digitalWrite(4, LOW);
delay(200);
delayValue = delayValue - 10;
} else {
digitalWrite(currentLED, HIGH);
delay(200);
digitalWrite(currentLED, LOW);
delay(200);
digitalWrite(currentLED, HIGH);
delay(200);
digitalWrite(currentLED, LOW);
delay(200);
}
}
digitalWrite(currentLED, HIGH);
delay(delayValue);
digitalWrite(currentLED, LOW);
delay(delayValue);
currentLED = currentLED + 1;
if(currentLED > 5) {
currentLED = 2;
}
}