Skip to content

Instantly share code, notes, and snippets.

@quozl
Forked from schappim/hall-effect.ino
Last active December 20, 2017 02:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quozl/4a52f90a7878a0d46e80f875cee0c7f0 to your computer and use it in GitHub Desktop.
Save quozl/4a52f90a7878a0d46e80f875cee0c7f0 to your computer and use it in GitHub Desktop.
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