I have an Arduino Micro, 2 XBee S1's, one FSR sensor. I am using MatLab and Arduino 1.0.5 for coding. I want to be able to get the pressure sensor values transmitted wireless, using the XBees, to the PC. So it would go as follows: Pressure Sensor >> Arduino Micro>> Xbee S1 >> XBee S1 >> PC. This is my coding for the arduino program 1.0.5 :
//initializing variables
int mode =-1;
//define where the pins are connected
int value;
void setup()
{
//initialize serial communications at 9600 bps
Serial.begin(9600);
//check serial communication - acknowledgement routine
Serial.println('a');
char a = 'b';
while (a!='a')
{
//wait for a specific character from the pc
a=Serial.read();
}
}
void loop()
{
if (Serial.available()>0) //check if any data has been sent by the PC
{
mode=Serial.read(); //check if there is a request for any data
switch(mode) //used to set different modes for various operations. F is used to read values
{
case 'F': //Force sensor
value= analogRead(A0); //sensor connected to A0
Serial.println(value); //send value over Serial
break;
}
}
}
And now I want to make some type of coding in MatLab, to create some type of handshake between all the devices and both programs. I need someone to help me on this! smiley-confuse smiley-confuse
Moderator edit:
</mark> <mark>[code]</mark> <mark>
</mark> <mark>[/code]</mark> <mark>
tags added.