极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 13517|回复: 5

一个iPad遥控led的小例子,简单易行

[复制链接]
发表于 2013-5-11 08:53:13 | 显示全部楼层 |阅读模式
这个例子中要演示一下如何利用BlueShield和Arduino一起配合,来达到遥控led小灯的效果。

我们准备直接使用Arduino编辑器自带的例子Examples->Communication->Dimmer,这个例子原本是利用串口输入数字,控制led的亮度。在这个基础上加上BlueShield,遥控就变得简单了。

准备材料

  • microduino一个,这相当于一个缩小版的arduino uno
  • Arduino的蓝牙模块BlueShield一块
  • 发光二极管一个
  • 220欧电阻一个
  • 面包板一块
  • 杜邦线若干


最重要的,你手上要有一个搭载了蓝牙4.0的设备比如iPhone 4S/5,iPad mini/4等等。

开始接线

由于MicroDuino和arduino uno是兼容的,所以图中以uno的图片代替。接线图如下



实际接线图



测试

  • 下载软件LightBlue
  • 写入测试程序Dimmer到Arduino
  • 打开LightBlue,连上BlueShield,找到D3E60005-8F36-40D6-B2D5-C5D9F5E81869这个characteristic,输入hex例如ff,这是最亮,01是最暗的情况


演示视频



附上Dimmer的源码
  1. const int ledPin = 9;      // the pin that the LED is attached to

  2. void setup()
  3. {
  4.   // initialize the serial communication:
  5.   Serial.begin(9600);
  6.   // initialize the ledPin as an output:
  7.   pinMode(ledPin, OUTPUT);
  8. }

  9. void loop() {
  10.   byte brightness;

  11.   // check if data has been sent from the computer:
  12.   if (Serial.available()) {
  13.     // read the most recent byte (which will be from 0 to 255):
  14.     brightness = Serial.read();
  15.     // set the brightness of the LED:
  16.     analogWrite(ledPin, brightness);
  17.   }
  18. }
复制代码
回复

使用道具 举报

发表于 2013-5-11 21:43:10 | 显示全部楼层
用了microduino,俺是一定要顶一下的,顺便曝光一下Ogre_c已经设计出了蓝牙4.0盾,目前打样中,详情浏览microduino wiki,目前根据开源的精神,发布出了原理图以及pcb布局,还有厂家的模块文档,有兴趣的朋友可以看看。
回复 支持 反对

使用道具 举报

发表于 2013-5-21 17:08:23 | 显示全部楼层
zcbzjx 发表于 2013-5-11 21:43
用了microduino,俺是一定要顶一下的,顺便曝光一下Ogre_c已经设计出了蓝牙4.0盾,目前打样中,详情浏览mic ...

蓝牙4.0模块传输距离实测到底能有多远?看淘宝卖家讲的空旷距离能达到60米,表示质疑。。。
回复 支持 反对

使用道具 举报

发表于 2013-5-31 00:52:38 | 显示全部楼层
有空试试!
回复 支持 反对

使用道具 举报

发表于 2013-5-31 08:38:50 | 显示全部楼层
这个蓝牙模块什么型号呢,哪买的呢
回复 支持 反对

使用道具 举报

 楼主| 发表于 2013-5-31 15:36:21 | 显示全部楼层
duocool 发表于 2013-5-31 08:38
这个蓝牙模块什么型号呢,哪买的呢

叫BlueShield,支持蓝牙4.0的arduino shield

http://item.taobao.com/item.htm?id=17978577688
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 需要先绑定手机号

Archiver|联系我们|极客工坊

GMT+8, 2024-5-10 08:43 , Processed in 0.050634 second(s), 22 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表