Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 0:a9afa14d4795, committed 2021-11-01
- Comitter:
- snapo
- Date:
- Mon Nov 01 12:34:36 2021 +0000
- Commit message:
- basic class to interface quickly with a 3 pin capacitive proximity sensor;
Changed in this revision
| CAPsensor.cpp | Show annotated file Show diff for this revision Revisions of this file |
| CAPsensor.h | Show annotated file Show diff for this revision Revisions of this file |
--- /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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/CAPsensor.h Mon Nov 01 12:34:36 2021 +0000
@@ -0,0 +1,15 @@
+#pragma once
+#include "mbed.h"
+
+class capacitorSensor {
+
+ AnalogIn capSense_;
+ int capReadings_;
+
+public:
+ //ensure the PinName included is one of the analog pins else the class will function incorrectly.
+ capacitorSensor (PinName capSense);
+ void capReading();
+
+
+};
\ No newline at end of file