// Define the GPIO pins
const int hallSensor1 = 2; // GPIO pin for hall sensor 1
const int hallSensor2 = 3; // GPIO pin for hall sensor 2
const int hallSensor3 = 4; // GPIO pin for hall sensor 3
// Define the sequence: 1, 5, 4, 6, 2, 3
int hallSequence[] = {
0b001, // 1
0b101, // 5
0b100, // 4
0b110, // 6
0b010, // 2
0b011 // 3
};
int currentStep = 0; // Track the current step in the sequence
void setup() {
// Initialize the GPIO pins as outputs and set internal pull-up
pinMode(hallSensor1, OUTPUT);
pinMode(hallSensor2, OUTPUT);
pinMode(hallSensor3, OUTPUT);
digitalWrite(hallSensor1, HIGH);
digitalWrite(hallSensor2, HIGH);
digitalWrite(hallSensor3, HIGH);
}
void loop() {
// Set the hall sensor pins based on the current sequence step
digitalWrite(hallSensor1, hallSequence[currentStep] & 0b001);
digitalWrite(hallSensor2, hallSequence[currentStep] & 0b010);
digitalWrite(hallSensor3, hallSequence[currentStep] & 0b100);
// Move to the next step in the sequence
currentStep = (currentStep + 1) % 6;
// Wait for 100ms before changing to the next state
delay(1000);
}