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 solenoidOn(); // Interrupt to turn ON solenoid 00024 void readSensor(); // Read sensors 00025 void convert(); // converts sensor readings to sensible logic 00026 void process(); // Colour processing 00027 void initialConditions(); // Sets initial conditions 00028 00029 DigitalIn inOne; 00030 DigitalIn inTwo; 00031 DigitalOut solenoid; 00032 00033 int firstLoop; 00034 bool toggleA; 00035 bool toggleB; 00036 bool toggleC; 00037 bool toggleConst; // Can be used to toggle colour processing 00038 00039 bool newDetection; // Colour newly detected? (i.e. is now but wasn't before?) Yes/No -> 1/0 00040 bool flagColour; 00041 bool sensorOneCheck, sensorTwoCheck; 00042 ColourSensor(PinName pin1, PinName pin2, PinName pin3); 00043 00044 void makeColourActive(); 00045 void ColourCheck(); 00046 bool diskColour; // Colour of disk: Red/Blue -> 1/0 00047 bool diskHave; 00048 bool sensorColour; 00049 private: 00050 bool sensorOne; 00051 bool sensorOneOld; // Comparison bool 00052 00053 bool sensorTwo; 00054 // Have disk? Yes/No -> 1/0 00055 bool sensorTwoOld; 00056 00057 bool sensorIf; // Yes/No -> 1/0 00058 bool sensorIfOld; 00059 // Red/Blue -> 0/1 00060 00061 00062 bool solenoidState; // State of solenoid: On/Off -> 1/0 00063 00064 }; 00065 00066 #endif
Generated on Sat Aug 6 2022 16:18:59 by
1.7.2