查看“Maple Lesson 07 - Control RGB LED”的源代码
←
Maple Lesson 07 - Control RGB LED
跳转至:
导航
、
搜索
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
{| style="width: 800px;" |- | ==Objective== You have learned several LED experiment, then go on studying the RGB LED that is display different color by a RGB LED, including the breathing lamp's effect. ==Equipment== *[[ Microduino-CoreSTM32]] Microduino-CoreSTM32 is an ARM development board using STM32F103CBT6 chip. It use special Upin7 interface, the size is similar with a coin and fully compatible other Microduino modules. *Other hardware equipment **Breadboard Jumper one box **Breadboard one piece **RGB LED one **220Ω resistor one **USB Data cable one [[File:STM32-lesson7All.jpg|600px|center|thumb]] ===RGB=== RGB LED contains three LEDs, one is red, the other is green and another it blue. By controlling three LED's brightness, you can mix up almost any color you want. [[File:lesson7-RGB.jpg|600px|center|thumb]] ===Connection method=== *Method 1: The longest lead wire (anode) will be connected to +5 V. The other three pins are connected the series resistance of 220Ω then connected to Microduino PWM output port. The resistance use to prevent too much current flows and burn the LED. *Method 2: RGB anode through 220Ω resistor connects to VCC, the other three pins connected to the PWM output port. Three LED share a resistance, then the brightness dimmed. ==Schematic== The following connection uses method 1 and uses pin D4、D11 and D12. You also can use PWM pin:0,1,4,11,12,14(A0),15(A1),16(A2),17(A3),18(SDA),19(SCL),20(A6),21(A7). [[File:stm32-lesson7-schematic.jpg|600px|center|thumb]] ==Program== <source lang="cpp"> int redPin = 4; int greenPin = 11; int bluePin = 12; void setup() { pinMode(redPin, PWM); pinMode(greenPin, PWM); pinMode(bluePin, PWM); } void loop() { setColor(65535, 0, 0); // Red delay(1000); setColor(0, 65535, 0); // Green delay(1000); setColor(0, 0, 65535); // Blue delay(1000); setColor(65535, 65535, 0); // Yellow delay(1000); setColor(80, 0, 80); // Purple delay(1000); setColor(65535, 65535, 65535);//White delay(1000); setColor(0, 0, 0); //Black delay(1000); for(int i=0;i<65535;i+=1285)//Red coming on { setColor(i, 0, 0); delay(30); } delay(100); for(int i=65535;i>0;i-=1285)//Red coming off { setColor(i, 0, 0); delay(30); } delay(100); for(int i=0;i<65535;i+=1285)//Blue coming on { setColor(0, i, 0); delay(30); } delay(100); for(int i=65535;i>0;i-=1285)//Blue coming off { setColor(0, i, 0); delay(30); } delay(100); for(int i=0;i<65535;i+=1285)//Green coming on { setColor(0, 0, i); delay(30); } delay(100); for(int i=65535;i>0;i-=1285)//Green coming off { setColor(0, 0, i); delay(30); } delay(100); } void setColor(int red, int green, int blue)//Color display program { pwmWrite(redPin, 65535-red); //A total of anode RGB, low level light red LED using 65535-red pwmWrite(greenPin, 65535-green); pwmWrite(bluePin, 65535-blue); } </source> ==Result== In a light can be seen on red, green, blue, yellow, purple, black, white, and the effect like a breathing lamp. [[File:stm32-lesson7Result.jpg|600px|center|thumb]] ==Video== |}
返回至
Maple Lesson 07 - Control RGB LED
。
导航菜单
个人工具
创建账户
登录
名字空间
页面
讨论
变种
视图
阅读
查看源代码
查看历史
更多
搜索
Welcome
首页
创客大赛
大赛详情
3D打印
安装月球车
图形化编程
操控月球车
升级月球车
编程工具下载
软件下载
Arduino
Processing
Mixly
Scratch
模块套件
Microduino 102
mCookie 102
mCookie 202
mCookie 302
IBC
其他
应用套件
四轴飞行器
平衡车
小车CUBE
音乐播放器
刷卡音乐播放器
wifi气象站
彩虹音乐触摸灯
分贝检测仪
迎门汇报
LED点阵时钟
LED点阵屏幕
硬件
mCookie
Sensor
Microduino
MicroWrt
MicroNux
MicroRobot-Core
MicroRobot-CoreESP
ideaBoard
ideaBox
MicroMV
MicroAI
帮助
常见问题
帮助
工具
链入页面
相关更改
特殊页面
页面信息