Your explanation still doesn't rise above the level of "Well, DUH".
i read a value from a potentiometer, put the value into an array " AnalogValue[stepnr] ", divide that by 8
That is plainly obvious but why do you divide it by 8?
and put it into another array "note[stepnr]"
Why put it in another array? You can just use the AnalogValue and divide by 8 when needed (this is more a coding efficiency issue)?
which represents the note to be played(this one I want to quantize),
Which completely contradicts yourself. In your first post you said you wanted to quantize the midi notes. Then, when asked about it, you said you wanted to quantize "note/pitch/frequency". Which is it?
than i simply sent that note to the serial port, which is connected to midi, the noteOn function i posted below.
Which synthesizer are you sending this to?
What does the write_value function do, what kind of device is it connected to and why do you multiply the analog value by 4?
And to, sort of, answer your, sort of, question. If you really do want to quantize the frequency of the analog signal, I don't think it can be done. Pitch shifting requires code to do FFT (and the inverse?) and it is not a trivial operation.