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
00001 #include "mbed.h" 00002 #include "ColourSensor_H.h" 00003 00004 Ticker detectColour; 00005 Timeout readColour; 00006 Timeout reactivateColour; 00007 00008 int main() { 00009 //printf("Program has started\n\r"); 00010 00011 ColourSensor ColourSensor(PTC16, PTC13, PTE20); 00012 00013 // Set call rate of colour detection function 00014 detectColour.attach(callback(&ColourSensor, &ColourSensor::readIf), 0.5); 00015 00016 // int firstLoop = 1; 00017 00018 while (1) { 00019 // main program loop 00020 /* 00021 if (firstLoop) { 00022 printf("Main loop has started\n\r"); 00023 firstLoop--; 00024 } 00025 */ 00026 00027 if (ColourSensor.toggleConst && ColourSensor.toggleA) { 00028 // Call readColSenWhich after x seconds 00029 //printf("Toggle A\n\r"); 00030 00031 readColour.attach(callback(&ColourSensor, &ColourSensor::readWhich), 0.2); 00032 00033 ColourSensor.toggleA = 0; 00034 } 00035 00036 if (ColourSensor.toggleConst && ColourSensor.toggleB) { 00037 // Process colour sensor data 00038 //printf("Toggle B\n\r"); 00039 00040 ColourSensor.process(); 00041 00042 reactivateColour.attach(callback(&ColourSensor, &ColourSensor::makeColourActive), 2.0); 00043 00044 ColourSensor.toggleB = 0; 00045 } 00046 } 00047 }
Generated on Mon Jul 18 2022 08:22:20 by
1.7.2