<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-CN">
		<id>http:///https//wiki.microduino.cn/index.php?action=history&amp;feed=atom&amp;title=OLED%E6%98%BE%E7%A4%BA%E8%B6%85%E5%A3%B0%E6%B3%A2%E8%B7%9D%E7%A6%BB</id>
		<title>OLED显示超声波距离 - 版本历史</title>
		<link rel="self" type="application/atom+xml" href="http:///https//wiki.microduino.cn/index.php?action=history&amp;feed=atom&amp;title=OLED%E6%98%BE%E7%A4%BA%E8%B6%85%E5%A3%B0%E6%B3%A2%E8%B7%9D%E7%A6%BB"/>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=OLED%E6%98%BE%E7%A4%BA%E8%B6%85%E5%A3%B0%E6%B3%A2%E8%B7%9D%E7%A6%BB&amp;action=history"/>
		<updated>2026-06-13T08:59:33Z</updated>
		<subtitle>本wiki的该页面的版本历史</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>https//wiki.microduino.cn/index.php?title=OLED%E6%98%BE%E7%A4%BA%E8%B6%85%E5%A3%B0%E6%B3%A2%E8%B7%9D%E7%A6%BB&amp;diff=26311&amp;oldid=prev</id>
		<title>1196357542@qq.com：创建页面，内容为“{| style=&quot;width: 800px;&quot; |- | &lt;p style=&quot;color: #4F4E4E;font-size:220%&quot;&gt;'''Sensor-Ultrasonic+点阵显示超声波距离'''&lt;/p&gt; &lt;br&gt; 本示例给出了将超声波传…”</title>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=OLED%E6%98%BE%E7%A4%BA%E8%B6%85%E5%A3%B0%E6%B3%A2%E8%B7%9D%E7%A6%BB&amp;diff=26311&amp;oldid=prev"/>
				<updated>2018-06-07T03:37:40Z</updated>
		
		<summary type="html">&lt;p&gt;创建页面，内容为“{| style=&amp;quot;width: 800px;&amp;quot; |- | &amp;lt;p style=&amp;quot;color: #4F4E4E;font-size:220%&amp;quot;&amp;gt;&amp;#039;&amp;#039;&amp;#039;Sensor-Ultrasonic+点阵显示超声波距离&amp;#039;&amp;#039;&amp;#039;&amp;lt;/p&amp;gt; &amp;lt;br&amp;gt; 本示例给出了将超声波传…”&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{| style=&amp;quot;width: 800px;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;p style=&amp;quot;color: #4F4E4E;font-size:220%&amp;quot;&amp;gt;'''Sensor-Ultrasonic+点阵显示超声波距离'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
本示例给出了将超声波传感器测得的距离值在OLED上显示出来的方法，显示距离的单位为毫米&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;p style=&amp;quot;color: #E87E05;font-size:135%&amp;quot;&amp;gt;所需硬件&amp;lt;/p&amp;gt;&lt;br /&gt;
*[[mCenter+]]&lt;br /&gt;
*[[Sensor-Ultrasonic+]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;p style=&amp;quot;color: #E87E05;font-size:135%&amp;quot;&amp;gt;电路搭建&amp;lt;/p&amp;gt;&lt;br /&gt;
将Ultrasonic+传感器接到Hub的IIC引脚。&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
将mCenter+（或者用Battery、Core、Hub堆叠在一起代替mCenter+，代替后核心选择core）通过MicroUSB数据线接入电脑，核心选择core+ 5V。初次使用请参考：[[AVR核心：Getting_started/zh|Getting Started]]。&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;p style=&amp;quot;color: #E87E05;font-size:135%&amp;quot;&amp;gt;代码&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;Microduino_Ultrasonic.h&amp;gt;         //引用超声波库文件&lt;br /&gt;
#include &amp;lt;U8glib.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE);     //设置OLED型号&lt;br /&gt;
//-------字体设置，大、中、小&lt;br /&gt;
#define setFont_L u8g.setFont(u8g_font_timB18)&lt;br /&gt;
#define setFont_M u8g.setFont(u8g_font_fixed_v0r)&lt;br /&gt;
#define setFont_S u8g.setFont(u8g_font_chikitar)&lt;br /&gt;
&lt;br /&gt;
uint16_t Distance, lastDis;  //定义变量&lt;br /&gt;
uint32_t oledTime = millis();&lt;br /&gt;
Ultrasonic Ultrasonic1(ULTRASONIC_ADDR_1);//将Ultrasonic实例化&lt;br /&gt;
&lt;br /&gt;
void setup() {&lt;br /&gt;
  Serial.begin(115200);  // 串口初始化&lt;br /&gt;
  Ultrasonic1.begin();  //超声波初始化&lt;br /&gt;
  delay(2000);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop() {&lt;br /&gt;
  Distance = Ultrasonic1.getDistance(); //获取超声波测得的距离&lt;br /&gt;
  Serial.println(Distance);               //串口打印距离值&lt;br /&gt;
  oled(Distance) ;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void oled(uint16_t Dis) {&lt;br /&gt;
  u8g.firstPage();&lt;br /&gt;
  do {&lt;br /&gt;
    u8g.setDefaultForegroundColor();&lt;br /&gt;
&lt;br /&gt;
    setFont_L;                       //设置字体&lt;br /&gt;
    u8g.setPrintPos(10, 45);          //设置文字开始坐标&lt;br /&gt;
    u8g.print(Dis);       //&lt;br /&gt;
    u8g.setPrintPos(112, 45);          //设置文字开始坐标&lt;br /&gt;
    setFont_M;                       //设置字体&lt;br /&gt;
    u8g.print(&amp;quot;mm&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  while ( u8g.nextPage() );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Sensor-Ultrasonic+|返回Sensor-Ultrasonic+ 界面]]&lt;/div&gt;</summary>
		<author><name>1196357542@qq.com</name></author>	</entry>

	</feed>