Examples - Infineon/radar-bgt60 GitHub Wiki
List of examples
To run this examples use either the Arduino IDE or something similar like the PlatformIO extension for VS Code or Atom.
- examples/directionDetection - Determining the direction of the detected target in polling mode.
- examples/directionDetectionInt - Determining the direction of the detected target with the help of interrupts.
- examples/motionDetection - Checking for a motion in the detection range of the radar sensor in polling mode.
- examples/motionDetectionInt - Checking for a motion in the detection range of the radar sensor in interrupt mode.
All Arduino sketches are also available for the other included platforms. See below src/framework/PLATFORM directory.
Examples
directionDetection
This example shows how you can use the BGT60 radar shield to determine the direction of the detected movement. Here we just simply call the getDirection()
function continuously in the loop to check the direction of the motion. Following you can see the different steps of the example:
- First we create an object of the BGT60 class
- Afterwards we call the initialization function of the class (
init()
) - Then we create a variable of the internal direction type (
Direction_t
) where we can store the value of the direction - Now we call the function to readout the direction pin (
getDirection()
) - Depending on the status of the
Direction_t
variable we print a corresponding message in the serial monitor - The three previous steps are continuously repeated in the loop
motionDetection
This example shows how you can use the BGT60 radar shield to check if motion is present in front of the sensor. Here we just simply call the getMotion()
function continuously in the loop to check if a motion was detected or not. Following you can see the different steps of the example:
- First we create an object of the BGT60 class
- Afterwards we call the initialization function of the class (
init()
) - Then we create a variable of the internal motion type (
Motion_t
) where we can store the value of the motion - Now we call the function to readout the target pin (
getMotion()
) - Depending on the status of the
Motion_t
variable we print a corresponding message in the serial monitor - The three previous steps are continuously repeated in the loop
interruptMode
This example shows how to use the interrupt functionality of the library. In order to use the interrupts you have to call the enableInterrupt()
function and pass a callback-function to it. Following you can see the different steps of the example:
- First we create an object of the BGT60 class
- Now we create a user-defined callback function which is just setting a flag when one of the interrupts occurred
- Afterwards we call the initialization function of the class (
init()
) - Then we create variables of the internal types for motion (
Motion_t
) and direction (Direction_t
) to store their values - Now we are checking for a set flag. If the flag is set we first read the corresponding pin for the motion detection (
getMotion()
) and check if motion was detected or not. And then we try to determine the direction of the motion with thegetDirection()
function. Afterwards the flag is reset. In case the flag is not set we do nothing and skip the functions - The previous step is continuously repeated in the loop