//---------------------------------------------------------------------------------------------------
Step 1: Open a new sketch example, "UltraSonicGesture" from "danlib"
//---------------------------------------------------------------------------------------------------
Step 2: Add source code as following in setup() and loop().
#include <UltraSonicManage.h>
void setup() {
UltraSonicGesturer.Initial(cTrigPin, cEchoPin, &Process_WaveEvent);
}
void loop() {
UltraSonicGesturer.Check_WaveEvent();
}
//---------------------------------------------------------------------------------------------------
Step 3: Add your control code in Process_WaveEvent()
// Triggered if WaveEven ---------------------------------
void Process_WaveEvent(TUltraSonicGesturer*, TWaveState ws, int aCnt, float frDistCM, float toDistCM) {
switch (ws) {
case wsWaveIn: // Hand in
// add your control code here......
break;
case wsWaveOut: // Hand
// add your control code here......
break;
case wsWave: // Hand in&Out
// add your control code here......
break;
case wsHolding: // Hand in, holding
// add your control code here......
break;
case wsHold: // Hand in , holding then out
// add your control code here......
break;
case wsNearToFar: // Hand in, holding from near to far
// add your control code here......
break;
case wsFarToNear: // Hand in, holding from far to near
// add your control code here......
break;
}
Comments
Please log in or sign up to comment.