Skip to content

Instantly share code, notes, and snippets.

@jpliew
Created March 25, 2020 06:45
Show Gist options
  • Save jpliew/9affae1c7d892af8b2284ede12b447e9 to your computer and use it in GitHub Desktop.
Save jpliew/9affae1c7d892af8b2284ede12b447e9 to your computer and use it in GitHub Desktop.
Tutorial 3 - 2B
int sensorPin = 2;
int LEDPin = 13;
int isTilted = 0;
void setup() {
Serial.begin(9600);
pinMode(sensorPin, INPUT);
pinMode(LEDPin, OUTPUT);
}
void loop() {
isTilted=digitalRead(sensorPin);
if (isTilted) {
digitalWrite(LEDPin, HIGH);
} else {
digitalWrite(LEDPin, LOW);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment