Hobart, Tasmania
Offline
Newbie
Karma: 0
Posts: 1
Senior Newbie
|
 |
« Reply #9 on: January 26, 2012, 03:48:26 am » |
I got over the problem by ignoring the 0 and re-numbered the characters 1,2,3, etc. The next problem was that only half of the code is there. There is no use of the heart character or the frownie, let alone the lcd.setCursor() to place them. The pinout also changes with the LCD/buttons Shield from Freetronics Here is my rewrite:
*/
// include the library code: #include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
// make some custom characters: byte heart[8] = { 0b00000, 0b01010, 0b11111, 0b11111, 0b11111, 0b01110, 0b00100, 0b00000 };
byte smiley[8] = { 0b00000, 0b00000, 0b01010, 0b00000, 0b00000, 0b10001, 0b01110, 0b00000 };
byte frownie[8] = { 0b00000, 0b00000, 0b01010, 0b00000, 0b00000, 0b00000, 0b01110, 0b10001 };
byte armsDown[8] = { 0b00100, 0b01010, 0b00100, 0b00100, 0b01110, 0b10101, 0b00100, 0b01010 };
byte armsUp[8] = { 0b00100, 0b01010, 0b00100, 0b10101, 0b01110, 0b00100, 0b00100, 0b01010 }; void setup() { // create a new character lcd.createChar(1, heart); // create a new character lcd.createChar(2, smiley); // create a new character lcd.createChar(3, frownie); // create a new character lcd.createChar(4, armsDown); // create a new character lcd.createChar(5, armsUp);
// set up the lcd's number of columns and rows: lcd.begin(16, 2); // Print a message to the lcd. lcd.print("I "); lcd.write(1); lcd.print(" Arduino! "); lcd.write(2);
}
void loop() { // read the potentiometer on A0: int sensorReading = analogRead(A0); // map the result to 200 - 1000: int delayTime = map(sensorReading, 0, 1023, 200, 1000); // set the cursor to the bottom row, 5th position: lcd.setCursor(4, 1); // draw the little man, arms down: lcd.write(4); // set the cursor to the top row, 14th position lcd.setCursor(13, 0); // draw a frownie lcd.write(3); delay(delayTime); lcd.setCursor(4, 1); // draw him arms up: lcd.write(5); lcd.setCursor(13, 0); // draw a smiley lcd.write(2); delay(delayTime); }
|