Hi there guys, i'm new in Arduino so as of right now i'm not quite sure if my question has an answer as of right now or not!
I was trying to create the Memory game with arduino uno by using 4 different-colour LED-s and 4 buttons and i was thinking of adding an LCD monitor to print Level and Game Over (never used one before) . But when i saw the schematic i realised it needed some Digital pins and those are "occupied" by the LEDs and buttons. Is there any workaround?! Thank you!
The schematic is pretty much like this one:

You can also use the analogue inputs as digital I/O.
Just configure them with 'pinMode()' then use them just like any other digital pins.
If you're using a standard HD44780U-compatible LCD, you can use it in 4-bit mode using the "LiquidCrystal" library, so it will only use 6 pins anyway. You have heaps of pins left. 
If you use I2C HD44780U-compatible LCD then you only need A4 and A5 analogue inputs.
BillHo:
If you use I2C HD44780U-compatible LCD then you only need A4 and A5 analogue inputs.
True. But since he says the pins he needs are 'occupied', I assumed he must have had a standard parallel LCD display, since SCL and SDA are unused..
Anyway, either way he doesn't have a problem.
he could just use 4 pins for the LED's and buttons. then he would have a lot of pins left over.
The one i'm using is LCM1602C (the one inside the starter kit).
So i have to use the analog pins and set pinmode from input to output?!
sh4d0w11s:
The one i'm using is LCM1602C (the one inside the starter kit).
So i have to use the analog pins and set pinmode from input to output?!
Just use them as you would a normal digital pin, as inputs or outputs.
I don't know what 'starter kit' you're referring to, (I've never bought a starter kit), but I imagine your LCD would be HD44780-compatible if it's included in an Arduino starter kit, so that it could be used with the "LiquidCrystal" library.
dave-in-nj:
he could just use 4 pins for the LED's and buttons. then he would have a lot of pins left over.
Dave, I'd like to see how that's done without the pushbuttons affecting the LED states.
OldSteve:
Just use them as you would a normal digital pin, as inputs or outputs.
I don't know what 'starter kit' you're referring to, (I've never bought a starter kit), but I imagine your LCD would be HD44780-compatible if it's included in an Arduino starter kit, so that it could be used with the "LiquidCrystal" library.
Dave, I'd like to see how that's done without the pushbuttons affecting the LED states.
{
- LCD RS pin to digital pin 12
- LCD Enable pin to digital pin 11
- LCD R/W pin to Ground
- LCD VO pin (pin 3) to PWM pin 9
- LCD D4 pin to digital pin 5
- LCD D5 pin to digital pin 4
- LCD D6 pin to digital pin 3
- LCD D7 pin to digital pin 2
}
How am i supposed to transform this into analog?! O.o
You don't 'transform' anything to analogue. l said that you can use the analogue pins A0 to A5 as normal digital I/O. Just forget that they can also be used as analogue inputs with 'analogRead()'.
You need to do some research on how to use an Arduino, I think. Google is very handy for this.
You could possibly start here:-
Analog Input Pins
If you want to use A0 as an output:-
pinMode(A0,OUTPUT);
If you want to use pin A3 as an input:-
pinMode(A3,INPUT);
How am i supposed to transform this into analog?!
You are not transforming anything to analog. You are using pins which are connected to an internal analog to digital converter on the main chip and can be used for analogRead(). They are no different than any of the other digital pins except for this internal connection and they can be used as a digital pin.
Use pinMode to set all the analog pins to OUTPUT. For example pinMode(A0,OUTPUT);
Thyen connect the display to the analog pins.
- LCD RS pin to digital pin A0
- LCD Enable pin to digital pin A1
- LCD R/W pin to Ground
//* LCD VO pin (pin 3) to PWM pin 9 <<<This is wrong!! See discussion below
- LCD VO pin (pin 3) to GND through potentiometer/rheostat/or fixed resistor of correct value
- LCD D4 pin to digital pin A5
- LCD D5 pin to digital pin A4
- LCD D6 pin to digital pin A3
- LCD D7 pin to digital pin A2
In your sketch, be sure that the "constructor" which tells the Arduino which pin is connected to what pin on the LCD matches your wiring. You can use any pin with the lcd as long as you tell the library what you are doing.
LiquidCrystal lcd(A0, A1, A5, A4, A3, A2);
Now, in regards to the V0 pin which is often called "contrast". It is usually connected to ground through the middle leg of a potentiometer which is also connected to 5v and ground. This is completely unnecessary and overly complex. The V0 pin needs to be connected to ground through a resistance value which will make the display show characters. It is usually somewhere between 470 ohm and 2.7K ohm.
The pot is a convenient way to adjust this resistance. The pot can also be used as a rheostat with the V0 pin connected to the middle wiper and only one leg of the pot connected to ground. No need for the 5v. In most of my work with these displays I just use a resistor from V0 to GROUND.
Trying to run the "contrast" with a PWM pin is wrong, and people have had mixed success with doing it. Trying to vary the "contrast" once it is set up is completley unnecessary as well.
Thank you very much,that helped alot! Now i will mount my LCD on a second breadboard and then connect the second breadboard using the Analog pins!!! 