Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int lightPin = A0;
- int ledPin = 5;
- int motionPin = 4;
- void setup() {
- // put your setup code here, to run once:
- Serial.begin(9600);
- pinMode(motionPin, INPUT);
- pinMode(ledPin, OUTPUT);
- }
- void loop() {
- int light = analogRead(lightPin);
- bool motion = digitalRead(motionPin);
- if (light < 900 && motion == HIGH) {
- digitalWrite(ledPin, HIGH);
- } else {
- digitalWrite(ledPin, LOW);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment