Hello everyone, I'm new to the Arduino community and have only been learning for a couple of days. I have greatly enjoyed learning and have discovered a lot from looking at these forums. However I'm stumped on my latest endeavor.
I've managed to get each button to control a separate LED through a single analog wire. The problem is I can not figure out for the life of me how to not continue to repeat the effect. For instance, when I press button one, led one increases in brightness. If I hold down button one, led one continues to cycle through it's brightness level.
In short I just want a held button to act as a single button action and not continually repeat. One press, one action, until it is released and pressed again. I've tried several ways of doing this to no avail so I'll share my raw setup up and code. If you can help that would be great, and feel free to be honest if I've just done something completely backwards. I may be a noob but I can take some criticism. Thanks in advance.
And of course, if you want to use this code and/or setup feel free, just please share your uses/discoveries.

Here's the setup:

And here is my code:
/*
Desired effects:
LED ONE, when button is pressed increase one level in brightness untill button is released, and pressed again, then increase in brightness again
LED TWO, only light whil button two is pressed and held.
LED THREE and FOUR, Light when button is pressed. Turn off when button is pressed for a second time
*/
const int switcharrayPin=0; //switch array to analog pin 0
const int ledonePin=11; // LED ONE
const int ledtwoPin=10; // LED TWO
const int ledthreePin=9; // LED THREE
const int ledfourPin=6; // LED FOUR
int ledonelevel=0; // Set ledone begining level
boolean switchone = false; // Hold value of Switch ONE
boolean switchtwo= false; // Hold value of Switch TWO
boolean switchthree= false; // Hold value of Switch THREE
boolean switchfour = false; // Hold value of Switch FOUR
void setup()
{
Serial.begin(9600); // Start serial communication
pinMode (switcharrayPin, INPUT); // set switch array to input
pinMode (ledonePin, OUTPUT); // set ledone to output
pinMode (ledtwoPin, OUTPUT); // set ledtwo to output
pinMode (ledthreePin, OUTPUT); // set ledthree to output
pinMode (ledfourPin, OUTPUT); // set ledfour to output
}
void loop()
{
int switcharrayval = analogRead(switcharrayPin); //Read switcharryPin
if(switcharrayval > 350 && switcharrayval < 550) //Check if switch one was pressed
{
ledonelevel = ledonelevel + 51; // Add 51 to ledonelevel
if (ledonelevel >255) ledonelevel=0; //Recycle LED after max level
analogWrite(ledonePin, ledonelevel); // Cycle led through level
}
if(switcharrayval > 260 && switcharrayval < 350) // Check if switch two was pressed
{
switchtwo=true; // Turn on switch two
}
if (switcharrayval < 260 || switcharrayval > 350) // Check if switch two was released
{
switchtwo=false; // Turn off switch two
}
digitalWrite(ledtwoPin, switchtwo); // Set ledtwo to switch two
if(switcharrayval > 230 && switcharrayval < 300) // Check if switch three is pressed
{
delay(10);
switchthree=!switchthree; // If so reverse the value of switch three
digitalWrite(ledthreePin, switchthree); // Set ledthree ledthree to same value as switch three
}
if(switcharrayval > 150 && switcharrayval < 225) // Check if switch four is pressed
{
switchfour=!switchfour; // If so reverse the value of switch four
digitalWrite(ledfourPin, switchfour); // Set ledfour to same value as switch four
}
Serial.println(analogRead(switcharrayPin)); // Display switcharrayPin value in serial monitor
delay(100); // Set serial monitor delay
}