This library is for the DopplerRadar Board.
This DopplerRadar Board can get the speed of the target and the state of the target's movement.
Connect the DopplerRadar Board to the serial port of the board. In this example, we use hardware serial as the serial port; If you have other software Serial ports on you board, you can also connect to it. But software serial port may cause data loss.
Git clone this resp to your Arduino IDE'S libraries directory.
Open the demo "BGT24LTR11_DETECTION_TARGET" from examples directory in Arduino IDE.
Start a project.
You can choose to use the hardware or software serial port.
#define COMSerial Serial
#define ShowSerial SerialUSB
BGT24LTR11<HardwareSerial> BGT;
Set the communication baud rate of the DopplerRadar module (115200).
Then initialize BGT in the setup function.
Set the working mode.
void setup()
{
// put your setup code here, to run once:
ShowSerial.begin(9600);
COMSerial.begin(115200);
BGT.init(COMSerial);
while (!ShowSerial)
;
while (!COMSerial)
;
/*
* MODE 0 -->detection target mode
* MODE 1 -->I/Q ADC mode
*/
while (!BGT.setMode(0))
;
}
Gets the speed value and target state.
void loop()
{
// put your main code here, to run repeatedly:
uint16_t state=0;
ShowSerial.print("target speed:");
ShowSerial.println(BGT.getSpeed());
state = BGT.getTargetState();
//2 --> target approach
//1 --> target leave
//0 --> Not Found target
if (state == 2)
{
ShowSerial.println("target approach");
}
else if (state == 1)
{
ShowSerial.println("target leave");
}
delay(200);
}
See BGT24LTR11.h for detailed descriptions.
See LICENSE.