Skip to content

Instantly share code, notes, and snippets.

@luanlmd
Created August 10, 2021 01:20
Show Gist options
  • Save luanlmd/a5cf15b763d8e01fcd2a693c284068d8 to your computer and use it in GitHub Desktop.
Save luanlmd/a5cf15b763d8e01fcd2a693c284068d8 to your computer and use it in GitHub Desktop.
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