操作演示如下:
一、 I2C的连线方式如图
正面
背面
二、线路连接好之后,打开LXTerminal,进入目录,如图所示
三.打开代码,见下图
四、、代码打开成功之后,输入make进行编译,出现可执行文件,如下图
五、 运行代码,简单快捷的I2C通信就能在您的Pcduino上实现了
/*This sketch prints "Hello World!" to the LCDand 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 <core.h>#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);}