Created
April 23, 2022 22:03
-
-
Save rmkanda/e36f7ecffcd7a775b19a969552c3df54 to your computer and use it in GitHub Desktop.
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
#include <Arduino.h> | |
#include <Wire.h> | |
#define ONBOARD_LED 16 | |
#define LDR_PIN 2 | |
void setup() | |
{ | |
pinMode(ONBOARD_LED, OUTPUT); | |
pinMode(LDR_PIN, INPUT); | |
} | |
void loop() | |
{ | |
int ldrStatus = analogRead(LDR_PIN); | |
if (ldrStatus > 200) | |
{ | |
digitalWrite(ONBOARD_LED, HIGH); | |
} | |
else | |
{ | |
digitalWrite(ONBOARD_LED, LOW); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment