Hi
im having a bit of a problem with getting my integers from my barcode scanner which is connected to my uno and making them appear on my as3 program. i have gotten them to link and have gotten them to send data back and fourth however the data iam getting isn't appearing the right way on my as3 code. i have attached pictures to help explain the problem i'am having.
the image called trace shows how the barcode characters are appearing when i run the as3 code and have the output as trace.
the image called text is where i want to display the characters but i only get the last digit of my barcode
i want to display all the barcode characters in the text section and this is where iam having the problem
so if anyone could help me i would like to say thanks
i have also attached the coding i have so far for both the arduino and as3
thank you
arduino :
const int BeeperPin = 11; // piezo beeper pin
byte serialin; // Serial data read in
byte linefeed=0; // for appending a linfeed so each barcode is on a new line
int bytesread = 0;
char code[13];
void setup() // standard arduino setup initializing loop
{
pinMode(BeeperPin, OUTPUT); // initialize Beeper output
tone(BeeperPin,2500,50); // beep at 2.5kHz for 20ms
delay(100);
tone(BeeperPin,2500,50); // beep at 2.5kHz for 20ms
Serial.begin(9600); // initialize the serial communication to 9600 baud
}
// Note that the barcode is aimed and triggered by a hardware switch
void loop() // standard arduino loop
{
while (Serial.available()) { // check for data from barcode scanner
serialin = Serial.read(); // read in barcode character at 9600 baud
Serial.write(serialin);
delay(10); // allow 1ms delay for next barcode character to be scanned in
linefeed = 1; // set so that whole barcode has a linefeed appended
}
if (linefeed>0) { // barcode has been full received
linefeed = 0;
tone(BeeperPin,2000,20); // beep at 2.5kHz for 20ms
}
}
as3 :
import flash.events.*;
import flash.net.Socket;
trace("__AS3 Example__");
var socket:Socket = new Socket("localhost",5331);
socket.addEventListener(ProgressEvent.SOCKET_DATA, socketDataHandler);
function socketDataHandler(event:ProgressEvent):void {
var value:String = String(socket.readUTFBytes(socket.bytesAvailable));
//trace(value);
boxtwo.text = value;
}