Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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