37款传感器与执行器的提法,在网络上广泛流传,其实Arduino能够兼容的传感器模块肯定是不止这37种的。鉴于本人手头积累了一些传感器和执行器模块,依照实践出真知(一定要动手做)的理念,以学习和交流为目的,这里准备逐一动手尝试系列实验,不管成功(程序走通)与否,都会记录下来—小小的进步或是搞不掂的问题,希望能够抛砖引玉。
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验九十三:0.96寸I2C IIC通信128*64显示器 OLED液晶屏模块
【Arduino】168种传感器模块系列实验(资料代码+图形编程+仿真编程)
实验九十三: 0.96寸I2C IIC通信128*64显示器 OLED液晶屏模块
项目四十五:选择180度旋转模式设置显示重映射
实验开源代码
/*
【Arduino】168种传感器模块系列实验(资料代码+图形编程+仿真编程)
实验九十七: 0.96寸I2C IIC通信128*64显示器 OLED液晶屏模块
项目四十五:选择180度旋转模式设置显示重映射
实验接线:
oled模块 Ardunio Uno
GND---------GND接地线
VCC---------5V 接电源
SDA---------A4
SCL ------- A5
*/
#include <Wire.h>
#include "SSD1306Ascii.h"
#include "SSD1306AsciiWire.h"
// 0X3C+SA0 - 0x3C or 0x3D
#define I2C_ADDRESS 0x3C
// Define proper RST_PIN if required.
#define RST_PIN -1
SSD1306AsciiWire oled;
//------------------------------------------------------------------------------
void setup() {
Wire.begin();
Wire.setClock(400000L);
#if RST_PIN >= 0
oled.begin(&Adafruit128x64, I2C_ADDRESS, RST_PIN);
#else // RST_PIN >= 0
oled.begin(&Adafruit128x64, I2C_ADDRESS);
#endif // RST_PIN >= 0
oled.setFont(Adafruit5x7);
// Use true, normal mode, since default for Adafruit display is remap mode.
oled.displayRemap(true);
oled.clear();
oled.println("Hello world!");
oled.println("displayRemap(false)");
oled.print("for other mode.");
}
//------------------------------------------------------------------------------
void loop() {}
Arduino实验场景图
【Arduino】168种传感器模块系列实验(资料代码+图形编程+仿真编程)
实验九十三: 0.96寸I2C IIC通信128*64显示器 OLED液晶屏模块
项目四十六:显示SSD1306Ascii库的字体样本
实验开源代码
/*
【Arduino】168种传感器模块系列实验(资料代码+图形编程+仿真编程)
实验九十七: 0.96寸I2C IIC通信128*64显示器 OLED液晶屏模块
项目四十六:显示SSD1306Ascii库的字体样本
实验接线:
oled模块 Ardunio Uno
GND---------GND接地线
VCC---------5V 接电源
SDA---------A4
SCL ------- A5
*/
#include <Wire.h>
#include "SSD1306Ascii.h"
#include "SSD1306AsciiWire.h"
// 0X3C+SA0 - 0x3C or 0x3D
#define I2C_ADDRESS 0x3C
// Define proper RST_PIN if required.
#define RST_PIN -1
const char* fontName[] = {
"Arial14",
"Arial_bold_14",
"Callibri11",
"Callibri11_bold",
"Callibri11_italic",
"Callibri15",
"Corsiva_12",
"fixed_bold10x15",
"font5x7",
"font8x8",
"Iain5x7",
"lcd5x7",
"Stang5x7",
"System5x7",
"TimesNewRoman16",
"TimesNewRoman16_bold",
"TimesNewRoman16_italic",
"utf8font10x16",
"Verdana12",
"Verdana12_bold",
"Verdana12_italic",
"X11fixed7x14",
"X11fixed7x14B",
"ZevvPeep8x16"
};
const uint8_t* fontList[] = {
Arial14,
Arial_bold_14,
Callibri11,
Callibri11_bold,
Callibri11_italic,
Callibri15,
Corsiva_12,
fixed_bold10x15,
font5x7,
font8x8,
Iain5x7,
lcd5x7,
Stang5x7,
System5x7,
TimesNewRoman16,
TimesNewRoman16_bold,
TimesNewRoman16_italic,
utf8font10x16,
Verdana12,
Verdana12_bold,
Verdana12_italic,
X11fixed7x14,
X11fixed7x14B,
ZevvPeep8x16
};
uint8_t nFont = sizeof(fontList)/sizeof(uint8_t*);
SSD1306AsciiWire oled;
//------------------------------------------------------------------------------
void setup() {
Wire.begin();
Wire.setClock(400000L);
#if RST_PIN >= 0
oled.begin(&Adafruit128x64, I2C_ADDRESS, RST_PIN);
#else // RST_PIN >= 0
oled.begin(&Adafruit128x64, I2C_ADDRESS);
#endif // RST_PIN >= 0
for (uint8_t i = 0; i < nFont; i++) {
oled.setFont(System5x7);
oled.clear();
oled.println(fontName[i]);
oled.println();
oled.setFont(fontList[i]);
oled.println("*+,-./0123456789:");
oled.println("abcdefghijklmno");
oled.println("ABCDEFGHIJKLMNO");
delay(10000);
}
oled.clear();
oled.print("Done!");
}
void loop() {}
Arduino实验场景图
hacker_2023.07.27
666