Dependents: nhk2018_throwing02 nhk_2018_undercarry_test08 nhk_2018_undercarry_test09 nhk_2018_undercarry_test10 ... more
Fork of TCS3200 by
TCS3200.cpp
- Committer:
- kenken0721
- Date:
- 2018-03-22
- Revision:
- 1:40b638b93be8
- Parent:
- 0:b98e768bc655
- Child:
- 2:78984c66a877
File content as of revision 1:40b638b93be8:
#include "TCS3200.h" #include "mbed.h" TCS3200::TCS3200(PinName S2, PinName S3, PinName OUT) : mS2(S2), mS3(S3), signal(OUT) { signal.rise(this,&TCS3200::HighTrigger); signal.fall(this,&TCS3200::LowTrigger); } long TCS3200::ReadRed() { mS2=0; mS3=0; wait(0.1); //Delay to allow frequency to change for the set color return(pulsewidth); } long TCS3200::ReadGreen() { mS2=1; mS3=1; wait(0.1); //Delay to allow frequency to change for the set color return(pulsewidth); } long TCS3200::ReadBlue() { mS2=0; mS3=1; wait(0.1); //Delay to allow frequency to change for the set color return(pulsewidth); } long TCS3200::ReadClear() { mS2=1; mS3=0; wait(0.1); //Delay to allow frequency to change for the set color return(pulsewidth); } void TCS3200::HighTrigger() { timer.start(); } void TCS3200::LowTrigger() { timer.stop(); pulsewidth = timer.read_us(); timer.reset(); }