Basic class to interface with a 3-pin capacitive proximity sensor
Diff: CAPsensor.cpp
- Revision:
- 0:a9afa14d4795
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CAPsensor.cpp Mon Nov 01 12:34:36 2021 +0000 @@ -0,0 +1,16 @@ +#include "CAPsensor.h" + +capacitorSensor::capacitorSensor (PinName capSense): + capSense_ (capSense) {}; + + +//function measures the reading of the sensor and then prints to console the result. +void capacitorSensor::capReading(){ + capReadings_ = capSense_.read_u16(); + + if (capReadings_ > 1000){ + printf("Sensor is Pressed/Activated \n"); + } else { + printf("Sensor is NOT Pressed/Activated \n"); + } +} \ No newline at end of file