flash on 2013-8-20
ff
/**
* Copyright hyunseop ( http://wonderfl.net/user/hyunseop )
* GNU General Public License, v3 ( http://www.gnu.org/licenses/quick-guide-gplv3.html )
* Downloaded from: http://wonderfl.net/c/sLKF
*/
package {
import flash.display.Sprite;
import funnel.*;
import funnel.ui.*;
public class MeasureBrightness extends Sprite{
private var arduino:Arduino;
private var sensorPin:Pin;
private var led:LED;
public function MeasureBrightness(){
var config:Configuration=Arduino.FIRMATA;
config.setDigitalPinMode(9,PWM);
arduino = new Arduino(config);
sensorPin=arduino.analogPin(0);
led=new LED(arduino.digitalPin(9));
sensorPin.addFilter(new Scaler(0,1,1,0));
sensorPin.addEventListener(PinEvent.CHANGE,onChange);
}
private function onChange(e:PinEvent):void{
led.intensity=sensorPin.value;
}
}
}