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.
sense.cpp
- Committer:
- bzhang10
- Date:
- 2010-11-30
- Revision:
- 0:cdbd21489e81
File content as of revision 0:cdbd21489e81:
#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);
}
}