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.
main.cpp
- Committer:
- quickeman
- Date:
- 2019-03-14
- Revision:
- 0:c3344ac96db1
- Child:
- 1:e4320a230347
File content as of revision 0:c3344ac96db1:
#include "mbed.h" #include "ColourSensor_H.h" Ticker detectColour; Timeout readColour; Timeout reactivateColour; int main() { printf("Program has started\n\r"); ColourSensor ColourSensor(PTC16, PTC13, PTC12); // Set call rate of colour detection function detectColour.attach(callback(&ColourSensor, &ColourSensor::readIf), 1.0); // Test LED //testLED2.period(1.0); //testLED2.write(0.5); int firstLoop = 1; while (1) { // main program loop if (firstLoop) { printf("Main loop has started\n\r"); firstLoop--; } if (ColourSensor.toggleConst && ColourSensor.toggleA) { // Call readColSenWhich after x seconds printf("Toggle A\n\r"); readColour.attach(callback(&ColourSensor, &ColourSensor::readWhich), 0.4); ColourSensor.toggleA = 0; } if (ColourSensor.toggleConst && ColourSensor.toggleB) { // Process colour sensor data printf("Toggle B\n\r"); ColourSensor.process(); reactivateColour.attach(callback(&ColourSensor, &ColourSensor::makeColourActive), 2.0); ColourSensor.toggleB = 0; } } }