Go Down

Topic: As3 to Arduino. (Read 2 times) previous topic - next topic


Okay. Basically I have a series of lights and a servo motor hooked up to my circuit. I want to be able to activate these individually from my computer and so need to be able to send unique commands over serial (via serproxy) to do so.
What the command is is not important so I just used the number one to test it.
I'm not sure I understand what you mean about the mouse position. I have used the mouseEvent purely as a means to send the command.
The if statements in the arduino code have been able to decode commands when I send them over the serial monitor in the arduino application but never over flash. This is the problem.
So I'm thinking that if I can send commands over serial via the serial monitor I need to format them the same as the serial monitor. Any idea how this might be done?
I just need to send over the data which my arduino is looking for in its if statement so it can execute the relevant code.
I hope that makes things slightly clearer...?


in all my as3 code talking to the socket i use    socket.flush(); to be sure its flushed the socket and sent the data

like mentioned above i would stick to just sending bytes as commands. 0-255

then on the arduino i would have a switch statement for each command sorta like

  if (Serial.available() > 0)
     // read byte in
     byte inByte = Serial.read();
     switch (inByte){
       case 0:
         // first command
       case 1:
         // second command
       case 2:
         // third command


Hi. The case command will work very well for my needs once I get it to recognise what I send.I tried the code you suggested and it did not work until I added quotations. (I was testing this in the serial monitor by the way)
So what does this mean? The arduino will only look for strings? So now I just need to send a string in the same format that the arduino recognises which is ascii right? What would be the correct method to format the socket payload correctly? I have tried WriteByte and this doesnt seem to work...
Thank you again for any help.


HAHA!!!!!! Ive bloomin done it I tells ya!! Basically I had the darn comm baud rate in the config file of serproxy set wrong. I synchronised that with my arduino program and sent the ascii number of the command in a writeByte method (72 for H). Phew, that was beginning to worry me. Cheers for all the help guys.


i was about to say, the ardunio serial is just a basic UART it just sends/receives bytes simple bytes 0-255 lol

so flash socket.writeByte() should be ideal!

Go Up