[vc_row][vc_column width=”1/1″][vc_column_text]
Use the LED of digital 13, and connect the Hall magnetic field sensor to digital pin 3, and when there is magnetic shield present, the LED will turn on, otherwise, it will turn off.
int Led=13; int SENSOR=3; int val; void setup() { pinMode(Led,OUTPUT); pinMode SENSOR,INPUT); } void loop() { val=digitalRead(SENSOR); if(val==HIGH) { digitalWrite(Led, HIGH); } Else { digitalWrite(Led, LOW); } }
[/vc_column_text][/vc_column][/vc_row]
Leave a Reply
You must be logged in to post a comment.