Go Down

### Topic: nokia lcd 5110 (Read 2575 times)previous topic - next topic

#### john44

##### Nov 26, 2011, 09:20 pm
hello,

I've the nokia lcd 5110 module. So, I must print the decade numbers from convert Distance in cm from my HC-SR04 module. Have you idea how I can do that? Because, the PCD8544 library haves only functions which they print characters.

#### Onions

#1
##### Nov 26, 2011, 09:38 pm
Check out http://www.arduino.cc/playground/Code/PCD8544
and http://blog.stuartlewis.com/2011/02/12/scrolling-text-with-an-arduino-and-nokia-5110-screen/

The first one definately gives you the option of printing a string, using the LcdString function.

Onions.
My website: http://www.harryrabbit.co.uk/electronics/home.html Up and running now! (Feel free to look round!)

#### john44

#2
##### Nov 26, 2011, 10:11 pmLast Edit: Nov 26, 2011, 10:16 pm by john44 Reason: 1
how can I convert the character-string function into number dec? I know a function String(value, DEC); Moreover, I write you my code

Code: [Select]
`void loop(){   LcdClear();  gotoXY(0, 2);  distance = ultrasonic.Ranging(CM);    LcdCharacter(ultrasonic.Ranging(CM));  // this functhion give me the character no decade numder !!!  LcdString("cm");      delay(3500);}`

I would like this http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1272177425

furthermore, I believe the solution is in this function,

Code: [Select]
`void LcdWrite(byte dc, byte data){  digitalWrite(PIN_DC, dc);  digitalWrite(PIN_SCE, LOW);  shiftOut(PIN_SDIN, PIN_SCLK, MSBFIRST, data);  digitalWrite(PIN_SCE, HIGH);}[code]how can I shiftout() DEC number and no byte data???`[/code]

#### Onions

#3
##### Nov 26, 2011, 10:56 pm
What data do you want to display on the LCD? It may just be a case of adding a number to the number you have. Check out the ASCII table: http://www.harryrabbit.co.uk/electronics/ASCII%20table.html

If you want to display the number 33, the character shown will be '!'. To get the LCD to show the number 33, a series of steps will need to be taken:

Split the number up into digits, which we'll store in an array:

array[0] = num % 10;
num = num / 10;
(repeat until num = 0)

If num was 33, the array will now have the values 3, 3. (Because of the way the above code processes the data, if num was 35, the array will now have the values 5, 3).

Next, turn the data in the array into a character. It is now the ASCII table comes in handy. If we assume a number of 0, we need to add 48 to it to produce the character 0. If the number is 3, we still need to add 48 to it to produce its character:

array = array + 48;

Then we need to start at the end of the array and work backwards, printing out the characters.

Code: [Select]
`while(num){  array[i] = num % 10;  num = num / 10;  i++;}arrayLegnth = i;for(int j = 0; j < i; j++){  array[j] = array[j] + 48;}while(i){  LcdCharacter(array[i]);  i--;}`

It should work...
Onions.
My website: http://www.harryrabbit.co.uk/electronics/home.html Up and running now! (Feel free to look round!)

#### john44

#4
##### Nov 27, 2011, 03:33 am
the solution of old problem

Code: [Select]
`http://www.cplusplus.com/reference/clibrary/cstdlib/itoa/`

Go Up

Please enter a valid email to subscribe