My code is meant to detect if there is any movement registered on my movement sensor, it is meant to just send 'S' to the serial once however it is sending 7 time, I was wondering how to make it so it just sends once.
const int sensor = A0;
void setup() {
Serial.begin(9600);
}
void loop() {
int sensorVal = analogRead(sensor);
if(sensorVal > 2){
Serial.write("S");
delay(500);
}
}
Any help would be appreciated.