This is what i got so far
I have the debounceing working great, but i am stuck trying to implement my analog readings as the output value to the LED. any ideas?
i have written the analog reading / mapping part, but i am not sure how to alter the code for my use.
int switchPin = 8;
int ledPin = 13;
boolean lastButton = LOW;
boolean currentButton = LOW;
boolean ledOn = false;
int analogPin = A0
void setup()
{
pinMode(switchPin, INPUT);
pinMode(ledPin, OUTPUT);
}
boolean debounce(boolean last)
{
boolean current = digitalRead(switchPin);
if (last != current)
{
delay(5);
current = digitalRead(switchPin);
}
return current;
}
void loop()
int outputValue = map(analogValue, 0, 1023, 0, 255);
int analogValue = analogRead(analogPin);
{
currentButton = debounce(lastButton);
if (lastButton == LOW && currentButton == HIGH)
{
ledOn = !ledOn;
}
lastButton = currentButton;
digitalWrite(ledPin, ledOn);
}