//https://github.com/xkam1x/Arduino-PWM-Reader/
//https://forum.arduino.cc/t/esp32-waveshare-sn65hvd230-can/1089185/2
#include <TaskScheduler.h>
#include "PWM.hpp"
#define PWMPIN 6 //pwm output
#define READPWMPIN 7 //PWM input
int pwmV=128;
PWM my_pwm(READPWMPIN);
void dpTimer();
Task t_doorValue(100,TASK_FOREVER, &dpTimer);
Scheduler runner;
void setup() {
Serial.begin(9600);
// put your setup code here, to run once:
runner.init();
runner.addTask(t_doorValue);
t_doorValue.enable();
pinMode(PWMPIN, OUTPUT);
pinMode(READPWMPIN,INPUT);
my_pwm.begin(true);
}
void loop() {
// put your main code here, to run repeatedly:
runner.execute();
Serial.print(pulseIn(READPWMPIN,HIGH));
/*
Serial.print("Value: ");
Serial.print(my_pwm.getValue());
Serial.print("\tAGE: ");
Serial.println(my_pwm.getAge());
*/
delay(100);
}
void dpTimer(){
digitalWrite(PWMPIN, HIGH);
delay(25);
digitalWrite(PWMPIN,LOW);
}