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.
ColourSensor_H.h
00001 // ColourSensor_H.h 00002 00003 #ifndef ColourSensor_H 00004 #define ColourSensor_H 00005 00006 #include "mbed.h" 00007 00008 // ColourSensor is used to detect the coloured disks and control the Solenoid 00009 /* Attributes: 00010 - Pinouts of sensor inputs and solenoid output 00011 00012 Methods: 00013 - solenoidSet 00014 - readColSenIf 00015 - readColSenWhich 00016 - colourCheck 00017 - makeColourActive 00018 */ 00019 00020 class ColourSensor { 00021 public: 00022 void solenoidSet(bool state); // Setting solenoid state 00023 void readIf(); // Read 'IF' sensor 00024 void readWhich(); // Read 'WHICH' sensor 00025 void process(); // Colour processing 00026 void initialConditions(); // Sets initial conditions 00027 00028 DigitalIn inIf; 00029 DigitalIn inWhich; 00030 DigitalOut solenoid; 00031 00032 int firstLoop; 00033 bool toggleA; 00034 bool toggleB; 00035 bool toggleConst; // Can be used to toggle colour processing 00036 00037 ColourSensor(PinName pin1, PinName pin2, PinName pin3); 00038 00039 void makeColourActive(); 00040 00041 00042 private: 00043 bool detectedIf; // Colour detected? Yes/No -> 1/0 00044 bool detectedIfOld; // Comparison bool 00045 bool newDetection; // Colour newly detected? (i.e. is now but wasn't before?) Yes/No -> 1/0 00046 bool detectedWhich; // Colour detected: Red/Blue -> 1/0 00047 bool diskHave; // Have disk? Yes/No -> 1/0 00048 bool diskColour; // Colour of disk: Red/Blue -> 1/0 00049 00050 bool solenoidState; // State of solenoid: On/Off -> 1/0 00051 00052 }; 00053 00054 #endif
Generated on Mon Jul 18 2022 08:22:20 by
1.7.2