London
Offline
Newbie
Karma: 0
Posts: 47
|
 |
« Reply #15 on: September 19, 2007, 06:04:03 am » |
Hi Alvaro, If I understand your first question correctly, you want to print your number in decimal on the LCD. See the section "Printing Numbers" on the LCD wiki page: http://www.arduino.cc/playground/Code/LCDRemember that the LCD library print() functions accept single ascii characters or strings of characters. So first you have to convert your number into a string representation. The wiki section above shows how to do this using the itoa() function. It might make sense for the LCD library to provide another function, say printNumber(int) which took an integer and printed its string representation in decimal. neillzero
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 2
Arduino rocks
|
 |
« Reply #16 on: March 23, 2008, 03:43:26 pm » |
First off, kudo's for the instructions in the 4bit playground page. If I had been paying attention to the datasheet I found for my display, I'd have got it working the first time  (For some reason the pin numbering is ass-backwards on my LCD). Still, I have a small question. For now, the random fruit example works perfectly. Single line, scrolling, all the bits. But, if I enable the 2nd line and the commented out 'score' bit the display stays empty. No noise, no nothing. Backlight comes on, but no character appear. Am I missing something, or have my earlier attempts killed just the second line? The display is a pc1602f, which should be hd44780 compatible. (excuse me for lifting this old thread from the depths of oblivion) Thanks! Andre
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 18
Arduino rocks
|
 |
« Reply #17 on: April 03, 2008, 12:00:33 pm » |
thanx a lot!
|
|
|
|
« Last Edit: April 04, 2008, 09:40:46 am by grandemahatma »
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 48
http://arduinors.net
|
 |
« Reply #18 on: August 15, 2008, 07:42:29 am » |
Hello Neillzero.
Congratulation by LCD4bit lib. I'm using and it's very very custom.
But, I have a suggestion:
Currently, I formatted my computer, but the pins had changed the lib in itself. cpp.
So when I installed again my system and upload to arduino, my display doesn't worked.
So again I edit in your CPP the pins.
You should create methods to set the number of pins.
Thanks
|
|
|
|
|
Logged
|
|
|
|
|
Denmark
Offline
Newbie
Karma: 0
Posts: 6
Arduino rocks
|
 |
