We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Convert variable of type byte to Interger
Poll Poll
Question: Help me if you can please !!



« Created by: dexter on: Sep 14th, 2009, 3:31pm »

Page Index Toggle Pages: 1
Convert variable of type byte to Interger (Read 586 times)
Convert variable of type byte to Interger
Sep 14th, 2009, 3:31pm
 
Help me if you can please

How do I convert a variable of type byte to integer.
I am using Arduino and must capture data from serial port and stored in a variable to work. But the data comes from the serial port type byte.

Thanks

My code is

import processing.serial.*;

Serial myPort;

void setup() {
 
 println(Serial.list());

 myPort = new Serial(this, Serial.list()[0], 9600);
 
}

void draw()
{
 
 byte[] inBuffer = new byte[7];
 while (myPort.available() > 0)
 {
   inBuffer = myPort.readBytes();
   myPort.readBytes(inBuffer);
   if (inBuffer != null) {
     String myString = new String(inBuffer);
     print(myString);
     
     
   }
 }
         
}
Page Index Toggle Pages: 1