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.
Dependents: PAW_Sensor_HelloWorld
paw.h
00001 #ifndef PAW_H 00002 #define PAW_H 00003 00004 #include "mbed.h" 00005 00006 #define STATE_1 0 00007 #define STATE_2 1 00008 #define STATE_3 2 00009 #define STATE_4 3 00010 00011 struct paw_value 00012 { 00013 public: 00014 short ch_1; 00015 short ch_2; 00016 short ch_3; 00017 short ch_4; 00018 short initial_photo_1; 00019 short initial_photo_2; 00020 00021 paw_value() 00022 { 00023 ch_1 = 0; 00024 ch_2 = 0; 00025 ch_3 = 0; 00026 ch_4 = 0; 00027 initial_photo_1 = 0; 00028 initial_photo_2 = 0; 00029 } 00030 }; 00031 00032 /** PAW_Sensor Library 00033 * 00034 * Example: 00035 * @code 00036 * 00037 #include "mbed.h" 00038 #include "paw.h" 00039 00040 Serial pc( USBTX, USBRX ); 00041 const unsigned long baudrate = 115200; 00042 00043 // paw( LED1, LED2, PHOTO1, PHOTO2 ) 00044 PAW paw( p8, p9, p16, p17 ); 00045 paw_value g_value; 00046 00047 Ticker run; 00048 00049 00050 void run_paw_sensor() 00051 { 00052 if( paw.process_paw() == STATE_1 ) 00053 { 00054 paw.print( &pc, 0 ); 00055 } 00056 } 00057 00058 int main() 00059 { 00060 // Initializing Serial Communication 00061 pc.baud( baudrate ); 00062 pc.format( 8, Serial::None, 1 ); 00063 00064 run.attach_us(&run_paw_sensor, 500); 00065 00066 while(1); 00067 } 00068 00069 * @endcode 00070 */ 00071 00072 class PAW { 00073 00074 public: 00075 00076 /** Create a PAW Sensor instance 00077 * 00078 * @param led_1 PAW Sensor's Pin 5 00079 * @param led_2 PAW Sensor's Pin 4 00080 * @param photo_1 PAW Sensor's Pin 3 00081 * @param photo_2 PAW Sensor's Pin 2 00082 */ 00083 PAW( PinName led_1, PinName led_2, PinName photo_1, PinName photo_2 ); 00084 00085 /** Get values of PAW Sensor 00086 * 00087 * @return Return values of photosensor's voltage. 00088 */ 00089 paw_value get_value(); 00090 00091 /** Processing of Paw sensor. This fucntion must be performed periodically. 00092 * 00093 * @return Return current processing-state. 00094 */ 00095 unsigned char process_paw(); 00096 00097 /** Get current processing-state. 00098 * 00099 * @return Return current processing-state. 00100 */ 00101 bool get_state(); 00102 00103 /** Send values of PAW Sensor through serial-communication. 00104 * 00105 * @param Reference to serial object. 00106 * @param ID of PAW Sensor. you can chose number from 0 to 255. 00107 */ 00108 void print( Serial* pc, unsigned char id ); 00109 00110 protected: 00111 DigitalOut _led_1; 00112 DigitalOut _led_2; 00113 AnalogIn _photo_1; 00114 AnalogIn _photo_2; 00115 00116 unsigned char _state; 00117 00118 paw_value _value; 00119 }; 00120 00121 #endif /*** PAW_H ***/
Generated on Thu Jul 14 2022 00:11:31 by
1.7.2
PAW Sensor