TCS3200 color sensor

Dependencies:   TCS3200 mbed

Fork of my_example_TCS3200 by liang brain

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /*-----------------------------------------------------
00002  File Name : main.cpp
00003  Purpose : For tcs3200 sensor
00004  Creation Date : 24-06-2017
00005  Last Modified :
00006  Created By : Jeasine Ma [jeasinema[at]gmail[dot]com]
00007 -----------------------------------------------------*/
00008 #include <cstdio>
00009 #include <cstring>
00010 #include <cstdarg>
00011 
00012 #include "mbed.h"
00013 #include "TextLCD.h"
00014 #include "color.h"
00015 
00016 int main() {
00017     TextLCD lcd(PC_13, PC_14, PC_15, PA_0, PA_1, PB_4, TextLCD::LCD20x4); // rs, e, d4-d7, model
00018 
00019     // S0,S1,S2,S3,OUT
00020     ColorSensor color(PB_11, PA_12, PB_1, PB_10, PB_9);                            //用5个GPIO管脚
00021 
00022     while(1) {
00023         int red = color.getRed();
00024         int green = color.getGreen();
00025         int blue = color.getBlue();
00026         lcd.cls();
00027         lcd.printf("Color:\nR:%d G:%d B:%d", red, green, blue);
00028         wait(1);
00029     }
00030 }