Created
January 13, 2021 15:25
-
-
Save alvesoaj/ff0d171fc178607b1f6f8694dadcac74 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
/* | |
* AJ Alves ([email protected]) | |
*/ | |
int ANALOG_PIN = A0; // The NodeMCU Analogic Pin | |
int BOARD_RESOLUTION = 1024 ; // The analogic board resolution, for example NodeMCU ESP8266 is 10 bit (from 0 to 1023) | |
int val = 0; // A varaible to hold the value | |
void setup() { | |
Serial.begin(9600); // Serial Port setup | |
} | |
void loop() { | |
val = analogRead(ANALOG_PIN); // Reading from analogic pin | |
if (val < BOARD_RESOLUTION / 2) { | |
Serial.println("It is DARK!"); | |
} else { | |
Serial.println("It is LIGHT!"); | |
} | |
delay(1000); // Wait 1 second | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment