Go Down

Topic: Arduino chattin' to flash. (Read 1 time) previous topic - next topic


Hello. I have managed to get flash to talk to my arduino using serproxy. Now I need to get my arduino to talk to flash.
I have tried using the Serial.write(); arduino command to broadcast when a button has been pressed on the arduino. Now I need to get flash to read this command.
How would I go about doing this?
This Is the code I have so far for both arduino and flash.

Code: [Select]

const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin

// variables will change:
int buttonState = 0; 

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);     
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT); 

void loop(){
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {     
    // turn LED on:   
    digitalWrite(ledPin, HIGH);
    Serial.write("A") ;
  else {
    // turn LED off:
    digitalWrite(ledPin, LOW);

Flash As3:
Code: [Select]
import flash.net.Socket;
import flash.events.*;
import flash.utils.ByteArray;

var socket:Socket = new Socket("", 5331);

var socketholder = socket.readUTFBytes(socket.bytesAvailable);

socket.addEventListener( ProgressEvent.SOCKET_DATA, dataReceived );

function dataReceived ( pEvt:ProgressEvent ):void

if (socketholder == "A"){


button.addEventListener(MouseEvent.CLICK, turn_on);

function turn_on(event:MouseEvent):void{

if (socketholder == "B"){
trace("also wehey!");

Thank you in advance for any help which may be given.

Go Up