Martin Sturm / Mbed 2 deprecated Project

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers strings.cpp Source File

strings.cpp

00001 #include "strings.h"
00002 
00003 
00004 //inputs for string detection
00005 AnalogIn EStringL(p20); 
00006 AnalogIn AString(p19);
00007 AnalogIn DString(p18);
00008 AnalogIn GString(p17);
00009 AnalogIn BString(p16);
00010 AnalogIn EStringH(p15);
00011 
00012 //detection range    
00013 #define bufferVal 0.5
00014     
00015     
00016 
00017 
00018 
00019 char Strings() {
00020 char toPC=0;    
00021 int output[] = {-3,-3,-3,-3,-3,-3};
00022 
00023 for(int i=0;i<5;i++){
00024         if(EStringL > bufferVal) {
00025            output[0] +=1; 
00026         }
00027         if(AString > bufferVal) {
00028             output[1] +=1;
00029         } 
00030         if(DString > bufferVal) {
00031             output[2] +=1; 
00032         } 
00033         if(GString > bufferVal) {
00034             output[3]+=1;
00035         } 
00036         if(BString > bufferVal) {
00037             output[4]+=1;
00038         } 
00039         if(EStringH > bufferVal) {
00040              output[5]+=1;
00041         } 
00042  }
00043     for(int i=0;i<6;i++){
00044     if(output[i]>0)
00045     toPC+=1<<i;
00046     }
00047     
00048     return toPC;
00049 }