The following is my code, it runs continuously to get data from the analog sensor.
In this coding, every 1 second, there will be 10 signal data.
Now, I have no clue on how to apply a loop, as it doesn't involve in addition of data,
just have to directly collect every 10 data = 1 input of next function (I am going to apply Neural Network, all the 10 data have to be the input of neural network). So, it is likely to have input = (10 data) and then I call the input in output=sim(net,input).
Thank you for your time, please leave me some advice on how can I work this out,
void setup()
{
Serial.begin(9600);
}
void loop()
{
int val;
val=analogRead(0);//Connect the sensor to analog pin 0
Serial.println(val,DEC);
delay(100);}
Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html .
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.
Try this;
int val;
void setup()
{
Serial.begin(9600);
}
void loop()
{
for ( int i = 0; i < 10; i = i + 1) //Reads ten values
{
val = analogRead(A0); //Read value from analog pin 0
delay(100);
}
Serial.println(val, DEC); //Prints the last value, which is the tenth reading.
}
int data_buffer[10];
void setup()
{
}
void loop()
{
for (int i = 0; i < 10; i++) {
int raw_value = analogRead(A0); //Read value from analog pin 0
data_buffer[i] = raw_value;
}
// IMPLEMENT THE CODE TO SEND DATA TO NEURAL NETWORK HERE
delay(1000);
}
Since you use the neural network, I think the data should be sent to PC or server. It may need to be pre-processed on Arduino to reduces workload for the server. You can convert the raw analog value to another meaningful value. See this tutorial
void loop()
{
for (int i = 0; i < 10; i++) {
int raw_value = analogRead(A0); //Read value from analog pin 0
data_buffer[i] = raw_value;
}
// IMPLEMENT THE CODE TO SEND DATA TO NEURAL NETWORK HERE
delay(1000);
}
Since you use the neural network, I think the data should be sent to PC or server. It may need to be pre-processed on Arduino to reduces workload for the server. You can convert the raw analog value to another meaningful value. See [this tutorial](https://arduinogetstarted.com/tutorials/arduino-potentiometer)
Yes my miss, wants all 10 readings sent as one.
But post #1 has been edited after my post, and it originally didn't read like that.
Tom...