liang brain
/
my_example_TCS3200
qw
Embed:
(wiki syntax)
Show/hide line numbers
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 "color.h" 00014 00015 // DEBUG USB serial 00016 Serial ser2usb(USBTX, USBRX); 00017 int ser_baud = 9600; 00018 #define LOG(format, ...) do{\ //定义了一个调试的宏,C语言语法 00019 ser2usb.printf(format "\r\n", ##__VA_ARGS__);\ 00020 }while(0) 00021 00022 int main() { 00023 // S0,S1,S2,S3,OUT 00024 ColorSensor color(PA_0, PA_1, PA_4, PB_0, PC_1); //用5个GPIO管脚 00025 while(1) { 00026 int red = color.getRed(); 00027 int green = color.getGreen(); 00028 int blue = color.getBlue(); 00029 LOG("Color: R:%d G:%d B:%d", red, green, blue); 00030 wait(1); 00031 } 00032 }
Generated on Wed Jul 20 2022 05:40:43 by 1.7.2