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: pre_work.h
- Revision:
- 0:ee91220d7bea
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pre_work.h Tue Nov 30 23:53:06 2010 +0000 @@ -0,0 +1,79 @@ +#include "mbed.h" + +#define numsamples 1 +int touchSense1(void); +int touchSense2(void); +int senderror (); +int senderror2 (); +int test1(); +int test2(); +DigitalOut myled1(LED1); +AnalogIn input1(p20); +DigitalIn charger1(p19); +DigitalOut ground1(p18); + +DigitalOut myled2(LED2); +AnalogIn input2(p15); +DigitalIn charger2(p16); +DigitalOut ground2(p17); +Serial pc(USBTX, USBRX); // tx, rx +char str[40]; +char str2[40]; +int length=0; +int touchSense1(void) { + float sample; + ground1 = 0; + charger1.mode(PullUp); + charger1.mode(PullNone); + sample=input1.read(); + if (sample < 0.3) { + return 1; + } else { + return 0; + } +} + +int touchSense2(void) { + float sample; + ground2 = 0; + charger2.mode(PullUp); + charger2.mode(PullNone); + sample=input2.read(); + if (sample < 0.3) { + return 1; + } else { + return 0; + } +} + +int senderror () { + pc.printf("Touch Error"); + return 0; + } + +int senderror2 () { + pc.printf("Host Error"); + return 0; + } + + + + + + int test1() + { + int j=1000; + int judge=0; + for (int i=0;i<j;i++) + { if(touchSense1()) {judge=1;}} + return judge; + } + + int test2() + { + int j=1000; + int judge=0; + for (int i=0;i<j;i++) + { if(touchSense2()) {judge=1;}} + return judge; + } \ No newline at end of file