Forked from: Wasp's forked from: How to control a servo motor with an .. diff:1 forked from: forked from: How to control a servo motor with an Arduino board eruto forked:0favorite:0lines:30license : MIT License modified : 2011-09-16 03:29:55 Embed Tweet // forked from Wasp's forked from: How to control a servo motor with an Arduino board // forked from kotobuki's How to control a servo motor with an Arduino board // A very simple example to show how to use servos // NOTE: Arduino 0017 is requred to use servos // in StandardFirmata // // Output: // * A servo connected the D9 pin // // How to: // http://funnel.cc/Main/GettingStarted // // Reference: // http://funnel.cc/Software/ActionScript3 // http://funnel.cc/reference/actionscript3/ package { import flash.display.Sprite; import flash.events.TimerEvent; import flash.utils.Timer; import funnel.*; import funnel.ui.*; import funnel.gui.*; public class ArduinoServoTest extends Sprite { private const SERVO_PIN:int = 13; private var arduino:Arduino; private var servo:Servo; private var pulseGenerator:Timer; public function ArduinoServoTest() { var config:Configuration = Arduino.FIRMATA; config.setDigitalPinMode(SERVO_PIN, SERVO); arduino = new Arduino(config); servo = new Servo(arduino.digitalPin(SERVO_PIN)); var gui:ArduinoGUI = new ArduinoGUI(); addChild(gui); arduino.gui = gui; pulseGenerator = new Timer(1000); pulseGenerator.addEventListener(TimerEvent.TIMER, onPulse); pulseGenerator.start(); } private function onPulse(e:TimerEvent):void { var angle:Number = Math.random() * 180; servo.angle = angle; } } } Code Fullscreen Preview Fullscreen