mercredi 24 juin 2015

How to create delay/interval after receiving data from Arduino to Flash

I am working on both arduino and flash, I wanted to create a delay(like the timer function) when receiving data and display it in flash swf file.

I've successfully in displaying the data coming from arduino to flash, however, every time i pressed the pressure sensor, the data display in swf become clustered due to not having the interval/delay/timer function.

I've tried around and look through forums to get and idea but it unsuccesfull, I am relatively noob to action script 3.0, could anyone shed some light/guidance to what am I doing wrong?

Do I need to create seperate timer and create a new function and if so, how would I associate it with the "onTick2"?

Thank you.

a.addEventListener(ArduinoEvent.ANALOG_DATA, onTick2);

function onTick2(e:ArduinoEvent):void
{
  var forceValue:Number;
  var forceNum:Number;
  forceValue = a.getAnalogData(0); //this is the code to get the data from the sensor data in arduino
  forceNum = (forceValue/9.1);


  myFormat = new TextFormat();
  myFormat.font = "Arial";
  myFormat.size = 36;
  myFormat.color = 0xFFFFFF;

  myText = new TextField();
  myText.x = 250;
  myText.y = 240;
  myText.text ="\n"+forceNum.toString()+" Avg. Pressure";
  myText.height = 200;
  myText.width = 200;
  myText.defaultTextFormat = myFormat;

  addChild(myText);

}

Aucun commentaire:

Enregistrer un commentaire