Go Down

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

antigirl

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("127.0.0.1", 5331);

//var pwmValue:Number=0;

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


//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);
           //arduino.writeAnalogPin(ledPin,pwmValue);
           label2.text = (ef.value).toString();
     }
}

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

Go Up