九鼎创展论坛中文版English
登录 | 立即注册 设为首页收藏本站 切换到宽版
查看: 5757|回复: 0
打印 上一主题 下一主题

arduino ibox项目实战31-PhysicalPixel实验

[复制链接]
跳转到指定楼层
楼主
发表于 2014-10-29 09:11:29 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
硬件平台:PC机一台,ibox卡片电脑一只,arduino扩展板一个,串口调试板一个
软件平台:WIN7操作系统,android4.0android4.4系统,串口调试助手
实验目标:通过串口输入控制LED灯的亮与灭
打开arduino的IDE开发工具,依次点击文件->示例->04.Communication->PhysicalPixel,PhysicalPixel的示例程序将会被打开,其源码如下:
  1. const int ledPin = LED1; // the pin that the LED is attached to
  2. int incomingByte;      // a variable to read incoming serial data into

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

  9. void loop() {
  10.   // see if there's incoming serial data:
  11.   if (Serial.available() >= 0) {
  12.     // read the oldest byte in the serial buffer:
  13.     incomingByte = Serial.read();
  14.     // if it's a capital H (ASCII 72), turn on the LED:
  15.     if (incomingByte == 'H') {
  16.       digitalWrite(ledPin, HIGH);
  17.     }
  18.     // if it's an L (ASCII 76) turn off the LED:
  19.     if (incomingByte == 'L') {
  20.       digitalWrite(ledPin, LOW);
  21.     }
  22.   }
  23. }
复制代码
       依次将串口调试板的VDD,TXD,RXD,GND接到ibox转接板的3.3VTXRXGND,打开串口调试助手,将波特率设置得和程序一致,COM口和PC机的串口一致,参考设置如下图所示:

运行arduino程序,在串口调试助手终端输入HL,点击发送,观察LED灯的状态。

回复

使用道具 举报

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

本版积分规则

QQ|手机版|小黑屋|深圳市九鼎创展科技官方论坛 ( 粤ICP备11028681号-2  

GMT+8, 2024-6-15 04:20 , Processed in 0.020700 second(s), 22 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

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