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.
Dependencies: PololuLedStrip mbed
Diff: EffectPlugs.cpp
- Revision:
- 0:8dc213146b30
diff -r 000000000000 -r 8dc213146b30 EffectPlugs.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/EffectPlugs.cpp Sat May 19 14:27:12 2018 +0000
@@ -0,0 +1,33 @@
+#include "EffectPlugs.h"
+
+EffectPlugs::EffectPlugs(uint8_t _num, DigitalInOut *_pins)
+{
+ num = _num;
+ pins = _pins;
+
+ for (uint8_t i = 0; i < num; i++)
+ {
+ pins[i].input();
+ pins[i].mode(PullUp);
+ }
+}
+
+uint8_t EffectPlugs::pluggedConnection()
+{
+ uint8_t connection = 0, foundConnection = 0;
+ for (uint8_t i = 0; i < num; i++)
+ {
+ pins[i].output();
+ pins[i].write(0);
+
+ for (uint8_t j = i + 1; j < num; j++)
+ {
+ connection++;
+ if (pins[j].read() == 0)
+ foundConnection = connection;
+ }
+ pins[i].input();
+ pins[i].mode(PullUp);
+ }
+ return foundConnection;
+}