Last active
February 1, 2017 14:43
-
-
Save AiHiro/9a8a916b85bdfb87331502558463eaea to your computer and use it in GitHub Desktop.
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 <Wire.h> | |
#include <LiquidCrystal_I2C.h> | |
LiquidCrystal_I2C lcd(0x27,16,2); | |
const int CDS = 0; | |
const int led = 3; | |
const int tilt_port = 1; | |
String first_message = ""; | |
void setup() | |
{ | |
pinMode(led,OUTPUT); | |
//Serial.begin(9600); | |
lcd.init(); | |
} | |
void loop() | |
{ | |
int tilt_value; | |
while(1) | |
{ | |
lcd.setCursor(0, 0); | |
lcd.backlight(); | |
tilt_value=analogRead(tilt_port); | |
//Serial.println(tilt_value); | |
if(tilt_value>500) { | |
digitalWrite(led, LOW); | |
first_message = " stable "; | |
} else { | |
digitalWrite(led, HIGH); | |
first_message = "sloping surface"; | |
} | |
lcd.print(first_message); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment