Categories

Sunday, August 4, 2013

I love my Arduino!: Got text updating on an LCD module


I made some great progress with my Arduino by setting up my LCD to update with programmable text! It was a little tricky but it worked out in the end. I also made use of my bread box and took a lesson on LED set up, making pretty colorful lights :o

Hit the jump for more images and code snippets





Ok i cheated. The last picture is the insides of my computer but you wouldn't be able to tell the difference!!

Please note that the LCD monitor I used was a sainsmart LCD2004 which you can buy here on Amazon:
http://www.amazon.com/gp/product/B003B22UR0/ref=oh_details_o04_s00_i01?ie=UTF8&psc=1

Here's the code that I used to make the LCD test work from the Arduino compiler:

#include <Wire.h>
#include <LiquidCrystal_i2c.h>

LiquidCrystal_I2C lcd(0x3F,16,2); //set the LCD address to 0x27 for a 16 chars and 2 line display

void setup()
{
    lcd.init();
    lcd.backlight();
    lcd.setCursor(0, 0);
    lcd.print("Barak LCD Test");
    lcd.setCursor(0, 1);
    lcd.print("Voltage: ");
    lcd.setCursor(13, 1);
    lcd.print("V");
}
void loop()
{
    int val;
    float temp;
    val=analogRead(0);
    temp=val/4.092;
    val=(int)temp;//
    lcd.setCursor(9, 1);
    lcd.write(byte(0x30+val/100));
    lcd.write(byte(0x30+(val%100)/10));
    lcd.print('.');
    lcd.write(byte(0x30+val%10));
    delay(100);
}


No comments :

Post a Comment