37款传感器与执行器的提法,在网络上广泛流传,其实Arduino能够兼容的传感器模块肯定是不止这37种的。鉴于本人手头积累了一些传感器和执行器模块,依照实践出真知(一定要动手做)的理念,以学习和交流为目的,这里准备逐一动手尝试系列实验,不管成功(程序走通)与否,都会记录下来—小小的进步或是搞不掂的问题,希望能够抛砖引玉。
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验一百一十三:蓝色诺基亚5110屏 LCD液晶屏模块 兼容3310 LCD
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
程序五:这个程序是睡眠模式的演示
/*
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
程序五:这个程序是睡眠模式的演示
接脚
SCK - 引脚 8
MOSI - 引脚 9
直流 - 引脚 10
RST - 引脚 12
CS - 引脚 11
*/
#include <LCD5110_Graph.h>
LCD5110 myGLCD(8, 9, 10, 12, 11);
extern uint8_t SmallFont[];
extern uint8_t MediumNumbers[];
void setup() {
myGLCD.InitLCD();
}
void loop() {
myGLCD.setFont(SmallFont);
myGLCD.clrScr();
myGLCD.print("Entering", CENTER, 0);
myGLCD.print("Sleep Mode", CENTER, 8);
myGLCD.print("in", CENTER, 16);
myGLCD.print("Seconds", CENTER, 40);
myGLCD.update();
myGLCD.setFont(MediumNumbers);
for (int s = 10; s >= 0; s--)
{
myGLCD.printNumI(s, CENTER, 24, 2, '0');
myGLCD.update();
delay(1000);
}
myGLCD.enableSleep();
myGLCD.clrScr();
myGLCD.setFont(SmallFont);
myGLCD.print("Awake again!", CENTER, 0);
myGLCD.print("Text has been", CENTER, 16);
myGLCD.print("changed while", CENTER, 24);
myGLCD.print("in Sleep Mode.", CENTER, 32);
delay(5000);
myGLCD.disableSleep();
delay(5000);
}
实验场景图
下载库 https://github.com/wilmsn/LCD5110_Graph
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
程序六:LCD5110_Graph 滚动文本演示
/*
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
程序六:LCD5110_Graph 滚动文本演示
接脚
SCK - 引脚 8
MOSI - 引脚 9
直流 - 引脚 10
RST - 引脚 12
CS - 引脚 11
*/
#include <LCD5110_Graph.h>
LCD5110 myGLCD(8,9,10,12,11);
extern unsigned char SmallFont[];
int y;
void setup()
{
myGLCD.InitLCD();
myGLCD.setFont(SmallFont);
randomSeed(analogRead(0));
}
void loop()
{
y = random(0, 40);
for (int i=84; i>=-(34*6); i--)
{
myGLCD.print("LCD5110_Graph Scrolling Text Demo ", i, y);
myGLCD.update();
delay(50);
}
}
实验场景图
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
程序七:这个程序是最小字体的演示
/*
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
程序七:这个程序是最小字体的演示
接脚
SCK - 引脚 8
MOSI - 引脚 9
直流 - 引脚 10
RST - 引脚 12
CS - 引脚 11
*/
#include <LCD5110_Graph.h>
LCD5110 myGLCD(8,9,10,12,11);
extern unsigned char TinyFont[];
void setup()
{
myGLCD.InitLCD();
myGLCD.setFont(TinyFont);
}
void loop()
{
myGLCD.print(" !"#$%&'()*+,-./", CENTER, 0);
myGLCD.print("0123456789:;<=>?", CENTER, 6);
myGLCD.print("@ABCDEFGHIJKLMNO", CENTER, 12);
myGLCD.print("PQRSTUVWXYZ[\\]^_", CENTER, 18);
myGLCD.print("`abcdefghijklmno", CENTER, 24);
myGLCD.print("pqrstuvwxyz{|}~ ", CENTER, 30);
myGLCD.update();
while (1);
}
实验场景图
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
程序八:LCD5110屏的综合测试
/*
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
程序八:LCD5110屏的综合测试
接脚
SCK - 引脚 8
MOSI - 引脚 9
直流 - 引脚 10
RST - 引脚 12
CS - 引脚 11
*/
#include <LCD5110_Graph.h>
LCD5110 myGLCD(8,9,10,12,11);
extern unsigned char SmallFont[];
extern unsigned char TinyFont[];
extern uint8_t arduino_logo[];
extern uint8_t The_End[];
extern uint8_t pacman1[];
extern uint8_t pacman2[];
extern uint8_t pacman3[];
extern uint8_t pill[];
float y;
uint8_t* bm;
int pacy;
void setup()
{
myGLCD.InitLCD();
myGLCD.setFont(SmallFont);
randomSeed(analogRead(7));
}
void loop()
{
myGLCD.clrScr();
myGLCD.drawBitmap(0, 0, arduino_logo, 84, 48);
myGLCD.update();
delay(2000);
myGLCD.clrScr();
myGLCD.print("LCD5110_Graph", CENTER, 0);
myGLCD.print("DEMO", CENTER, 20);
myGLCD.drawRect(28, 18, 56, 28);
for (int i=0; i<6; i++)
{
myGLCD.drawLine(57, 18+(i*2), 83-(i*3), 18+(i*2));
myGLCD.drawLine((i*3), 28-(i*2), 28, 28-(i*2));
}
myGLCD.setFont(TinyFont);
myGLCD.print("(C)2015 by", CENTER, 36);
myGLCD.print("Henning Karlsen", CENTER, 42);
myGLCD.update();
delay(5000);
myGLCD.clrScr();
for (int i=0; i<48; i+=2)
{
myGLCD.drawLine(0, i, 83, 47-i);
myGLCD.update();
}
for (int i=83; i>=0; i-=2)
{
myGLCD.drawLine(i, 0, 83-i, 47);
myGLCD.update();
}
delay(2000);
myGLCD.clrScr();
myGLCD.drawRect(0, 0, 83, 47);
for (int i=0; i<48; i+=4)
{
myGLCD.drawLine(0, i, i*1.75, 47);
myGLCD.update();
}
for (int i=0; i<48; i+=4)
{
myGLCD.drawLine(83, 47-i, 83-(i*1.75), 0);
myGLCD.update();
}
delay(2000);
myGLCD.clrScr();
for (int i=0; i<8; i++)
{
myGLCD.drawRoundRect(i*3, i*3, 83-(i*3), 47-(i*3));
myGLCD.update();
}
delay(2000);
myGLCD.clrScr();
for (int i=0; i<17; i++)
{
myGLCD.drawCircle(41, 23, i*3);
myGLCD.update();
}
delay(2000);
myGLCD.clrScr();
myGLCD.drawRect(0, 0, 83, 47);
myGLCD.drawLine(0, 23, 84, 23);
myGLCD.drawLine(41, 0, 41, 47);
for (int c=0; c<4; c++)
{
for (int i=0; i<84; i++)
{
y=i*0.017453292519943295769236907684886;
myGLCD.invPixel(i, (sin(y*6)*20)+23);
myGLCD.update();
delay(20);
}
}
delay(2000);
for (int pc=0; pc<3; pc++)
{
pacy=random(0, 28);
for (int i=-20; i<84; i++)
{
myGLCD.clrScr();
for (int p=4; p>((i+20)/20); p--)
myGLCD.drawBitmap(p*20-8, pacy+7, pill, 5, 5);
switch(((i+20)/3) % 4)
{
case 0: bm=pacman1;
break;
case 1: bm=pacman2;
break;
case 2: bm=pacman3;
break;
case 3: bm=pacman2;
break;
}
myGLCD.drawBitmap(i, pacy, bm, 20, 20);
myGLCD.update();
delay(25);
}
}
for (int i=0; i<25; i++)
{
myGLCD.clrScr();
myGLCD.drawBitmap(0, i-24, The_End, 84, 24);
myGLCD.update();
delay(100);
}
myGLCD.setFont(SmallFont);
myGLCD.print("Runtime (ms):", CENTER, 32);
myGLCD.printNumI(millis(), CENTER, 40);
myGLCD.update();
for (int i=0; i<5; i++)
{
myGLCD.invert(true);
delay(1000);
myGLCD.invert(false);
delay(1000);
}
}
Graphics.c
const unsigned char arduino_logo[] ={
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xF8, 0xFC, 0xFC, // 0x0010 (16) pixels
0xFE, 0xFE, 0x7F, 0x7F, 0x7F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x7F, 0x7F, 0x7F, 0xFE, 0xFE, 0xFE, // 0x0020 (32) pixels
0xFC, 0xFC, 0xF8, 0xF0, 0xF0, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, // 0x0030 (48) pixels
0xF0, 0xF0, 0xF8, 0xFC, 0xFC, 0xFE, 0xFE, 0xFE, 0x7F, 0x7F, 0x7F, 0x3F, 0x3F, 0x3F, 0x3F, 0x7F, // 0x0040 (64) pixels
0x7F, 0x7F, 0x7F, 0xFE, 0xFE, 0xFC, 0xFC, 0xF8, 0xF8, 0xF0, 0xE0, 0xC0, 0x86, 0x06, 0x06, 0x00, // 0x0050 (80) pixels
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0060 (96) pixels
0x1F, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // 0x0070 (112) pixels
0x80, 0x80, 0x00, 0x00, 0x01, 0x01, 0x03, 0x0F, 0x1F, 0x3F, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC, 0xFE, // 0x0080 (128) pixels
0xFF, 0xFF, 0xFF, 0x3F, 0x1F, 0x0F, 0x03, 0x01, 0x01, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0xF8, // 0x0090 (144) pixels
0xF8, 0xF8, 0xF8, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x1F, 0xFF, 0xFF, 0xFF, // 0x00A0 (160) pixels
0xFF, 0xFF, 0xFC, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x7F, 0xFF, // 0x00B0 (176) pixels
0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x07, 0x07, 0x07, // 0x00C0 (192) pixels
0x07, 0x07, 0x07, 0x07, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xF0, 0xF8, 0xFE, 0xFF, // 0x00D0 (208) pixels
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xF8, 0xF0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x07, // 0x00E0 (224) pixels
0x07, 0x07, 0x07, 0x3F, 0x3F, 0x3F, 0x3F, 0x07, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, // 0x00F0 (240) pixels
0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x0100 (256) pixels
0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0x7F, 0xFF, 0xFE, 0xFE, 0xFC, 0xFC, // 0x0110 (272) pixels
0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xFC, 0xFC, 0xFC, 0xFE, 0xFF, 0x7F, 0x7F, 0x3F, 0x3F, // 0x0120 (288) pixels
0x1F, 0x0F, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x3F, 0x7F, // 0x0130 (304) pixels
0x7F, 0xFF, 0xFE, 0xFC, 0xFC, 0xFC, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xFC, 0xFC, 0xFE, // 0x0140 (320) pixels
0xFE, 0xFF, 0x7F, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x0150 (336) pixels
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0x80, 0x00, 0x00, // 0x0160 (352) pixels
0x00, 0x00, 0xC1, 0xC1, 0xC1, 0xC1, 0xC1, 0xC1, 0x81, 0x81, 0x01, 0x01, 0xC1, 0xC1, 0xC0, 0xC0, // 0x0170 (368) pixels
0xC0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0x80, 0x00, // 0x0180 (384) pixels
0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC1, 0xC1, 0x01, 0x01, 0xC1, 0xC1, 0xC1, 0x01, 0x01, // 0x0190 (400) pixels
0x01, 0xC1, 0xC1, 0x01, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0xC0, 0xC0, 0x80, 0x80, 0x00, 0x00, 0x00, // 0x01A0 (416) pixels
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF8, 0xFF, 0x3F, 0x3B, // 0x01B0 (432) pixels
0x3F, 0x7F, 0xFE, 0xF0, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x1C, 0x3C, 0xFF, 0xFF, 0xC7, 0x00, 0x00, // 0x01C0 (448) pixels
0xFF, 0xFF, 0xFF, 0xE0, 0xE0, 0xF1, 0x7F, 0x3F, 0x1F, 0x00, 0x3F, 0x7F, 0xFF, 0xE0, 0xC0, 0xE0, // 0x01D0 (464) pixels
0xFF, 0x7F, 0x3F, 0x00, 0x00, 0xE0, 0xE0, 0xFF, 0xFF, 0xFF, 0xE0, 0xE0, 0xC0, 0x00, 0x00, 0xFF, // 0x01E0 (480) pixels
0xFF, 0x07, 0x0F, 0x3E, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x3F, 0x7F, 0xFF, 0xE0, 0xC0, 0xE1, 0x7F, // 0x01F0 (496) pixels
0x7F, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
const unsigned char The_End[] ={
0x00, 0x80, 0x80, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xE0, 0x60, 0x00, 0x00, // 0x0010 (16) pixels
0x80, 0xC0, 0xC0, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0xC0, 0xC0, 0xE0, // 0x0020 (32) pixels
0xC0, 0xC0, 0xC0, 0xC0, 0xE0, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0xE0, // 0x0030 (48) pixels
0xE0, 0xC0, 0xC0, 0xC0, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x80, 0x80, 0xC0, 0xC0, 0xC0, 0x00, 0x00, // 0x0040 (64) pixels
0x00, 0x00, 0x80, 0xE0, 0xF0, 0xF0, 0x60, 0x40, 0xF0, 0xF0, 0xF0, 0xF0, 0xE0, 0xE0, 0xC0, 0xC0, // 0x0050 (80) pixels
0x80, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x81, 0xFC, 0xFF, 0x0F, 0x03, 0x00, 0x00, 0x00, // 0x0060 (96) pixels
0xEE, 0x6F, 0x67, 0xFF, 0xFF, 0x7F, 0x71, 0x30, 0xF0, 0xFF, 0x3F, 0x39, 0x38, 0x18, 0x00, 0x01, // 0x0070 (112) pixels
0x00, 0xF8, 0xFF, 0x1F, 0x0F, 0x0C, 0x0D, 0x8D, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, // 0x0080 (128) pixels
0x00, 0xC0, 0xFF, 0x7F, 0x0F, 0x0C, 0x0D, 0x0D, 0x84, 0x80, 0x80, 0x07, 0x07, 0x83, 0xFF, 0xFF, // 0x0090 (144) pixels
0x1F, 0x3F, 0xFE, 0xF8, 0xF8, 0xFE, 0xDF, 0x03, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0x1F, 0x00, // 0x00A0 (160) pixels
0x00, 0x80, 0x81, 0xC3, 0xE7, 0x7F, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x06, 0x07, 0x07, 0x03, 0x00, // 0x00B0 (176) pixels
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x0F, 0x07, 0x03, 0x00, 0x00, 0x0F, 0x0F, 0x07, 0x00, // 0x00C0 (192) pixels
0x00, 0x06, 0x06, 0x3F, 0x1F, 0x0F, 0x0F, 0x0E, 0x06, 0x06, 0x06, 0x07, 0x07, 0x03, 0x00, 0x00, // 0x00D0 (208) pixels
0x00, 0x00, 0x06, 0x1F, 0x3F, 0x1F, 0x0F, 0x0E, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x03, 0x00, // 0x00E0 (224) pixels
0x06, 0x0F, 0x07, 0x01, 0x00, 0x00, 0x00, 0x01, 0x0F, 0x07, 0x03, 0x00, 0x00, 0x18, 0x1C, 0x1F, // 0x00F0 (240) pixels
0x0F, 0x07, 0x06, 0x07, 0x03, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
};
const unsigned char pacman1[] ={
0x80, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7E, 0x3E, 0x1C, // 0x0010 (16) pixels
0x0C, 0x00, 0x00, 0x00, 0x1F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF9, // 0x0020 (32) pixels
0xF0, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x07, 0x0F, // 0x0030 (48) pixels
0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0x03, 0x03, 0x00, 0x00, 0x00,
};
const unsigned char pacman2[] ={
0x80, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0x7C, // 0x0010 (16) pixels
0x7C, 0x38, 0x20, 0x00, 0x1F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF9, // 0x0020 (32) pixels
0xF9, 0xF0, 0xF0, 0xE0, 0xE0, 0xC0, 0x40, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x07, 0x0F, // 0x0030 (48) pixels
0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0x03, 0x03, 0x01, 0x00, 0x00,
};
const unsigned char pacman3[] ={
0x80, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFC, // 0x0010 (16) pixels
0xF8, 0xF0, 0xE0, 0x80, 0x1F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0020 (32) pixels
0xFF, 0xFF, 0xFF, 0xFF, 0xFB, 0xF9, 0x79, 0x19, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x07, 0x0F, // 0x0030 (48) pixels
0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00,
};
const unsigned char pill[] ={
0x0E, 0x1F, 0x1F, 0x1F, 0x0E,
};
实验场景图