Skip to content

Instantly share code, notes, and snippets.

@futureshocked
Created January 6, 2020 05:39
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 futureshocked/3934b0e9cba045d3d773f369fb619e0d to your computer and use it in GitHub Desktop.
Save futureshocked/3934b0e9cba045d3d773f369fb619e0d to your computer and use it in GitHub Desktop.
Use this sketch to detect when your Arduino is tilted. Connect a tilt sensor to Analog pin 0 (A0)
int out;
void setup()
{
Serial.begin(9600); // sets the serial port to 9600
}
void loop()
{
out = analogRead(0); // read analog input pin 0
Serial.println(out, DEC);
delay(100); // wait 100ms for next reading
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment