#include <pigpiod_if2.h>
#include <thread>
using namespace std;
#define PIN 30
void play_beep()
{
auto instance = pigpio_start(NULL, NULL);
// We actually can't achieve 2700Hz due to the sampling
// rate, but it will do the best it can
set_PWM_frequency(instance, PIN, 2700);
// 128/255 = 50% duty
set_PWM_dutycycle(instance, PIN, 128);
// play beep for 100 milliseconds
this_thread::sleep_for(chrono::milliseconds(100));
// turn off beep
set_PWM_dutycycle(instance, PIN, 0);
pigpio_stop(instance);
}