Hello:
I was wondering if any one in this forum would be willing to either share or sell me an actionscript code that would communicate with arduino uno making 6 different LEDs come ON (HIGH) individually and sequentially (one after the other). And if it can be made for a user selected number of seconds before it moves on to the next different LED that would be great. In other word before the next LED would come on the one previous would go OFF (LOW). Also, if possible allow the user to change the intensity of the lit LED. I know for some of you actionscript is really easy but I am new to all of this. If someone is willing to share a code that I could easily modify to my needs it would be immensily appreciated. I would even be very happy to send them a monitary gift. Thanks in advance and any help will be truly appreciated. Ocin1
A quick Google of "Flash serial port" seems to indicate that Flash (as in a browser object) can't access a serial port, which is the easiest way to communicate between an Arduino and a PC. There's a shim called serproxy you can use if you're developing a standalone app (e.g. Adobe Air); not sure if that's what you want.
You could probably do what you want with an Ethernet shield and having Flash communicate with it using network sockets. The Arduino code would be really simple; just read some network data and turn on/off some pins. You should be able to find lots of examples for that. The ActionScript code should also be pretty simple; Googling "actionscript network socket" has a ton of hits, including examples straight from Adobe.
Good luck!
Hi and thank you for the reply.
the thing about actionscript is so new to me and examples out there don't even show the pin it is controlling. I look in the scripts but see no pin pointing.
I got a music example to work great using serproxy but as i said i cannot figure how to change to multiple pins. Do you think using a ethernet shield would be easier? Sorry but I don't know much about that either. Thanks for any other suggestions. Also would you be intersted in putting together an actionscript to run two or three LEDs and then I can modify it to hopefully add more LEDs to the script. I would pay you through PayPal. Please let me know I am running out of time to finish this project. thanks.
Hi Ocin,
Sorry but I don't really know that much ActionScript. I did work with Flash about 10 years ago, but haven't done anything with it since then.
I'm pretty sure you'd be able to find someone to help you with the ActionScript coding in one of the Adobe forums, it seems like network access in Flash / AIR would be pretty common (e.g. database access).
Good luck!
HI-
you would mainly want to look to see if ActionScript 3.0 examples will work for you.
As ActionScript 2.0 has NO default capabilities to do what you ask.
You dont see any pinout stuff in Flash cause it doesnt fit/belong there..
I think there are some proxy/3rd party stuff that may work as a go-between.. ASglue? (off the top of my head)
Flash (AS2 at least) can NOT talk directly to databases either.. needing some sort of server side scripting to work.. (ie: ASP, PHP..etc)
I am fairly well versed in AS2 (havent made the jump to 3.0 though)..
so if you have something that needs to be looked at, post it.
Hi guys I appreciate both of your suggestions but I have posted the same thing on adobe's forum and no replies. I guess one is supposed to be a programmer to get any help in that forum. I have been pretty good in getting arduino with processing to work. Don't misunderstand me the ones I got to work are all examples. I also got one music example to work using adobe flash actionscript with the arduino, Firmata, and serproxy. As I said to my earlier post the adobe actionscript 3 has nothing I know to look for to change pins. So I guess I am out of luck in making flash/actionscript to work with this project.
Here is the script from Manual Gonzales that I got it to work using an mp3 file and playing the file in actionscript with my PC connected to the arduino by USB and taping on Pin 2. When I look at this code there is nothing that appears like I could change and make LEDs come on and off. Here is
Gonzales actionscript:
/******************
- Manuel Gonzalez *
- Coding Color *
-
www.stheory.com *
*******************/
package {
import flash.display.MovieClip;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundMixer;
import net.eriksjodin.arduino.Arduino;
import net.eriksjodin.arduino.events.ArduinoEvent;
import net.eriksjodin.arduino.events.ArduinoSysExEvent;
import flash.utils.getDefinitionByName;
import flash.events.Event;
public class Prototype_1 extends MovieClip {
private var _arduino:Arduino;
private var _soundArray:Array=new Array("nico");
private var _currSound:Object;
private var _currChannel:SoundChannel;
private var numEvents:Number=0;
public function Prototype_1() {
initArduino();
}
private function initArduino():void {
_arduino=new Arduino("127.0.0.1",5331);
_arduino.addEventListener(Event.CONNECT,onSocketConnect);
_arduino.addEventListener(Event.CLOSE,onSocketClose);
_arduino.addEventListener(ArduinoEvent.FIRMWARE_VERSION, onReceiveFirmwareVersion);
_arduino.addEventListener(ArduinoEvent.DIGITAL_DATA, onReceiveDigitalData);
}
private function onSocketConnect(e:Object):void {
trace("Socket connected!");
_arduino.requestFirmwareVersion();
}
private function onSocketClose(e:Object):void {
trace("Socket closed!");
}
private function onReceiveDigitalData(e:ArduinoEvent):void {
updateApp({pin:e.pin,val:e.value});
}
private function updateApp(in_obj:Object):void {
trace("updateApp pin: " + in_obj.pin + " val " + in_obj.val);
switch (in_obj.pin) {
case 2 :
if (in_obj.val==1) {
startSound();
} else if (in_obj.val == 0) {
stopSound();
}
break;
}
}
private function onReceiveFirmwareVersion(e:ArduinoEvent):void {
trace("Firmware version: " + e.value);
if (int(e.value)!=2) {
trace("Unexpected Firmware version encountered! This Version of as3glue was written for Firmata2.");
} else {
setUpArduino();
startSound();
}
}
private function setUpArduino():void {
_arduino.enableDigitalPinReporting();
_arduino.setPinMode(2, Arduino.INPUT);
}
private function startSound():void {
var theSound:Class=getDefinitionByName(_soundArray[0]) as Class;
_currSound =new theSound();
_currChannel=_currSound.play(0,999);
}
private function stopSound():void {
flash.media.SoundMixer.stopAll();
}
}
}
these two functions look to be dealing with pin(s)
private function onReceiveDigitalData(e:ArduinoEvent):void {
updateApp({pin:e.pin,val:e.value});
}
private function updateApp(in_obj:Object):void {
trace("updateApp pin: " + in_obj.pin + " val " + in_obj.val);
switch (in_obj.pin) {
case 2 :
if (in_obj.val==1) {
startSound();
} else if (in_obj.val == 0) {
stopSound();
}
break;
}
}
maybe take a peek in these class files too?
import net.eriksjodin.arduino.Arduino;
import net.eriksjodin.arduino.events.ArduinoEvent;
import net.eriksjodin.arduino.events.ArduinoSysExEvent;
import flash.utils.getDefinitionByName;