Mixed analog and digital ins
* Connect analog sensors (such as potentiometers) to A0/2/4
* Connect digital sensors (such as tactile switches) to A1/3/5
/**
* Copyright kotobuki ( http://wonderfl.net/user/kotobuki )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/mdEG
*/
package {
import flash.display.Sprite;
import flash.events.Event;
import funnel.*;
import funnel.gui.*;
[SWF(backgroundColor="0x888888")]
public class FlashTest extends Sprite {
private const NUM_CHANNELS:int = 3;
private var arduino:Arduino;
private var scopes:Array;
public function FlashTest() {
// Configure A1/3/5 as digital inputs
var config:Configuration = Arduino.FIRMATA;
config.setDigitalPinMode(15, IN);
config.setDigitalPinMode(17, IN);
config.setDigitalPinMode(19, IN);
arduino = new Arduino(config);
var gui:ArduinoGUI = new ArduinoGUI();
addChild(gui);
arduino.gui = gui;
scopes = new Array(NUM_CHANNELS);
for (var i:int = 0; i < NUM_CHANNELS; i++) {
// Instantiate SignalScopes A0/2/4
scopes[i] = new SignalScope(0, 61 + (53 * i), 200, "A" + (i * 2));
addChild(scopes[i]);
}
addEventListener(Event.ENTER_FRAME, loop);
}
private function loop(event:Event):void {
// Update SignalScopes for A0/2/4
for (var i:int = 0; i < NUM_CHANNELS; i++) {
scopes[i].update(arduino.analogPin(i * 2));
}
}
}
}