2015-10-18 06:22:28 -04:00
|
|
|
//
|
|
|
|
// FILE: array.ino
|
|
|
|
// AUTHOR: Rob Tillaart
|
2021-10-19 13:44:42 -04:00
|
|
|
// VERSION: 0.1.0
|
2015-10-18 06:22:28 -04:00
|
|
|
// DATE: 2015-10-18
|
|
|
|
//
|
|
|
|
// PUPROSE: example complex array
|
|
|
|
//
|
|
|
|
|
2021-10-19 13:44:42 -04:00
|
|
|
|
2018-01-25 04:35:37 -05:00
|
|
|
#include "Complex.h"
|
2015-10-18 06:22:28 -04:00
|
|
|
|
|
|
|
Complex samples[100];
|
|
|
|
|
2021-10-19 13:44:42 -04:00
|
|
|
|
2015-10-18 06:22:28 -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: ");
|
2015-10-18 06:22:28 -04:00
|
|
|
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
|
|
|
|
2015-10-18 06:22:28 -04:00
|
|
|
void loop()
|
|
|
|
{
|
|
|
|
}
|
2021-12-14 09:48:21 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// -- END OF FILE --
|
|
|
|
|