#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C LCD = LiquidCrystal_I2C(0x27, 16, 2);
const int sensorPin = 35;
float sensorValue = 0;
const float x = 0.0008122077282;
// LED light pins
const int ledRed = 32;
const int ledGreen = 33;
const int ledBlue = 25;
// void spinner() {
// static int8_t counter = 0;
// const char* glyphs = "\xa1\xa5\xdb";
// LCD.setCursor(15, 1);
// LCD.print(glyphs[counter++]);
// if (counter == strlen(glyphs)) {
// counter = 0;
// }
// }
void setup() {
Serial.begin(115200);
pinMode(sensorPin, INPUT);
pinMode(ledRed, OUTPUT);
pinMode(ledGreen, OUTPUT);
pinMode(ledBlue, OUTPUT);
LCD.init();
LCD.clear();
}
void loop() {
sensorValue = analogRead(sensorPin);
sensorValue *= x;
if (sensorValue <= 1.10) {
digitalWrite(ledRed, HIGH);
digitalWrite(ledGreen, LOW);
digitalWrite(ledBlue, LOW);
Serial.println("Low");
LCD.backlight();
LCD.clear();
LCD.setCursor(6, 0);
LCD.print("LOW");
LCD.setCursor(3, 1);
LCD.print(sensorValue);
LCD.print(" Volts");
} else if ((sensorValue > 1.10) && (sensorValue <= 2.10)) {
digitalWrite(ledRed, LOW);
digitalWrite(ledGreen, LOW);
digitalWrite(ledBlue, HIGH);
Serial.println("Moderate");
LCD.backlight();
LCD.clear();
LCD.setCursor(6, 0);
LCD.print("MODERATE");
LCD.setCursor(3, 1);
LCD.print(sensorValue);
LCD.print(" Volts");
} else {
digitalWrite(ledRed, LOW);
digitalWrite(ledGreen, HIGH);
digitalWrite(ledBlue, LOW);
Serial.println("Bright");
LCD.backlight();
LCD.clear();
LCD.setCursor(6, 0);
LCD.print("BRIGHT");
LCD.setCursor(3, 1);
LCD.print(sensorValue);
LCD.print(" Volts");
}
delay(300);
}