smiley led display with home made 1x3 keypad // problem

Hi guys,

I'm working on a project where I made a led display with three faces (sad , neutral , happy).
To show a face I made a keypad from scratch with aliminiumfoil and paper.

My idea was to make 1 attachement to the keypad an output(high) and if a smiley is pressed the foil would touch each other and I could detect that with my arduino trough a digital read .
But my code isn't working. When I attach my arduino to my work it keeps on looping between a neutral face and a sad face without any key on my pad being touched !

What am I doing wrong?
I really need this to work :confused:

I added my code in attach
(sorry for my messy english!)

examenOpdracht.ino (2.08 KB)

What am I doing wrong?

Not posting your schematic.

How have you wired the input? Have you got a pull up or down resistor because your code is not enabling the internal ones you need one. See http://www.thebox.myzen.co.uk/Tutorial/Inputs.html

Now your code is wrong as well. Each while loop only gets executed once.
while (neutralVal == 1)
Because at the end you have the statement
neutralVal=0;
Where you should have a

neutralVal=digitalRead(neutralK);

Instead.

All three loops need mending like this.