Array, DAC

Hi there

Im reciving float data from a sensor. I would like to plot the recived data simultaneously or all most, through the DAC.

So I thought of using an array. My problem is I think to get the Data out of the array I would need a for loop but I have to compare a variable to somthing like max value in the array or min. value bit I dont know how
Can someone help me this is my e.g. code

float Sensor_Value[];// values will be recived from a senosr it should me plotted simultaneously


void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

for (int i=0; i<???;i++){ // Do I have to compare it to something to get my data plotted ?

  if (Sensor_Value[i]>????)
  { //????}
  analogWriteResolution (12); // DAC resolution

  analogWrite(DAC0,Sensor_Value[i]);
  
}
float Sensor_Value[];// values will be recived from a senosr it should me plotted simultaneously

How many elements can this array hold? Any answer except 0 is wrong.

And, of course, 0 isn't a useful answer, either.

  analogWriteResolution (12); // DAC resolution

How many times do I have to tell you that you only need to do this once?

Where, EXACTLY, are you plotting this data?

Hi thanks for yor reply

float Sensor_Value;// values will be recived from a senosr it should me plotted simultaneously

How many elements can this array hold? Any answer except 0 is wrong.

And, of course, 0 isn’t a useful answer, either.

Well im getting the data from the senosr so I dont really know how many data I will recive this is why I wanted to make it dynamic.

Where, EXACTLY, are you plotting this data?

@ Oscilloscpe

Well im getting the data from the senosr so I dont really know how many data I will recive this is why I wanted to make it dynamic.

This does not make sense. You damned well ought to know how much data you get from a sensor. At a minimum, you need to know that there will be a maximum of n bytes, so you can size the array appropriately.

There is nothing in the code you posted that suggests that you are READING data. It looks like you are SENDING data that you don't have from an array that can't hold any data.

There is nothing in the code you posted that suggests that you are READING data. It looks like you are SENDING data that you don't have from an array that can't hold any data.

yeah the code I posted is just an example.

So I will try to explain my "problem" again

I recive float values from a senosr those values will be caclculated to other values and the result of this caluclation I will call it float Sensor_Value

Now I want to use my DAC and an oscilloscope to plot the date of this value Sensor_Value so I though of an array or how can I plot them ?

Don't cross post thanks.

Threads merged.

I recive float values from a senosr those values will be caclculated to other values and the result of this caluclation I will call it float Sensor_Value

Why? You should be calling the result pinkElephants. The sensor value gets turned into something else, so storing the result in Sensor_Value does not make sense.

Now I want to use my DAC and an oscilloscope to plot the date of this value Sensor_Value so I though of an array or how can I plot them ?

Using the DAC and a silly scope is fine. Thinking you can just tell the Arduino that the array exists isn't. You MUST provide a size. Then, you read and store values until the array is full. Then, you send the data.

Or, you send each value as it is read and manipulated, and don't bother with an array.

Does this make sense ?

Does it even compile? If not, and I'm positive that it does not, then, no.