Go Down

Topic: 2+ potentiometers in flash (Read 604 times) previous topic - next topic


hey guys, using firmata, have 2 potentiometers,
and CODE is reading from 2 inputs

BUT when i only connect one[or interact with one], the code changes values for both variables.
[so i move one potentiometers, the code reacts as if im moving both - simultaneously]

Code: [Select]

import net.eriksjodin.arduino.Arduino;
import net.eriksjodin.arduino.events.ArduinoEvent;
import flash.events.MouseEvent;
import flash.events.Event;

//var ledPin:Number = 11;
var inputPin:Number =0;
var arduino:Arduino = new Arduino("", 5331);

//var pwmValue:Number=0;

function onReceiveAnalogData(e:ArduinoEvent):void {
     if(e.pin==0) {
           //pwmValue = 255-Math.round(e.value/4.0);
           label.text = (e.value).toString();

//arduino.setPinMode(ledPin, Arduino.PWM);
arduino.setAnalogPinReporting(inputPin, Arduino.ON);
arduino.addEventListener(ArduinoEvent.ANALOG_DATA, onReceiveAnalogData);

function onReceiveAnalogDatax(ef:ArduinoEvent):void {
     if(ef.pin==5) {
           //pwmValue = 255-Math.round(e.value/4.0);
           label2.text = (ef.value).toString();

arduino.setAnalogPinReporting(5, Arduino.ON);
arduino.addEventListener(ArduinoEvent.ANALOG_DATA, onReceiveAnalogDatax);

Go Up