Hi. I am trying to do something very simple using flash with actionscript 3 to control my arduino uno through the Arduino 0022 IDE.
I am simply trying to send a character to my board from my flash program which is routed through Serproxy but although I am getting the blinking light telling me data is being sent through the serial to my arduino, the code is not being executed.
I am using the slightly modified sample software "physical pixel" to test this:
const int ledPin = 13; // the pin that the LED is attached to
int incomingByte; // a variable to read incoming serial data into
void setup() {
// initialize serial communication:
Serial.begin(9600);
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
}
void loop() {
// see if there's incoming serial data:
if (Serial.available() > 0) {
// read the oldest byte in the serial buffer:
incomingByte = Serial.read();
if (incomingByte == 1) {
digitalWrite(ledPin, HIGH);
}
if (incomingByte == 0) {
digitalWrite(ledPin, LOW);
}
}
}
here is the as3 code i am trying to use:
import flash.net.Socket;
import flash.events.*;
var socket:Socket = new Socket("127.0.0.1", 5331);
button.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame);
function fl_ClickToGoToAndStopAtFrame(event:MouseEvent):void
{
socket.writeInt(1);
}
As you can see it is rather simple yet the arduino doesn't seem to recognise my commands. I have tried getting it to respond by removing the if stamemnt and that works so it must be something to do with the parsing.
any help would be massively appreciated.
Dan.