HOW TO SEND / RECEIVE STRINGS between FLASH AND ARDUINO ?
I d like to pass a number (id) to the arduino attached to this computer
so this id could spread via XBee to another arduino which needs this number
to response with a string.
Dozo, See the code where HELP is NEEDED.
♥0 |
Line 23 |
Modified 2009-11-16 03:02:33 |
MIT License
archived:2017-03-10 09:49:33
ActionScript3 source code
/**
* Copyright bontempos ( http://wonderfl.net/user/bontempos )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/xN0W
*/
// I d like to pass a number (id) to the arduino attached to this computer
// so this id could spread via XBee to another arduino which needs this number
// to response with a string.
// Dozo, See the code where HELP is NEEDED.
package {
import flash.utils.Timer;
import flash.display.Sprite;
import flash.events.Event;
import funnel.*;
public class FlashTest extends Sprite {
private var arduino:Arduino;
public function FlashTest() {
// PASS THIS NUMBER VIA XBee (the XBee part is working ok)
var id:uint = 11; //could be any number...
//PASS THE NUMBER AT EACH SECOND (LOOPING)
var intervalo:Timer = new Timer(1000);
intervalo.start();
intervalo.addEventListener(TimerEvent.TIMER,sendID);
// ???? HELP IS NEEDED HERE
function sendID(e:Event):void{
// I mean arduino to keep sending this ID number to serial as if I had programed:
// void loop(){
// Serial.print(id)
// }
// in Arduino itself.
arduino.sendString(id); //<----------------- this is invention
//call the function to retrive the string from serial
getString();
}
// ???? HELP IS NEEDED HERE
// arduino will receive strings from serial after succefully send an ID number to serial
// it is a string like this: "12,14,102332,"
function getString():void{
var response:String = arduino.serialRead(); //<----------------- this is invention
// ...and trace it;
trace(response); //it should trace ("12,14,102332") each time there is available data at serial;
//I dont even know if firmata is really needed since all I want is to retrive strings from serial to flash.
}
}
}
}