Created
March 25, 2020 06:45
-
-
Save jpliew/9affae1c7d892af8b2284ede12b447e9 to your computer and use it in GitHub Desktop.
Tutorial 3 - 2B
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 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