Hello sorry for the previous message. Here is the code that I am working with.
const int switchPin = 2;
const int ledPin = 13;
const int relay1=7;
const int relay2=8;
int times=0; // how many times the wheel turns
void setup() {
Serial.begin(9600);
pinMode(switchPin, INPUT);
pinMode(ledPin, OUTPUT);
digitalWrite(switchPin, HIGH);
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
digitalWrite(relay1, HIGH);
digitalWrite(relay2, HIGH);
}
void loop() {
if(digitalRead(switchPin) == LOW){
digitalWrite(ledPin, LOW);
times = times + 1;
}else {
digitalWrite(ledPin, HIGH);
}
/* Check the relay status */
if(times==3) {
digitalWrite(relay1, LOW);
}else if(times==8) {
digitalWrite(relay2, LOW);
}
Serial.println("Whell turn times:");
Serial.println(times);
delay(100);
}
Furthermore I have no schematics about my sensor. I just work with plug and play mode. The sensor is this: Keyes Hall Effect Magnetic Sensor Module for Arduino - Free shipping - DealExtreme