Skip to content

Instantly share code, notes, and snippets.

@arduinothai
Created May 13, 2018 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arduinothai/6fa7991f9e557db75f9ebba186a2e899 to your computer and use it in GitHub Desktop.
Save arduinothai/6fa7991f9e557db75f9ebba186a2e899 to your computer and use it in GitHub Desktop.
int SensorPin = 2;
int value;
void setup(void) {
Serial.begin(9600);
pinMode(SensorPin,INPUT);
}
void loop(void) {
value = digitalRead(SensorPin);
Serial.print("Analog reading = ");
Serial.println(value);
if (value == 0)
{
Serial.println(" - Very bright");
}
else
{
Serial.println(" - Dark");
}
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment