Created
May 14, 2018 00:00
-
-
Save dangpzanco/1cbdf80b1b09dead988072ba59330c51 to your computer and use it in GitHub Desktop.
UV meter in Arduino Uno
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
void setup() | |
{ | |
// open serial port, set the baud rate to 9600 bps | |
Serial.begin(115200); | |
} | |
void loop() | |
{ | |
float UVIndex; | |
// Connect UV sensors to Analog 0 | |
int32_t sensorValue = analogRead(0); | |
float voltValue = 5.0f * (sensorValue) / 1024.0f; | |
if(voltValue <= 200e-3) | |
UVIndex = voltValue/0.2f; | |
else | |
UVIndex = 2.0f*voltValue/0.2f; | |
// Print the value to serial | |
Serial.print(voltValue); | |
Serial.print(","); | |
Serial.println(UVIndex); | |
delay(200); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment