Hi,
I connected my arduino with flash with the serproxy (stefano busti) and when I’m starting my swf, it works. But in my flash file I have different buttons. These buttons only say: gotoAndStop(other frame). The data communication works only as long I’m in the first frame. Even if I try to integrate the communication code from the first frame in the other frames it doesn’t start again. The serproxy sais:
Server <3> - thread started
Server <3> - EOF from sock
Server <3> exiting
This ist the code of my test file.
//Define the host, "localhost" means you run it on your local Computer
Host = "localhost";
//this is the Portnumber for USB Port, has to be defined in serproxy.cfg
Port = 5333;
// Create new XML Socket Connection
socket = new XMLSocket();
//start the connection when frame is loaded
this.onLoad = function() {
_root.socket.connect(_root.Host,_root.Port);
};
//this Method gets the Data from the socket
XMLSocket.prototype.onData = function(src) {
Use(src);
};
//Function MoveIt, do something with the data
function Use(myString) {
//cut the last digit from the string
//myString = myString.substring(myString);
//move the picture
myString = parseInt(myString); // Ganzzahlen
rechteck._x = 145 + myString;
//print the value
trace(myString);
}
What is wrong that the connection is interrupted?
The other problem I have is that I have connected three potentiometers on port 1, 3 and 5. The arduino has the following code:
int potPin1 = 1; // select the input pin for the potentiometer
int val1 = 0; // variable to store the value coming from the sensor
int potPin3 = 3; // select the input pin for the potentiometer
int val3 = 0; // variable to store the value coming from the sensor
int potPin5 = 5; // select the input pin for the potentiometer
int val5 = 0; // variable to store the value coming from the sensor
void setup() {
// open the serial port at 9600 bps:
Serial.begin(9600);
}
void loop() {
val1 = analogRead(potPin1); // read the value from the sensor
Serial.println(val1); // print as an ASCII-encoded decimal
val3 = analogRead(potPin3); // read the value from the sensor
Serial.println(val3); // print as an ASCII-encoded decimal
val5 = analogRead(potPin5); // read the value from the sensor
Serial.println(val5); // print as an ASCII-encoded decimal
//delay(val); // stop the program for some time
}
I’m storing the three sensors in three variables. Is there a possibility to get these three variables in Flash? At the moment Flash gives me the values in the form: val1 val3 val5 val1 val3 val5…
Is there somebody who can help me?
Janas