Created
August 10, 2021 01:20
-
-
Save luanlmd/a5cf15b763d8e01fcd2a693c284068d8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
int tempVal; | |
int tempPin = 1; | |
int photoPin = 2; | |
int photoVal; | |
void setup() | |
{ | |
pinMode(LED_BUILTIN, OUTPUT); | |
Serial.begin(9600); | |
} | |
void loop() | |
{ | |
tempVal = analogRead(tempPin); | |
float mv = (tempVal/1024.0)*5000; | |
float cel = mv/10; | |
photoVal = analogRead(photoPin); | |
Serial.print("Temp: "); | |
Serial.print(cel); | |
Serial.print("*C"); | |
Serial.println(); | |
Serial.print("Photoresistor: "); | |
Serial.print(photoVal); | |
Serial.println(); | |
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) | |
delay(500); // wait for a second | |
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment