Im pretty close to pulling my freaking hair out. It seemed like such a simple task, basic button. Using ground to send a signal on a digital input with a simple button. I have the standardF loaded on the board. Im using serproxy (no errors in serproxy) so I can access it in flash with as3 glue. At one point last night after 2 18 hour days of WTF why is this not working. It just started working, went to bed. Next morning I plugged the board into a second computer to test the code, it seemed to work better, I could not load the firmware version on my desktop in flash. But on my laptop it worked, however i could not set pins. wtf... plugged it back in to my desktop now its not working here either. 4 more hours of WTF tinkering, reloading fireware, drivers, same crap. When I open the serial monitar its garbled, but no combo of baud rates fixes it. I can write the blink sketch without issue thou and it never worked even when I was able to see my signals on the pins. I am at my wits end on this. Big issue one, when ever I use the controller when I shutdown i crash with the BUGCODE_USB_DRIVER on a bsod (win 7 x64) and the same thing happens on my laptop (win7 x64). As best I can tell I dont need the FTDI drivers thou i loaded the lastest ones anyway just to try it. When I look at the drivers in window its version: 5.1.2600.0 from 11/15/2007 i tried to update and all sorts of tricks but windows says this is the latest.
Please help. =(
This is my simple class for access the 2560
package elements
{
import com.greensock.*;
import com.greensock.easing.*;
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import net.eriksjodin.arduino.*;
import net.eriksjodin.arduino.events.*;
public class Controller extends Sprite
{
public var _tick:Timer;
public var _board:Arduino;
public var _pushed:Boolean = false;
public function Controller()
{
_tick = new Timer(50);
_tick.addEventListener(TimerEvent.TIMER, onTick);
_board = new Arduino("127.0.0.1", 5331);
_board.addEventListener(Event.CONNECT,onConnect);
_board.addEventListener(IOErrorEvent.IO_ERROR,onConnectError);
_board.addEventListener(ArduinoEvent.FIRMWARE_VERSION, onFirmware);
_board.addEventListener(ArduinoEvent.DIGITAL_DATA, trigger);
}
public function onConnect(e:Event):void
{
D.log("board connected" + e);
_board.enableDigitalPinReporting();
_board.writeDigitalPin(2, Arduino.HIGH);
_board.writeDigitalPin(3, Arduino.HIGH);
_board.writeDigitalPin(4, Arduino.HIGH);
_tick.start(); // tick not needed but keeping to monitor states
}
public function onConnectError(e:IOErrorEvent):void
{
D.log(e);
}
public function onFirmware(e:ArduinoEvent):void
{
D.log("Firmware loaded" + e);
}
public function trigger(e:ArduinoEvent):void {
D.log("Controller.trigger() " + e.pin + " = " + e.value);
if(e.value == 0){
switch(e.pin) {
case 2:
dispatchEvent(new ControllerEvent(ControllerEvent.PUSH, 1));
break;
case 3:
dispatchEvent(new ControllerEvent(ControllerEvent.PUSH, 2));
break;
case 4:
dispatchEvent(new ControllerEvent(ControllerEvent.PUSH, 3));
break;
}
}
}
public function onTick(e:TimerEvent):void {
var pin:int = _board.getDigitalData(2);
if (pin === 0) {
_pushed = true;
}
if (_pushed) {
D.log('*********************** '+pin);
}else {
D.log('x '+pin);
}
}
}
}