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.
Diff: sense.cpp
- Revision:
- 0:cdbd21489e81
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sense.cpp Tue Nov 30 22:03:27 2010 +0000
@@ -0,0 +1,43 @@
+#include "mbed.h"
+#include "touch0.h"
+#include "touch1.h"
+#define numsamples 1
+DigitalOut myled0(LED1);
+DigitalOut myled1(LED2);
+int sense() {
+ int TS[2];
+ while (1) {
+ TS[0]=touchSense0();
+ TS[1]=touchSense1();
+ if (TS[0]*TS[1]==1) {
+ return 2;
+ } else {
+ if (TS[0]==1) {
+ while (TS[0]==1) {
+ wait (0.5);
+ TS[0]=touchSense0();
+ TS[1]=touchSense1();
+ if (TS[0]*TS[1]==1) {
+ return 2;
+ }
+ }
+ myled0=!myled0;
+ return 0;
+ } else {
+ if (TS[1]==1) {
+ while (TS[1]==1) {
+ wait (0.5);
+ TS[0]=touchSense0();
+ TS[1]=touchSense1();
+ if (TS[0]*TS[1]==1) {
+ return 2;
+ }
+ }
+ myled1=!myled1;
+ return 1;
+ }
+ }
+ }
+ wait(0.005);
+ }
+}
\ No newline at end of file