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.
Dependencies: TCS3472_I2C mbed
main.cpp
- Committer:
- averybolt
- Date:
- 2015-05-11
- Revision:
- 0:ed1ae1bcbe64
File content as of revision 0:ed1ae1bcbe64:
#include "mbed.h"
#include "TCS3472_I2C.h" //actually an hpp
#define switch_addr 0xE0
TCS3472_I2C Sensor1 (P0_22, P0_20);
I2C i2c( P0_22, P0_20);
int main()
{
i2c.frequency(400000);
char cmd [1];
int RGBC[4];
Sensor1.enablePowerAndRGBC();
Sensor1.setIntegrationTime(100);
Sensor1.setRGBCGain(1);
Sensor1.enableWait();
while(1){
cmd[0]=0x01;
i2c.write(switch_addr,cmd,1);
Sensor1.getAllColors(RGBC);
Sensor1.getAllColors(RGBC);
printf("red %d green %d blue %d clear %d\r\n",RGBC[0],RGBC[1],RGBC[2],RGBC[3]);
cmd[0]=0x02;
i2c.write(switch_addr,cmd,1);
Sensor1.getAllColors(RGBC);
Sensor1.getAllColors(RGBC);
printf("red %d green %d blue %d clear %d\r\n",RGBC[0],RGBC[1],RGBC[2],RGBC[3]);
}
}