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
- Committer:
- quickeman
- Date:
- 2019-03-18
- Revision:
- 0:23508e7103a4
File content as of revision 0:23508e7103a4:
// ColourSensor_H.h
#ifndef ColourSensor_H
#define ColourSensor_H
#include "mbed.h"
// ColourSensor is used to detect the coloured disks and control the Solenoid
/* Attributes:
- Pinouts of sensor inputs and solenoid output
Methods:
- solenoidSet
- readColSenIf
- readColSenWhich
- colourCheck
- makeColourActive
*/
class ColourSensor {
public:
void solenoidSet(bool state); // Setting solenoid state
void solenoidOn(); // Interrupt to turn ON solenoid
void readIf(); // Read 'IF' sensor
void readWhich(); // Read 'WHICH' sensor
void process(); // Colour processing
void initialConditions(); // Sets initial conditions
DigitalIn inIf;
DigitalIn inWhich;
DigitalOut solenoid;
int firstLoop;
bool toggleA;
bool toggleB;
bool toggleConst; // Can be used to toggle colour processing
bool flagColour;
ColourSensor(PinName pin1, PinName pin2, PinName pin3);
void makeColourActive();
private:
bool detectedIf; // Colour detected? Yes/No -> 1/0
bool detectedIfOld; // Comparison bool
bool newDetection; // Colour newly detected? (i.e. is now but wasn't before?) Yes/No -> 1/0
bool detectedWhich; // Colour detected: Red/Blue -> 1/0
bool diskHave; // Have disk? Yes/No -> 1/0
bool diskColour; // Colour of disk: Red/Blue -> 1/0
bool solenoidState; // State of solenoid: On/Off -> 1/0
};
#endif