Skip to content

Instantly share code, notes, and snippets.

@AiHiro
Last active February 1, 2017 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AiHiro/9a8a916b85bdfb87331502558463eaea to your computer and use it in GitHub Desktop.
Save AiHiro/9a8a916b85bdfb87331502558463eaea to your computer and use it in GitHub Desktop.
#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