GY-63_MS5611/libraries/Complex/examples/array/array.ino

60 lines
936 B
Arduino
Raw Normal View History

//
// FILE: array.ino
// AUTHOR: Rob Tillaart
2021-10-19 13:44:42 -04:00
// VERSION: 0.1.0
// DATE: 2015-10-18
//
// PUPROSE: example complex array
//
2021-10-19 13:44:42 -04:00
#include "Complex.h"
Complex samples[100];
2021-10-19 13:44:42 -04:00
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
2021-10-19 13:44:42 -04:00
Serial.print("\n Complex numbers array example: ");
Serial.println(COMPLEX_LIB_VERSION);
Serial.println("\n1. Read into array");
for (int i = 0; i < 100; i++)
{
float re = analogRead(A0) / 1023.0;
float im = analogRead(A1) / 1023.0;
samples[i].set(re, im);
}
Serial.println("\n2. Print array");
for (int i = 0; i < 100; i++)
{
if (i % 5 == 0) Serial.println();
Serial.print(samples[i]);
Serial.print("\t");
}
Serial.println();
Serial.println("\n3. Sum array");
Complex sum;
for (int i = 0; i < 100; i++)
{
sum += samples[i];
}
Serial.println(sum);
Serial.println("\n done");
}
2021-12-14 09:48:21 -05:00
void loop()
{
}
2021-12-14 09:48:21 -05:00
// -- END OF FILE --