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.
pre_work.h
- Committer:
- taoxh
- Date:
- 2010-11-30
- Revision:
- 0:ee91220d7bea
File content as of revision 0:ee91220d7bea:
#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;
}