“实验二:RGB彩灯实验”的版本间的差异
来自丢石头百科
Yousimaier17(讨论 | 贡献) |
Yousimaier17(讨论 | 贡献) |
||
第1行: | 第1行: | ||
− | [[Basic Experiment Kits For Arduino]] | + | |
+ | [[Basic Experiment Kits For Arduino|首页]] | ||
== Arduino == | == Arduino == | ||
=== 实验现象 === | === 实验现象 === | ||
第8行: | 第9行: | ||
=== 电路连接 === | === 电路连接 === | ||
− | * | + | *[[File:实验二:RGB彩灯实验_接线1.png|400px]] |
=== 主要程序 === | === 主要程序 === | ||
<pre> | <pre> | ||
− | int red = | + | int red = 3; //select the pin for the red LED |
− | int green = 5; | + | int green = 5; // select the pin for the blue LED |
− | int blue = | + | int blue = 6; // select the pin for the green LED |
int val; | int val; | ||
第43行: | 第44行: | ||
== 树莓派 == | == 树莓派 == | ||
+ | === 实验现象 === | ||
+ | * | ||
+ | === 电路连接 === | ||
+ | * | ||
+ | === 程序运行 === | ||
+ | ==== C语言 ==== | ||
+ | ==== Python ==== | ||
=== 例程下载 === | === 例程下载 === | ||
− | + | ||
+ | == 相关例程 == | ||
+ | {{Arduino and Raspberry Pi Case}} |
2024年8月9日 (五) 15:32的版本
目录
Arduino
实验现象
- RGB模块实现酷炫的灯光效果
实验原理
- 通过 R、G、B 三个引脚的PWM电压输入可以调节三种基色(红/蓝/绿)的强度从而实现全彩的混色效果
电路连接
主要程序
int red = 3; //select the pin for the red LED int green = 5; // select the pin for the blue LED int blue = 6; // select the pin for the green LED int val; void setup() { pinMode(red,OUTPUT); pinMode(green,OUTPUT); pinMode(blue,OUTPUT); } void loop() { for(val=255; val>0; val--) { analogWrite(red,val); analogWrite(blue,128-val); analogWrite(green,255-val); delay(1); } for(val=0; val<255; val++) { analogWrite(red,val); analogWrite(blue,128-val); analogWrite(green,255-val); delay(1); } }