# Edge detection tutorial with pot

I've recently started playing around with Arduino and now I'd like to change the
Tutorial: State Change Detection (Edge Detection) for pushbuttons.
I've been looking for a while now how to use either pointers or arrays to acces elements in an array, but the internet didn't help me so far.

My idea is to add a potentiometer as an input for values 0 to 1023 and have a headerfile with an array (I think?) to use as a reference table.
So if my input is X I want my "VALUE" to be whatever I got stored in my headerfile.

I changed te tutorial a bit for my application;

if (buttonPushCounter % "VALUE" == 0) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}
if(buttonPushCounter == 10) // Reset the counter to repeat
buttonPushCounter = 0;
}

That would be `Value = yourArray[X];` but are you going to create an array of 1024 values? That's a lot of memory...

I would only need 10 elements to store my value, after that it resets.

so for example

Input Value
102.3 1
204.6 1
306.9 2

etc.

If there is a relationship between the value that you read, and the value that you want, then an array (called a lookup table) is not needed.

You really need to explain what you are trying to accomplish, not how you think you should do it.

`X` is your potentiometer `analogRead()`, right? So between 0 and 1023

what are the floating point numbers? Is that your way of splitting the range into 10 intervals? (So 1023/10). You should not use floating point number given that your input is an integer anyway...

And based on that `X`, you want to calculate a threshold `Value` to use in the modulo operation - is that correct?

If so the logic that defines the threshold `Value` based on `X` is if `X` is in the first or second interval, the `Value` is 1, or will be 2 in the third interval, etc?

Can you clarify exactly the logic?

My setup is a rotating wheel with 10 magnetic teeth and a reed sensor representing the pushbutton
It should send a delayed signal to my ledpin after it started counting from 0 and when a certain tooth is up.
I can't use a time delay because the rotational speed might differ.
There is a 10k sliderpot running parallel alongside the shaft,
there is no direct mathematical relationship between the potmeter and the value I want to use, I would like it to be user definable value.

Since I'm a pretty fresh Arduino user, I figured if I would use an array I could tell my code when my analogread ranges from let's say 0 to 102.3 it would use value "A" and for the next step 102.4 to 204.6 it uses value "B"

It should send a delayed signal to my ledpin after it started counting from 0 and when a certain tooth is up.

Please re-do this sentence to use nouns, not pronouns.

Sorry clear as mud... how can you tell which tooth is in front of the reed sensor and what has the potentiometer to do with all this? Is it important that it is parallel along the shaft?

Can you do a drawing and explain what you really want to achieve?