Martin Sturm
/
Project
Diff: strings.cpp
- Revision:
- 0:2fab16867d73
- Child:
- 1:44f0b9d5883b
diff -r 000000000000 -r 2fab16867d73 strings.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/strings.cpp Wed Nov 30 18:06:50 2011 +0000 @@ -0,0 +1,63 @@ +#include "strings.h" + +int tempEL = 40; +int tempA = 40; +int tempD = 40; +int tempG = 40; +int tempB = 40; +int tempEH = 40; + +//inputs for string detection +AnalogIn EStringL(p20); +AnalogIn AString(p19); +AnalogIn DString(p18); +AnalogIn GString(p17); +AnalogIn BString(p16); +AnalogIn EStringH(p15); + +//detection range +int bufferVal = 15; + + + +char output = 0; + +char Strings() { + + + + if(abs(EStringL-tempEL) > bufferVal) { + output = (output|0x01); + }else { + output = (output&0xFE); + } + if(abs(AString-tempA) > bufferVal) { + output = (output|0x02); + }else { + output = (output&0xFD); + } + if(abs(DString-tempD) > bufferVal) { + output = (output|0x04); + }else { + output = (output&0xFB); + } + if(abs(GString-tempG) > bufferVal) { + output = (output|0x08); + }else { + output = (output&0xF7); + } + if(abs(BString-tempB) > bufferVal) { + output = (output|0x10); + }else { + output = (output&0xEF); + } + if(abs(EStringH-tempEH) > bufferVal) { + output = (output|0x20); + }else { + output = (output&0xDF); + } + wait(0.02); + + + return output; +} \ No newline at end of file