GY-63_MS5611/libraries/Radar/examples/radarDemo/radarDemo.ino

147 lines
2.4 KiB
Arduino
Raw Normal View History

//
// 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
#include "radar.h"
2020-11-27 05:33:55 -05:00
uint32_t del = 150;
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()
{
Serial.print(millis());
Serial.println("\t1. home position");
radar.setHomePosition(0, 0);
radar.gotoHomePosition();
wait();
2020-11-27 05:33:55 -05:00
}
2020-11-27 05:33:55 -05:00
void test2()
{
Serial.print(millis());
Serial.println("\t2. gotoPan 20");
radar.gotoPan(20);
wait();
Serial.println();
2020-11-27 05:33:55 -05:00
}
2020-11-27 05:33:55 -05:00
void test3()
{
Serial.print(millis());
Serial.println("\t3. gotoTilt 60");
radar.gotoTilt(60);
wait();
Serial.println();
2020-11-27 05:33:55 -05:00
}
2020-11-27 05:33:55 -05:00
void test4()
{
Serial.print(millis());
Serial.println("\t4. gotoPanTilt 60 20");
radar.gotoPanTilt(60, 20);
wait();
Serial.println();
2020-11-27 05:33:55 -05:00
}
2020-11-27 05:33:55 -05:00
void test5()
{
Serial.print(millis());
Serial.println("\t5. home position");
radar.gotoHomePosition();
wait();
Serial.println();
2020-11-27 05:33:55 -05:00
}
2020-11-27 05:33:55 -05:00
void test6()
{
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
}
2020-11-27 05:33:55 -05:00
void test7()
{
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);
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()
{
Serial.print(millis());
2020-11-27 05:33:55 -05:00
Serial.println("\tgo home position");
radar.gotoHomePosition();
wait();
Serial.println();
}
void wait()
{
2020-11-27 05:33:55 -05:00
Serial.println("\nTIME\t\tPAN\tTILT");
do
{
Serial.print(millis());
Serial.print("\t*\t");
2020-11-27 05:33:55 -05:00
Serial.print(radar.getPan());
Serial.print("\t");
2020-11-27 05:33:55 -05:00
Serial.println(radar.getTilt());
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());
}
2020-11-27 05:33:55 -05:00
// -- END OF FILE --