示例代码:

类似与这样的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灯的更多相关文章

  1. arduino 蓝牙控制RGB LED灯

    /* 日期:2016.9.2 功能:arduino 蓝牙控制RGB LED灯 元件: 跳线公公头 * 8 rgbled, 220欧电阻 蓝牙模块 接线: 蓝牙模块VCC,GND分别接5V,GND;TX ...

  2. Arduino 各种模块篇 蓝牙模块 手机蓝牙控制Arduino LED灯

    解决方案. 条件: 1.手机android 商店下载 blueTerm 2.向arduino中载入如下代码: char val; ; void setup() { Serial.begin(); pi ...

  3. 基于arduino UNO R3+ESP8266控制LED灯的开关(无USB转TTL工具实现)

    最近由于项目要求,需要开发物联网云平台,而本人对硬件和通信技术一窍不通,故而选择arduino这一简单单片机来实现学习掌握基础的硬件和通信技术. 下面就是本人通过查阅大佬资料做的一个整合版本的通过手机 ...

  4. Arduino 各种模块篇 摇杆模块

    Arduino的另外几种模块,我们常见的joystick摇杆模块. 用起来很爽,摇杆 有X,Y轴可调 这里有一篇非常想尽的示例代码: http://www.geek-workshop.com/foru ...

  5. Arduino系列之pwm控制LED灯(呼吸灯)

    下面我将写出最简单控制呼吸灯的方法 void setup()                                 // { pinMode(12,OUTPUT);             ...

  6. Arduino 各种模块篇 粉尘传感器 dust sensor 空气质量检测

    Testing a sensor from here. http://www.seeedstudio.com/wiki/Grove_-_Dust_Sensor It's a dust sensor. ...

  7. Arduino 各种模块篇 光敏感应模块 light sensor

    It looks like this one: This one isn't a digital light sensor, so it's very simple. http://www.seeed ...

  8. Arduino 各种模块篇 motor shield

    根据arduino官方网站出的shield, 类似的情况有很多中motor shield 这里测试采用的是http://www.seeedstudio.com/wiki/Motor_Shield_V1 ...

  9. Arduino 各种模块篇 震动模块 vibrator module

    The vibrator I got works at the voltage ranging from 3.3V ~ 5.5V I want to make it vibrate variably. ...

随机推荐

  1. Objective-C的动态特性

    最近几年中涌现了大量的Objective-C开发者.有些是从动态语言转过来的,比如Ruby或Python,有些是从强类型语言转过来的,如Java或C#,当然也有直接以Objective-C作为入门语言 ...

  2. MVC验证04-自定义验证规则、日期范围验证

    原文:MVC验证04-自定义验证规则.日期范围验证 本文体验范围验证.与本文相关的包括: MVC验证01-基础.远程验证   MVC验证02-自定义验证规则.邮件验证   MVC验证03-自定义验证规 ...

  3. Codeforces 113A-Grammar Lessons(实现)

    A. Grammar Lessons time limit per test 5 seconds memory limit per test 256 megabytes input standard ...

  4. windows批处理研究_不断更新

    windows批处理脚本(bat),很麻烦,主要原因有: 1.bat脚本编写的风格,太古老,调用方式太奇怪. 2.windows自身运行机制就对批处理脚本有兼容性问题.比如,鼠标双击打开一个bat,与 ...

  5. bzoj 1799: [Ahoi2009]self 类似的分布 解读

    [原标题] 1799: [Ahoi2009]self 同类分布 Time Limit: 50 Sec  Memory Limit: 64 MB Submit: 554  Solved: 194 [id ...

  6. 使用OpenWrt的SDK

    原文:http://wiki.openwrt.org/doc/howto/obtain.firmware.sdk 为什么要使用SDK: Reasons for using the SDK are: C ...

  7. [翻译]初识SQL Server 2005 Reporting Services Part 2

    原文:[翻译]初识SQL Server 2005 Reporting Services Part 2 在Part 1文章中我们对SQL Server Reporting Services 2005(S ...

  8. 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 ...

  9. android 背景图片的设置

    在java文件中对控件设置背景图片 layout.setBackgroundDrawable(getResources().getDrawable(R.drawable.bgimage)) 在设置中, ...

  10. TodoList开发笔记 – Part Ⅱ

    上一节给出了应用的两个主要UML类图,应用采用的技术也给出了,这一节开始实际设计编码 一.应用公开的方法 其实就几个的方法而已 1.代办事项的CRUD 2.代办事项归类目录的CRUD 3.代表事项“已 ...