TroubleshootingArduino

need help with escape room puzzle im working on

userHead Luke.Germishuizen 2022-12-03 02:18:52 320 Views1 Replies

Hello Everyone, im new here, im working on a escape room puzzle, i have a chessboard, on the back of it, is a hall sensor.so if you place the right piece on the right spot the arduino sends a command to the relay and then the electric lock opens up. The problem im having is, if you place the chess piece on the board, the power on the lock stay on. Been struggling with this for days already. The code for the project is as follow

 

 

 

int hallSensorPin = 2;    

int ledPin =  13;    

int state = 0;          


 

void setup() {

  pinMode(ledPin, OUTPUT);      

  pinMode(hallSensorPin, INPUT);    

}


 

void loop(){

 

  state = digitalRead(hallSensorPin);

 

  if (state == LOW) {        

   digitalWrite(ledPin,LOW);

     

  }

  else {

  digitalWrite(ledPin, HIGH);

 

 

 

  }

}

2022-12-12 16:11:48

Hi, Try to use the serial port output to view the data output by the Hall sensor, and see if the chess pieces can output high and low levels normally when placed.

userHeadPic Winster