arduinoUno连接发射模块与接收模块跟显示屏说明

1. Uno板连接接收模块与发射模块

1.1接线说明

接收模块   Uno

GND ------------GND接地线

VCC -------------5V接电源

数据引脚------11引脚(此例子接法)

 

 

发射模块   Uno

GND ------------GND接地线

VCC -------------5V接电源

数据引脚------12引脚(此例子接法)

 

1.2测试代码

接收模块代码:

#include <VirtualWire.h>

#undef int

#undef abs

#undef double

#undef float

#undef round

 

 byte buf[VW_MAX_MESSAGE_LEN];

 byte buflen = VW_MAX_MESSAGE_LEN;

void setup()

{

   Serial.begin(9600);  // Debugging only

   Serial.println("setup");

   Serial.println("Receiver...");

   // Initialise the IO and ISR

   vw_set_ptt_inverted(true); // Required for DR3100

   vw_setup(2000);   // Bits per sec

   vw_rx_start();       // Start the receiver PLL running

}

void loop()

{

 

   if (vw_get_message(buf, &buflen))//Non-blocking

  {

   int i;

   digitalWrite(12, true);  //Flash a light to show received good message

   Serial.print("Got: "); //Message with a good checksum received, dump it.

   for (i = 0; i < buflen; i++)

  {

   Serial.print(buf[i], HEX);

   Serial.print(" ");

    }

   Serial.println("");

   digitalWrite(12, false);

   }

   }

 

 

 

发射模块代码:

#include <VirtualWire.h>

#undef int

#undef abs

#undef double

#undef float

#undef round

void setup()

{

   Serial.begin(9600);    // Debugging only

   Serial.println("setup");

   Serial.println("Transmmiter...");

   // Initialise the IO and ISR

   vw_set_ptt_inverted(true); // Required for DR3100

   vw_setup(2000);   // Bits per sec

}

void loop()

{

   const char *msg = "hello";

   digitalWrite(13, true); // Flash a light to show transmitting

   vw_send((uint8_t *)msg, strlen(msg));

   vw_wait_tx(); // Wait until the whole message is gone

   digitalWrite(13, false);

   delay(200);

   }

 

 

 

2. Uno板连接显示器

2.1 接线说明

 

2.2 测试代码

2.2.1英文显示屏测试代码

//LingShun lab  

#include <Wire.h>   

#include <LiquidCrystal_I2C.h> //引用I2C库  

  

//设置LCD1602设备地址,这里的地址是0x3F,一般是0x20,或者0x27,具体看模块手册  

LiquidCrystal_I2C lcd(0x3F,16,2);    

 

  

void setup()  

{  

  lcd.init();                  // 初始化LCD  

  lcd.backlight();             //设置LCD背景等亮  

}  

  

void loop()  

{

  lcd.setCursor(0,0);                //设置显示指针  

  lcd.print("Hello Wzx!!!");     //输出字符到LCD1602

  int ButtonState = digitalRead(0); //设置变量存储读到的状态值  

  //lcd.clear();

  delay(1000);  

}

 

 

 

2.2.2中文显示屏测试代码

#include <RSCG12864B.h>//引用库文件

void setup() {
   // put your setup code here, to run once:
   RSCG12864B.begin();//串口初始化
   RSCG12864B.brightness(255);//屏幕亮度
}

void loop() {
   // put your main code here, to run repeatedly:
   unsigned char i;
   char chn[]={  0xD6, 0xD0,0xB1, 0xB4,0xCB, 0xB9,0xCC, 0xD8,0,};//中贝斯特
   char f1[]={0X49,0X32,0X43,0XBD,0XD3,0XBF,0XDA,0X2C,0XC4,0XDA,0XBD,0XA8,0XD7,0XD6,0XBF,0XE2,0,};
   char f2[]={0XD6,0XD0,0XCE,0XC4,0X2C,0XBA,0XAB,0XCE,0XC4,0X2C,0XC8,0XD5,0XCE,0XC4,0,};
   char f3[]={0XD6,0XA7,0XB3,0XD6,0X32,0X44,0XBB,0XE6,0XCD,0XBC,0};//显示文字
   RSCG12864B.display_bmp(0);//显示图片
   delay(800);
   RSCG12864B.display_bmp(1);
   delay(800);
   RSCG12864B.display_bmp(2);
   delay(800);
   RSCG12864B.display_bmp(3);
   delay(800);
   RSCG12864B.display_bmp(4);
   delay(800);
   RSCG12864B.display_bmp(5);//通过图片下载工具放置0-5bmp图片
   delay(800);
   RSCG12864B.clear();//屏幕清屏
   RSCG12864B.print_string_16_xy(0,15,chn);//坐标0,15,显示chn里的内容
   RSCG12864B.print_string_16_xy(8,35,"zhongbest.com");//显示zhongbest.com
   delay(3000);
   RSCG12864B.clear();
   RSCG12864B.print_string_12_xy(16,15,chn);//坐标16,15,显示chn里的内容
   RSCG12864B.print_string_12_xy(20,35,"zhongbest.com");//显示zhongbest.com
   delay(3000);
   RSCG12864B.clear();
   RSCG12864B.font_revers_on();
   RSCG12864B.print_string_12_xy(25,0,"Built-in font");
   RSCG12864B.font_revers_off();
   RSCG12864B.print_string_5x7_xy(3,15,"5*7 ASCII 0123456789");
   RSCG12864B.print_string_5x7_xy(3,25,"5*7 ASCII ABCDEabcde");
   RSCG12864B.print_string_12_xy(20,35,"6*12/12*12 FONT");
   RSCG12864B.print_string_16_xy(5,48,"8*16/16*16 FONT");//显示内容
   delay(3000);
   RSCG12864B.clear();
   RSCG12864B.print_string_16_xy(0,0,f1);//定义f1起始坐标0,0
   RSCG12864B.print_string_16_xy(0,16,f2);//定义f2起始坐标0,16
   RSCG12864B.print_string_16_xy(0,32,f3);
   RSCG12864B.draw_rectangle(0,50,127,63);
   for(i=2;i<=125;i++)
   {
     RSCG12864B.draw_fill_rectangle(2,52,i,61);
     delay(100);
   }
   delay(3000);
}

 

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值