×
嵌入式 > 技术百科 > 详情

pcDuino与Arduino通过xbee模块实现双灯互控

发布时间:2020-06-13 发布时间:
|

操作演示如下:

一、 I2C的连线方式如图

正面

背面

二、线路连接好之后,打开LXTerminal,进入目录,如图所示

三.打开代码,见下图

四、、代码打开成功之后,输入make进行编译,出现可执行文件,如下图

五、 运行代码,简单快捷的I2C通信就能在您的Pcduino上实现了

/*

This sketch prints "Hello World!" to the LCD

and shows the time.

The circuit:

* 5V to Arduino 5V pin

* GND to Arduino GND pin

* SCL to Analog #5

* SDA to Analog #4

*/

// include the library code:

#include

#include "Wire.h"

#include "LiquidCrystal.h"

// Connect via i2c, default address #0 (A0-A2 not jumpered)

LiquidCrystal lcd(0);

void setup() {

// set up the LCD's number of rows and columns:

lcd.begin(16, 2);

// Print a message to the LCD.

lcd.print("hello, world!");

}

void loop() {

// set the cursor to column 0, line 1

// (note: line 1 is the second row, since counting begins with 0):

lcd.setCursor(0, 1);

// print the number of seconds since reset:

lcd.print(millis()/1000);

lcd.setBacklight(HIGH);

delay(500);

lcd.setBacklight(LOW);

delay(500);

}


『本文转载自网络,版权归原作者所有,如有侵权请联系删除』

热门文章 更多
ADI 高精度低功耗精密放大器