Pages: [1]   Go Down
Author Topic: Serial.println  (Read 570 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Full Member
***
Karma: 0
Posts: 235
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi guys this my first post in this forum. i am a totally a newbie just starting out into the world of electronics. i had bought a arduino board couple of days back and was testing various functionalities...
well here is the problem...
I want to give a value to the arduino then  try to print that value in the serial monitor from the board(just trying... smiley) here is the code i wrote...

int a;
void setup()
{
   Serial.begin(9600);
}
void loop()
{
  if(Serial.available()>0)
    {  a=Serial.read();
       Serial.println(a);
    }
}


well everything works fine.... but whenever i give value in serial monitor , its ASCII value is being displayed... :-? i knw its ASCII value is the one to be displayed... but say if want it to print the same data i give in the same format... like if i give 1 it should show 1 and not 49...
and also say i gave a string "Arduino" it should print that...
can anyone plz tell me how i can do this???
Thanx in advance....
 smiley
Logged

Austin, TX USA
Offline Offline
God Member
*****
Karma: 4
Posts: 997
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

000,

Try this:

Serial.println(a, BYTE);

Mikal
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 235
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thanx mate it works....  smiley
Logged

Pages: [1]   Go Up
Jump to: