I want to count peak of photocell data with serial communication in Arduino.
Here is the question. My problem is when I count one of the peaks it continues the counting and doesn't stop counting. My project is count Michelson Morley fringes with a photocell and Arduino.
If somebody can help me with the coding part I would appreciate it.
Here is the code that I used:
int count=0;
int val;
int data;
void setup() {
Serial.begin(115200);
}
void loop() {
data=analogRead(A0);
val=map(data,0,1023,1000,0);
if(val>700) {
count++;
}
Serial.println(count);
delay(100);
}