2015-03-06 17:34:37 -05:00
|
|
|
//
|
|
|
|
// FILE: radarDemo.ino
|
|
|
|
// AUTHOR: Rob Tillaart
|
2020-11-27 05:33:55 -05:00
|
|
|
// VERSION: 0.1.1
|
|
|
|
// PURPOSE: demo of the radar library
|
|
|
|
// DATE: 29-03-2015
|
|
|
|
// URL: https://github.com/RobTillaart/RADAR
|
2015-03-06 17:34:37 -05:00
|
|
|
|
|
|
|
#include "radar.h"
|
|
|
|
|
2020-11-27 05:33:55 -05:00
|
|
|
uint32_t del = 150;
|
2015-03-06 17:34:37 -05:00
|
|
|
|
|
|
|
RADAR radar(10, 11);
|
|
|
|
|
|
|
|
void setup()
|
|
|
|
{
|
|
|
|
Serial.begin(115200);
|
|
|
|
Serial.print("Start radarDemo, lib version: ");
|
|
|
|
Serial.println(RADAR_LIB_VERSION);
|
|
|
|
Serial.println();
|
|
|
|
|
2020-11-27 05:33:55 -05:00
|
|
|
test1();
|
|
|
|
test2();
|
|
|
|
test3();
|
|
|
|
test4();
|
|
|
|
test5();
|
|
|
|
test6();
|
|
|
|
test7();
|
|
|
|
|
|
|
|
gohome();
|
|
|
|
Serial.println();
|
|
|
|
Serial.print(millis());
|
|
|
|
Serial.println("\tdone...");
|
|
|
|
}
|
|
|
|
|
|
|
|
void loop()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void test1()
|
|
|
|
{
|
2015-03-06 17:34:37 -05:00
|
|
|
Serial.print(millis());
|
|
|
|
Serial.println("\t1. home position");
|
|
|
|
radar.setHomePosition(0, 0);
|
|
|
|
radar.gotoHomePosition();
|
|
|
|
wait();
|
2020-11-27 05:33:55 -05:00
|
|
|
}
|
2015-03-06 17:34:37 -05:00
|
|
|
|
2020-11-27 05:33:55 -05:00
|
|
|
void test2()
|
|
|
|
{
|
2015-03-06 17:34:37 -05:00
|
|
|
Serial.print(millis());
|
|
|
|
Serial.println("\t2. gotoPan 20");
|
|
|
|
radar.gotoPan(20);
|
|
|
|
wait();
|
|
|
|
Serial.println();
|
2020-11-27 05:33:55 -05:00
|
|
|
}
|
2015-03-06 17:34:37 -05:00
|
|
|
|
2020-11-27 05:33:55 -05:00
|
|
|
void test3()
|
|
|
|
{
|
2015-03-06 17:34:37 -05:00
|
|
|
Serial.print(millis());
|
|
|
|
Serial.println("\t3. gotoTilt 60");
|
|
|
|
radar.gotoTilt(60);
|
|
|
|
wait();
|
|
|
|
Serial.println();
|
2020-11-27 05:33:55 -05:00
|
|
|
}
|
2015-03-06 17:34:37 -05:00
|
|
|
|
2020-11-27 05:33:55 -05:00
|
|
|
void test4()
|
|
|
|
{
|
2015-03-06 17:34:37 -05:00
|
|
|
Serial.print(millis());
|
|
|
|
Serial.println("\t4. gotoPanTilt 60 20");
|
|
|
|
radar.gotoPanTilt(60, 20);
|
|
|
|
wait();
|
|
|
|
Serial.println();
|
2020-11-27 05:33:55 -05:00
|
|
|
}
|
2015-03-06 17:34:37 -05:00
|
|
|
|
2020-11-27 05:33:55 -05:00
|
|
|
void test5()
|
|
|
|
{
|
2015-03-06 17:34:37 -05:00
|
|
|
Serial.print(millis());
|
|
|
|
Serial.println("\t5. home position");
|
|
|
|
radar.gotoHomePosition();
|
|
|
|
wait();
|
|
|
|
Serial.println();
|
2020-11-27 05:33:55 -05:00
|
|
|
}
|
2015-03-06 17:34:37 -05:00
|
|
|
|
2020-11-27 05:33:55 -05:00
|
|
|
void test6()
|
|
|
|
{
|
2015-03-06 17:34:37 -05:00
|
|
|
Serial.print(millis());
|
|
|
|
Serial.println("\t6. setPosition");
|
|
|
|
for (int i = 0; i < 10; i++)
|
|
|
|
{
|
|
|
|
radar.setPosition(i, random(90), random(90));
|
|
|
|
}
|
|
|
|
Serial.println();
|
2020-11-27 05:33:55 -05:00
|
|
|
}
|
2015-03-06 17:34:37 -05:00
|
|
|
|
2020-11-27 05:33:55 -05:00
|
|
|
void test7()
|
|
|
|
{
|
2015-03-06 17:34:37 -05:00
|
|
|
Serial.print(millis());
|
|
|
|
Serial.println("\t7. gotoPosition");
|
|
|
|
for (int i = 0; i < 10; i++)
|
|
|
|
{
|
|
|
|
radar.gotoPosition(i);
|
2020-11-27 05:33:55 -05:00
|
|
|
int16_t p, t;
|
|
|
|
radar.getPosition(i, p, t);
|
2015-03-06 17:34:37 -05:00
|
|
|
Serial.print(millis());
|
|
|
|
Serial.print("\t");
|
|
|
|
Serial.print(i);
|
|
|
|
Serial.print("\t");
|
|
|
|
Serial.print(p);
|
|
|
|
Serial.print("\t");
|
|
|
|
Serial.println(t);
|
|
|
|
|
|
|
|
wait();
|
|
|
|
Serial.println();
|
|
|
|
}
|
2020-11-27 05:33:55 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void gohome()
|
|
|
|
{
|
2015-03-06 17:34:37 -05:00
|
|
|
Serial.print(millis());
|
2020-11-27 05:33:55 -05:00
|
|
|
Serial.println("\tgo home position");
|
2015-03-06 17:34:37 -05:00
|
|
|
radar.gotoHomePosition();
|
|
|
|
wait();
|
|
|
|
Serial.println();
|
|
|
|
}
|
|
|
|
|
|
|
|
void wait()
|
|
|
|
{
|
2020-11-27 05:33:55 -05:00
|
|
|
Serial.println("\nTIME\t\tPAN\tTILT");
|
2015-03-06 17:34:37 -05:00
|
|
|
do
|
|
|
|
{
|
|
|
|
Serial.print(millis());
|
|
|
|
Serial.print("\t*\t");
|
2020-11-27 05:33:55 -05:00
|
|
|
Serial.print(radar.getPan());
|
2015-03-06 17:34:37 -05:00
|
|
|
Serial.print("\t");
|
2020-11-27 05:33:55 -05:00
|
|
|
Serial.println(radar.getTilt());
|
2015-03-06 17:34:37 -05:00
|
|
|
delay(del);
|
|
|
|
} while (radar.isMoving());
|
2020-11-27 05:33:55 -05:00
|
|
|
Serial.print(millis());
|
|
|
|
Serial.print("\t*\t");
|
|
|
|
Serial.print(radar.getPan());
|
|
|
|
Serial.print("\t");
|
|
|
|
Serial.println(radar.getTilt());
|
2015-03-06 17:34:37 -05:00
|
|
|
}
|
2020-11-27 05:33:55 -05:00
|
|
|
|
|
|
|
// -- END OF FILE --
|