hello everyone, i am trying to transmit the analog input data to matlab. i am able to receive the data in matlab too, but even after the analog input is changed the data read in matlab doesnot change. i tried the same using serial monitor it worked perfectly. pls help me to solve this problem. here is the sketch of my project.
int analogInPin1 = A0;
int analogInPin2 = A1;
int analogInPin3 = A2;
int analogInPin4 = A3;
int analogInPin5 = A4;
int analogInPin6 = A5;
int sensorValue1 = 0;
int sensorValue2 = 0;
int sensorValue3 = 0;
int sensorValue4 = 0;
int sensorValue5 = 0;
int sensorValue6 = 0;
int outputValue1 = 0;
int outputValue2 = 0;
int outputValue3 = 0;
int outputValue4 = 0;
int outputValue5 = 0;
int outputValue6 = 0;
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
pinMode(2,INPUT);
}
void loop() {
// read the analog in value:
if(Serial.available() > 0)
{
sensorValue1 = analogRead(analogInPin1);
sensorValue2 = analogRead(analogInPin2);
sensorValue3= analogRead(analogInPin3);
sensorValue4 = analogRead(analogInPin4);
sensorValue5 = analogRead(analogInPin5);
sensorValue6 = analogRead(analogInPin6); // map it to the range of the analog out:
outputValue1 = map(sensorValue1, 0, 1023, 0, 255);
outputValue2 = map(sensorValue2, 0, 1023, 0, 255);
outputValue3 = map(sensorValue3, 0, 1023, 0, 255);
outputValue4 = map(sensorValue4, 0, 1023, 0, 255);
outputValue5 = map(sensorValue5, 0, 1023, 0, 255);
outputValue6 = map(sensorValue6, 0, 1023, 0, 255); // change the analog out value:
for(int i=0;i<30;i++)
{
Serial.println(outputValue1);
delay(100);
Serial.println(outputValue2);
delay(100);
Serial.println(outputValue3);
delay(100);
Serial.println(outputValue4);
delay(100);
Serial.println(outputValue5);
delay(100);
Serial.println(outputValue6);
delay(100);
}
}
}