« Reply #19 on: August 24, 2008, 03:34:11 am » |
Hey Neilzero.. Ive adapted your code into my little program, but can't find out how to make it show the temperature as 26,1 as oposed to the 261 format it is in now ?!?! Im sure you have a solution, I just can't see it since i've only been into arduino programming for about 4 days now :-/ My code is at the bottom. int heat = 451; char heat_str[4] = " "; //reserve the string space first itoa(heat, heat_str, 10); lcd.printIn(heat_str);
//todo: make sure number can be notated within str length.
My code.. #include <LCD4Bit.h>
LCD4Bit lcd = LCD4Bit(2); int temperaturePin = 2; // select the input pin for the temperature
void setup() { lcd.init(); }
void loop() {
lcd.clear(); lcd.printIn("Vandtemperatur :"); delay(1000);
int i, val = 0; for(i = 0; i < 20; ++i) { val += analogRead(temperaturePin); // read the value from the sensor delay(50); } val /= 4.06; // conversion value to millivolts if(val > 28 * 10) // temperature in deg C times 10, since we're measuring to tenths of a degree digitalWrite(13,HIGH); else digitalWrite(13,LOW); int heat = val; char heat_str[5] = " "; //reserve the string space first itoa(val, heat_str, 10);
lcd.cursorTo(2, 5); //line=2, x=6. lcd.printIn(heat_str); delay(1000); }
Thanks... Martin
|
|
|
|
« Last Edit: August 24, 2008, 05:49:47 am by Solow »
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 3
Arduino rocks
|
 |
« Reply #20 on: August 27, 2008, 10:19:57 pm » |
neillzero, Thanks so much for the trouble shooting help! I've been sitting here looking over the wiring over and over and over, wondering what could be wrong. Turns out, once I delete LCD4bit.o and recompiled the code, it worked perfectly! I'm glad I found your post, maybe this should be in the wiki? Maybe it is and I missed it! Thanks again!
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Full Member
Karma: 0
Posts: 150
veroboaring is the new XGame - Extreme Veroboarder
|
 |
« Reply #21 on: August 27, 2008, 10:43:10 pm » |
My 2 playing with 4 bits LCD...
I always use LCD4Bits library...but i build it with a new LCD WH1602, and do not work... in the Lib note this:
// ########## pin assignment ########## int RS = 12; // Register Select int RW = 11; // Read/Write int En = 2; // Enable
//DB should be an unseparated group of pins - because of lazy coding in push_nibble() int DB[] = {7, 8, 9, 10}; // DB4 .. DB7
That on the default lib, my Lib: // ########## pin assignment ########## int RS = 3; // Register Select int RW = 11; // Read/Write int En = 2; // Enable
//DB should be an unseparated group of pins - because of lazy coding in push_nibble() int DB[] = {8, 5, 7, 6}; // DB4 .. DB7 :o
So this is not working... could be the pin assignment?
Best Regards! Frank
|
|
|
|
|
Logged
|
|
|
|
|
Sweden, Malmö
Offline
Full Member
Karma: 1
Posts: 200
Rooky
|
 |
« Reply #22 on: August 28, 2008, 01:37:00 am » |
Hey Neilzero..
Ive adapted your code into my little program, but can't find out how to make it show the temperature as 26,1 as oposed to the 261 format it is in now ?!?! Im sure you have a solution, I just can't see it since i've only been into arduino programming for about 4 days now :-/
Solow, read the attached post and you will get it. http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1218132924/8#8
|
|
|
|
|
Logged
|
|
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 1
Arduino rocks
|
 |
« Reply #24 on: December 08, 2008, 10:35:07 pm » |
I've got a question, I haven't seen anyone else getting these strange results.
I have a HD44780 LCD and finally got it to display characters with the example. Only problem is, I don't see fruits I see characters like ->, 0, etc. It's like the character map used isn't correct for my LCD. Can these vary by LCD or isn't the ascii universal?
Any ideas? I've been playing with pins and am going to start probing to make sure all my connections are being made. Anything else I should look for?
EDIT Nevermind my dumb question. I was feeding corrupt data (data pins were backwards)
|
|
|
|
« Last Edit: December 09, 2008, 08:48:04 am by syko82 »
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 5
Arduino rocks
|
 |
« Reply #25 on: December 12, 2008, 12:30:41 pm » |
This is a great thread. Thanks for contributing. Just thought I'd capture the landmark I stumbled upon
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Jr. Member
Karma: 0
Posts: 53
Arduino rocks
|
 |
« Reply #26 on: December 25, 2008, 06:56:37 am » |
Hi, i came across these lines in your great library: void LCD4Bit::printIn(char msg[]) { uint8_t i; //fancy int. avoids compiler warning when comparing i with strlen()'s uint8_t for (i=0;i < strlen(msg);i++){ print(msg[i]); } } In my opinion you don't need to include <string.h> and you don't need that fancy int8_t. Take a look: void LCD4Bit::printIn(char msg[]) { int i = 0; while(msg[i]) { print(msg[i]); i++; } } greetings sunny
|
|
|
|
|
Logged
|
|
|
|
|
London
Offline
Faraday Member
Karma: 6
Posts: 6226
Have fun!
|
 |
« Reply #27 on: December 25, 2008, 09:04:45 am » |
That is an improvement. But why not use the LCD code provided in release 0012. It has much richer print functionality with the added benefit that it uses the same syntax as the Serial print routines.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Jr. Member
Karma: 0
Posts: 53
Arduino rocks
|
 |
« Reply #28 on: December 25, 2008, 09:28:12 am » |
That's a good question. I haven't looked at that one yet. But i will do. Thx mem!
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 32
Arduino rocks
|
 |
« Reply #29 on: February 01, 2009, 03:51:27 pm » |
Hello, I think I have an improvment to this great library. I did some writing to the second line of my display and that will take 117msec to position and write the line content. After looking around, i found this site: http://www.geocities.com/dinceraydin/lcd/commands.htm and there is the command 0x080 to position the cursor directly, with going to home position and move left the cusor position. I now wrote a simple method to test this (no error handling, just a proof of concept :-) ): void myCursorTo(int aLine, int aCol) { int CmdToWrite = 128; //0x80 switch(aLine) { case 1: CmdToWrite = CmdToWrite + aCol; break; case 2: // this line is buggy, jumps only to first column of line 2 CmdToWrite = CmdToWrite + 40 + aCol; break; } lcd.commandWrite(CmdToWrite); } By using this to position the cursor, moving to second line and writing the content now just needs 35msec. A really great speed improvement. Cheers KiWiX
|
|
|
|
« Last Edit: February 02, 2009, 01:51:48 pm by kiwix »
|
Logged
|
|
|
|
|
|