Created
May 8, 2017 04:13
-
-
Save jesu0404/2e66d27df42e33c72ba74c7e218fbdea to your computer and use it in GitHub Desktop.
Arduino code to run the LCD, switches and dial.
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
#include <LiquidCrystal.h> | |
// initialize the library with the numbers of the interface pins | |
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); | |
int blueLED = 6; | |
int redLED = 7; | |
int greenLED = 8; | |
int yellowLED = 9; | |
int potPin = A5; | |
int sensorValue; | |
int magnet1 = 10; | |
int magnet2 = 13; | |
int weatherProfile; | |
void setup() | |
{ | |
lcd.begin (16,2); | |
Serial.begin(9600); | |
lcd.setCursor(2,0); | |
lcd.print("Please Choose"); | |
lcd.setCursor(0,1); | |
lcd.print("<--- or --->"); | |
pinMode(blueLED, OUTPUT); | |
pinMode(redLED, OUTPUT); | |
pinMode(greenLED, OUTPUT); | |
pinMode(yellowLED, OUTPUT); | |
pinMode(potPin, INPUT); | |
} | |
void loop() | |
{ | |
sensorValue = analogRead(potPin); | |
Serial.println(sensorValue); | |
if(sensorValue < 50) { | |
digitalWrite(redLED, LOW); | |
digitalWrite(yellowLED, LOW); | |
digitalWrite(greenLED, LOW); | |
digitalWrite(blueLED, LOW); | |
lcd.setCursor(0,0); | |
lcd.print(" Please Choose"); | |
} | |
else if(sensorValue >= 50 && sensorValue <= 255) { | |
digitalWrite(redLED, HIGH); | |
digitalWrite(yellowLED, LOW); | |
digitalWrite(greenLED, LOW); | |
digitalWrite(blueLED, LOW); | |
lcd.setCursor(0,0); | |
lcd.print("Good Morning! "); | |
if(digitalRead(magnet1) == HIGH) { | |
//getWeather("morning"); | |
} | |
else if(digitalRead(magnet2) == HIGH) { | |
//whatToWear(weatherProfile); | |
} | |
} | |
else if(sensorValue >= 256 && sensorValue <= 511) { | |
digitalWrite(yellowLED, HIGH); | |
digitalWrite(blueLED, LOW); | |
digitalWrite(greenLED, LOW); | |
digitalWrite(redLED, LOW); | |
lcd.setCursor(0,0); | |
lcd.print("Good Afternoon! "); | |
if(digitalRead(magnet1) == HIGH) { | |
//getWeather("afternoon"); | |
} | |
else if(digitalRead(magnet2) == HIGH) { | |
//whatToWear(weatherProfile); | |
} | |
} | |
else if(sensorValue >= 512 && sensorValue <= 767) { | |
digitalWrite(greenLED, HIGH); | |
digitalWrite(redLED, LOW); | |
digitalWrite(blueLED, LOW); | |
digitalWrite(yellowLED, LOW); | |
lcd.setCursor(0,0); | |
lcd.print("Good Evening! "); | |
if(digitalRead(magnet1) == HIGH) { | |
//getWeather("evening"); | |
} | |
else if(digitalRead(magnet2) == HIGH) { | |
//whatToWear(weatherProfile); | |
} | |
} | |
else if(sensorValue >= 768) { | |
digitalWrite(blueLED, HIGH); | |
digitalWrite(yellowLED, LOW); | |
digitalWrite(greenLED, LOW); | |
digitalWrite(redLED, LOW); | |
lcd.setCursor(0,0); | |
lcd.print("Go to sleep! "); | |
if(digitalRead(magnet1) == HIGH) { | |
//getWeather("nighttime"); | |
} | |
else if(digitalRead(magnet2) == HIGH) { | |
//whatToWear(weatherProfile); | |
} | |
} | |
} | |
void getWeather(string timeOfDay) { | |
int temp; | |
if(timeOfDay == "morning") { | |
temp = Serial.read(); //read in temperature from the Serial monitor | |
if(temp > 80) { | |
lcd.setCursor(0,0); | |
lcd.print("It will be hot. ") | |
} | |
else if(temp <= 80 && temp > 45) { | |
lcd.setCursor(0,0); | |
lcd.print("It will be mild. ") | |
} | |
else if(temp <= 45 && temp > 40) { | |
lcd.setCursor(0,0); | |
lcd.print("It will be cold. ") | |
} | |
else { | |
lcd.setCursor(0,0); | |
lcd.print("It will be frigid. ") | |
} | |
} | |
else if(timeOfDay == "afternoon") { | |
temp = Serial.read(); | |
if(temp > 80) { | |
lcd.setCursor(0,0); | |
lcd.print("It will be hot. ") | |
} | |
else if(temp <= 80 && temp > 45) { | |
lcd.setCursor(0,0); | |
lcd.print("It will be mild. ") | |
} | |
else if(temp <= 45 && temp > 40) { | |
lcd.setCursor(0,0); | |
lcd.print("It will be cold. ") | |
} | |
else { | |
lcd.setCursor(0,0); | |
lcd.print("It will be frigid. ") | |
} | |
} | |
else if(timeOfDay == "evening") { | |
temp = Serial.read(); | |
if(temp > 80) { | |
lcd.setCursor(0,0); | |
lcd.print("It will be hot. ") | |
} | |
else if(temp <= 80 && temp > 45) { | |
lcd.setCursor(0,0); | |
lcd.print("It will be mild. ") | |
} | |
else if(temp <= 45 && temp > 40) { | |
lcd.setCursor(0,0); | |
lcd.print("It will be cold. ") | |
} | |
else { | |
lcd.setCursor(0,0); | |
lcd.print("It will be frigid. ") | |
} | |
} | |
else if(timeOfDay == "nighttime") { | |
temp = Serial.read(); | |
if(temp > 80) { | |
lcd.setCursor(0,0); | |
lcd.print("It will be hot. ") | |
} | |
else if(temp <= 80 && temp > 45) { | |
lcd.setCursor(0,0); | |
lcd.print("It will be mild. ") | |
} | |
else if(temp <= 45 && temp > 40) { | |
lcd.setCursor(0,0); | |
lcd.print("It will be cold. ") | |
} | |
else { | |
lcd.setCursor(0,0); | |
lcd.print("It will be frigid. ") | |
} | |
} | |
} | |
void whatToWear(int weatherProfile) { | |
if(weatherProfile == 1) { | |
lcd.setCursor(0,1); | |
lcd.print("T-shirt+Shorts "); | |
} | |
else if(weatherProfile == 2) { | |
lcd.setCursor(0,1); | |
lcd.print("T-shirt+Pants "); | |
} | |
else if(weatherProfile == 3) { | |
lcd.setCursor(0,1); | |
lcd.print("Jacket+Pants "); | |
} | |
else { | |
lcd.setCursor(0,1); | |
lcd.print("Wintercoat+Pants "); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment