Hi everyone
This is my first post. I’m a newcomer to the world of microcontrollers but I’m very excited about the possibilities of integrating this platform with Flash and Processing.
I’m having some issues with the Ping))) Ultrasonic Range Sensor. I’m trying to send the signal from the sensor back into Flash but it just doesn’t seem to work. I’ve been to the playground and have downloaded the Glue classes (I’ve been using the example Flash files that came with Glue) and serproxy. Interms of sketches, I’ve tried Firmata, Arduino > Flash and Cuartielles’ code from
http://www.arduino.cc/en/Tutorial/UltrasoundSensor. I’ve even tried to combine some of them together! Cuartielles’ sketch is the only one which appears to make the sensor work (flashing LEDs that range in brightness depending upon proximity) but Flash is not picking this up
Currently I’m hooking up SIG on the sensor to the digital 7 pin although I have tried many other setups.
Here is my serproxy.cfg code:
Code:newlines_to_nils=false
comm_ports=3
comm_baud=57600
comm_databits=8
comm_stopbits=1
comm_parity=none
timeout=300
net_port3=5333
and here is my Actionscript – taken from the Glue examples files:
Code:import net.eriksjodin.arduino.Arduino;
import net.eriksjodin.arduino.events.ArduinoEvent;
import flash.events.Event;
var a:Arduino;
a = new Arduino("127.0.0.1", 5333);
a.addEventListener(Event.CONNECT,onSocketConnect);
a.addEventListener(Event.CLOSE,onSocketClose);
a.addEventListener(ArduinoEvent.FIRMWARE_VERSION, onReceiveFirmwareVersion);
a.addEventListener(ArduinoEvent.DIGITAL_DATA, onReceiveDigitalData);
a.addEventListener(ArduinoEvent.ANALOG_DATA, onReceiveAnalogData);
function onSocketConnect(e:Object):void {
trace("Socket connected");
// request the firmware version
a.requestFirmwareVersion();
}
function onSocketClose(e:Object):void {
trace("Socket closed");
}
function onReceiveAnalogData(e:ArduinoEvent):void {
//trace("Analog pin " + e.pin + " on port: " + e.port +" = " + e.value);
trace("analogue value = " + e.value);
var newX:Number = ( e.value - 10 ) / 10;
box_mc.scaleX -= ( box_mc.scaleX - newX ) / 8;
box_mc.scaleY -= ( box_mc.scaleY - newX ) / 8;
//var newY:Number = ( e.value - 10 ) * 80;
//box_mc.y -= (box_mc.y - newY) / 5
}
function onReceiveDigitalData(e:ArduinoEvent):void {
//trace("Digital pin " + e.pin + " on port: " + e.port +" = " + e.value);
trace("digital value = " + e.value);
}
function onReceiveFirmwareVersion(e:ArduinoEvent):void {
trace("Firmware version: " + e.value);
trace("Port: " + e.port);
initArduino();
}
function initArduino():void {
a.setPinMode(13, Arduino.OUTPUT);
a.writeDigitalPin(13, Arduino.HIGH);
a.setPinMode(6, Arduino.INPUT);
a.enableDigitalPinReporting();
a.setAnalogPinReporting(3, Arduino.ON);
a.setPinMode(11, Arduino.PWM);
a.writeAnalogPin(11, 255);
trace("Firmware version is: " + a.getFirmwareVersion());
trace("Analog pin 3 is: " + a.getAnalogData(3));
trace("Digital pin 4 is: " + a.getDigitalData(4));
}
I hope someone can help. Thanks in advance