Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int sensorPin = 4; // the number of the sensor pin
- const int ledPin = 13; // the number of the LED pin
- int sensorState = 0; // variable for reading the sensor status
- void setup() {
- pinMode(ledPin, OUTPUT);
- pinMode(sensorPin, INPUT);
- }
- void loop() {
- // read the state of the sensor value:
- sensorState = digitalRead(sensorPin);
- // if the sensorState is HIGH:
- if (sensorState == HIGH) {
- digitalWrite(ledPin, HIGH);
- }
- else {
- digitalWrite(ledPin, LOW);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment