Skip to content

Instantly share code, notes, and snippets.

@n3rdf1ght3r
Created October 4, 2015 21:06
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 n3rdf1ght3r/4b12a16a99d07a08bcd6 to your computer and use it in GitHub Desktop.
Save n3rdf1ght3r/4b12a16a99d07a08bcd6 to your computer and use it in GitHub Desktop.
Demotivational Scale
// include the library
#include <LiquidCrystal.h>
// init the lcd display according to the circuit
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
//variables for weight
int weight = 0;
int val = 0;
String insult = "";
// it's a 16x2 LCD so...
int screenWidth = 16;
int screenHeight = 2;
// the two lines
// line1 = scrolling
String line1 = insult;
// line2 = static
String weightDisplay = String(weight) + " ish pounds";
// just some reference flags
int stringStart, stringStop = 0;
int scrollCursor = screenWidth;
// most of the part is pretty basic
void setup() {
lcd.begin(screenWidth,screenHeight);
}
void loop() {
//scrolling text stuff by this guy http://bit.ly/1RoUXTd
lcd.setCursor(scrollCursor, 0);
lcd.print(line1.substring(stringStart,stringStop));
lcd.setCursor(0, 1);
lcd.print(weightDisplay);
delay(300);
lcd.clear();
if(stringStart == 0 && scrollCursor > 0){
scrollCursor--;
stringStop++;
}
else if (stringStart == stringStop){
stringStart = stringStop = 0;
scrollCursor = screenWidth;
}
else if (stringStop == line1.length() && scrollCursor == 0) {
stringStart++;
}
else {
stringStart++;
stringStop++;
}
//weight checking stuff
val = analogRead(4);
do
{
//checks for the weight when there is no pressure on the scale
delay (50);
val = analogRead(4);
weight = (val - 512) * 13;
//updates the weight on the lcd
weightDisplay = String(weight) + " ish pounds";
if (weight < 90)
{
line1 = "What is this a scale for ants?";
}
else if (weight == 91)
{
line1 = "You're so fat you have more rolls than a bakery";
}
else if (weight == 104)
{
line1 = "Damn how long have you been pregnant for?";
}
else if (weight == 117)
{
line1 = "When you stood on the scale I though my phone number popped up";
}
else if (weight == 130)
{
line1 = "You're not big boned, you're just fat";
}
else if (weight == 143)
{
line1= "Want to look thinner? Hang out with fat people.";
}
else if (weight == 156)
{
line1 = "You're in shape, just not the right one";
}
else if (weight == 169)
{
line1 = "Fat people are harder to kidnap";
}
else if (weight == 182)
{
line1 = "Even your double chin has a double chin";
}
else if (weight == 195)
{
line1 = "Your couble chin has a double chin";
}
else if (weight >= 208)
{
line1 = "Can't.. Breathe...";
}
}
while (val <= 512) ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment