Show Posts
Pages: [1]
1  Topics / Science and Measurement / Re: Data logging with Mega 2560 using Max3232 on: May 02, 2013, 07:35:17 am
I have had strange datas also when RS232 GND and Arduino GND were not connected...
2  Using Arduino / Programming Questions / Re: Int to ASCII conversion on: May 02, 2013, 05:59:58 am
Thank you all guys... I am going to try this...

EDIT:  Yes, problem solved. Thanks guys.

Finally I stored the incoming byte into char array, and then I converted it to float.
3  Using Arduino / Programming Questions / Re: Int to ASCII conversion on: May 01, 2013, 11:40:27 am
I'm reading those 13 bytes byte after byte, the last byte is CR.

for example, when receiving:
=0012.30(kg) CR

I'll get 13 bytes:
61 48 48 49 50 46 51 48 40 107 103 41 13

which are ASCII values of the message.

But with Serial.read I can receive just int,... or?


Also I'll try (as Grumpy_Mike) advised lcd.print ('buffer');.

4  Using Arduino / Programming Questions / Int to ASCII conversion on: May 01, 2013, 09:48:07 am
Hello,

I'm receiving from RS232 (via MAX232) datas; the word consist of  13 bytes and it is>
=xxxx.xx(kg) + CR, where 'x' is number and '.' is decimal point.

I can succesfully read the datas via Serial monitor (Serial.write (incomingByte));

Also I can display it on LCD using LCD.write (incomingByte);

I want to pick up just the numbers from message. All incoming bytes are the type int.
(Serial.write or LCD.write just make ASCII representation of that ints).

So my idea was to convert the int to ASCII, make a String and then cut the String. And then maybe to convert it to float.

So I used the itoa() in the way:

Code:
int incomingByte = 0; 
char buffer[12];
String ascii_num;

void loop() {

  if (Serial.available()) {
    incomingByte = Serial.read();
    itoa (incomingByte, buffer, 10);
     // so if I understand it correctly - now in buffer should be a character (like '0' for 48)
     // optionaly I can combine those buffers into string
     // ascii_num += buffer;
      lcd.print (buffer);
     
  } // end if

The problem is, that lcd.print (buffer) (or Serial.print (buffer)) is not showing the ASCII character, but always the number (I mean is not showing e.g. 'A', but 65);

I was searching the web, etc., but no way. I have feeling that itoa is not converting to ASCII but just into the string.

Does anybody has any idea?
Can someone push me to the right direction?
Is there any other way how to do this?

Thanks in advance


 
 
Pages: [1]