Hi, guys.
I have been away for too long for my trip in Iran.
For those who has been supporting me very much in this forum, I would like to express my greatfulness one more time.
I am testing this tutorial from official website of arduino.
It's about analog input.
I have the same situaiton just like this tutorial and I've had it working as it should be.
But, suddenly, I had such idea.
What if I only want to pick out static voltages among the variables.(not the variables which created when potentiometer is turning)
Since the LED is blinking according to the intensity of the voltage that is regulated by potentiometer, the only change that I can see through the LED is the intensity of the LED's flashing action.
Can I make the LED to flash only in a situation that I do not touch potentiometer?
I want arduino to discard(dis-recognize?) the voltage values when I am rolling the pot and only recognize the voltage values that is coming from the potentiameter when I am not rolling the pot.
So, the varioubles that has been created during the (repeating)rolling action of the pot could be regarded as noise and only the static values that is created when I am not rolling the pot could be regarded as the values that arduino should pick out-resulting in LED flashing action.
Yes quite simple. Take a sample of the analogue voltage and compare it to what it was last time a sample was taken. If it is the same then increment a count, if it is different then reset the count. Only when the count reaches some threshold value you use the new value to up date the LED flashing.
It's a sort of analogue debounce.
Hi, mike.
Based on the code from the tutorial, I want to add a code that could read value from the potentiometer only when the pot is giving stable value(shaft doesn't move), and make the LED pin in a high state.
int potPin = 2;
int ledPin = 13;
int val = 0;
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
val = analogRead(potPin);
digitalWrite(ledPin, HIGH);
delay(val);
digitalWrite(ledPin, LOW);
delay(val);
}