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.
Fork of FivePosSwitch by
FivePosSwitch.cpp
00001 #include "mbed.h" 00002 #include "FivePosSwitch.h" 00003 00004 FivePosSwitch::FivePosSwitch(AnalogIn pin):_pin(pin){ 00005 } 00006 00007 ACTIVE_POSITION FivePosSwitch::getPosition(){ 00008 float ain = _pin; 00009 00010 if((1.0 - TOLERANCE <= ain) && (ain <= 1.0 + TOLERANCE)) return UP; 00011 if((0.8 - TOLERANCE <= ain) && (ain <= 0.8 + TOLERANCE)) return CENTER; 00012 if((0.6 - TOLERANCE <= ain) && (ain <= 0.6 + TOLERANCE)) return LEFT; 00013 if((0.4 - TOLERANCE <= ain) && (ain <= 0.4 + TOLERANCE)) return DOWN; 00014 if((0.2 - TOLERANCE <= ain) && (ain <= 0.2 + TOLERANCE)) return RIGHT; 00015 else return NONE; 00016 }
Generated on Sat Jul 16 2022 21:10:03 by
1.7.2
