Arduino 各种模块篇 RGB LED灯
示例代码:
类似与这样的led,共阴rgb led,通过调节不同的亮度,组合成不同的颜色。


示例代码:
/*
作者:极客工坊
时间:2012年12月18日
IDE版本号:1.0.1
发布地址:www.geek-workshop.com
作用:共阳RGB颜色循环
*/ int redPin = ;
int greenPin = ;
int bluePin = ; void setup()
{
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
} void loop()
{
setColor(, , ); // 红色
delay();
setColor(, , ); // 绿色
delay();
setColor(, , ); // 蓝色
delay();
setColor(, , ); // 黄色
delay();
setColor(, , ); // 紫色
delay();
setColor(, , ); // 浅绿色
delay();
} void setColor(int red, int green, int blue)
{
analogWrite(redPin, -red);
analogWrite(greenPin, -green);
analogWrite(bluePin, -blue);
}
简单演示的代码。

可以显示多种颜色。
更多关于此灯的链接:http://www.geek-workshop.com/forum.php?mod=viewthread&tid=2802
Arduino 各种模块篇 RGB LED灯的更多相关文章
- arduino 蓝牙控制RGB LED灯
/* 日期:2016.9.2 功能:arduino 蓝牙控制RGB LED灯 元件: 跳线公公头 * 8 rgbled, 220欧电阻 蓝牙模块 接线: 蓝牙模块VCC,GND分别接5V,GND;TX ...
- Arduino 各种模块篇 蓝牙模块 手机蓝牙控制Arduino LED灯
解决方案. 条件: 1.手机android 商店下载 blueTerm 2.向arduino中载入如下代码: char val; ; void setup() { Serial.begin(); pi ...
- 基于arduino UNO R3+ESP8266控制LED灯的开关(无USB转TTL工具实现)
最近由于项目要求,需要开发物联网云平台,而本人对硬件和通信技术一窍不通,故而选择arduino这一简单单片机来实现学习掌握基础的硬件和通信技术. 下面就是本人通过查阅大佬资料做的一个整合版本的通过手机 ...
- Arduino 各种模块篇 摇杆模块
Arduino的另外几种模块,我们常见的joystick摇杆模块. 用起来很爽,摇杆 有X,Y轴可调 这里有一篇非常想尽的示例代码: http://www.geek-workshop.com/foru ...
- Arduino系列之pwm控制LED灯(呼吸灯)
下面我将写出最简单控制呼吸灯的方法 void setup() // { pinMode(12,OUTPUT); ...
- Arduino 各种模块篇 粉尘传感器 dust sensor 空气质量检测
Testing a sensor from here. http://www.seeedstudio.com/wiki/Grove_-_Dust_Sensor It's a dust sensor. ...
- Arduino 各种模块篇 光敏感应模块 light sensor
It looks like this one: This one isn't a digital light sensor, so it's very simple. http://www.seeed ...
- Arduino 各种模块篇 motor shield
根据arduino官方网站出的shield, 类似的情况有很多中motor shield 这里测试采用的是http://www.seeedstudio.com/wiki/Motor_Shield_V1 ...
- Arduino 各种模块篇 震动模块 vibrator module
The vibrator I got works at the voltage ranging from 3.3V ~ 5.5V I want to make it vibrate variably. ...
随机推荐
- cscope的使用
转自:http://easwy.com/blog/archives/advanced-vim-skills-cscope/ 本节所用命令的帮助入口: :help cscope 在前面的文章中介绍了利用 ...
- poj 2513 Colored Sticks(欧拉路径+并检查集合+特里)
题目链接:poj 2513 Colored Sticks 题目大意:有N个木棍,每根木棍两端被涂上颜色.如今给定每一个木棍两端的颜色.不同木棍之间拼接须要颜色同样的 端才干够.问最后是否能将N个木棍拼 ...
- mongodb操作之使用javaScript实现多表关联查询
一.数据控制 mongodb操作数据量控制,千万控制好,不要因为操作的数据量过多而导致失败. 演示一下发生此类错误的错误提示:
- hdu oj1102 Constructing Roads(最小生成树)
Constructing Roads Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...
- 【 D3.js 进阶系列 — 5.0 】 直方图
直方图用于描写叙述概率分布,D3 提供了直方图的布局 Histogram 用于转换数据. 假设有数组 a = [10, 11, 11.5, 12.5, 13, 15, 19, 20 ],如今把10~2 ...
- GIMP也疯狂之动态图的制作(一)
写在前面的话:本系列gimp教程已首发在Linux吧(Go),之所以重新发表是因为便于博主分类并且可以重新整理,用作记录.本系列的侧重不是GIF的教程,而是gimp教程,想更好的制作GIF图片请使用专 ...
- vector成员函数解析
vector线性集装箱,其元素颜格排序根据线性序列,和动态数组很阶段似,像阵列,它的元素被存储在连续的存储空间,这也意味着,我们不仅能够使用迭代器(iterator)访问元素,也可以用一个指针访问偏移 ...
- apache 提示You don't have permission to access /test.php on this server.怎样解决
把denty改成allow httpd.conf文件中. <Directory "cgi-bin"> AllowOverride None Options None O ...
- dpkg: error processing mysql-server (--configure): dependency problems - leaving unconfigured
dpkg: error processing mysql-server (--configure): dependency problems - leaving unconfigured start: ...
- hrift 的序列化机制
Thrift 个人实战--Thrift 的序列化机制 前言: Thrift作为Facebook开源的RPC框架, 通过IDL中间语言, 并借助代码生成引擎生成各种主流语言的rpc框架服务端/客户端代码 ...