-
-
Save quozl/4a52f90a7878a0d46e80f875cee0c7f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int led = 13;//LED pin | |
int sensor = A5; //sensor pin | |
int val; //numeric variable | |
void setup() | |
{ | |
pinMode(led, OUTPUT); | |
} | |
void loop() | |
{ | |
val = analogRead(sensor); //Read the sensor | |
if(val > 614) //when magnetic field is detected, turn led on | |
{ | |
digitalWrite(led, HIGH); | |
} | |
else | |
{ | |
digitalWrite(led, LOW); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment