五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

arduino入門18-進(jìn)階-OLED1306+HCSR04超聲波測距儀#跟著J

2023-07-24 17:43 作者:醉_夢一度  | 我要投稿

//oled


#include <SPI.h>

#include <Wire.h>

#include <Adafruit_GFX.h>

#include <Adafruit_SSD1306.h>


#define SCREEN_WIDTH 128 // OLED display width, in pixels

#define SCREEN_HEIGHT 64 // OLED display height, in pixels


// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)

// The pins for I2C are defined by the Wire-library.

// On an arduino UNO:????A4(SDA), A5(SCL)

// On an arduino MEGA 2560: 20(SDA), 21(SCL)

// On an arduino LEONARDO:??2(SDA),?3(SCL), ...

// On an arduino ESP8266:??D2(SDA)GPIO4,?D1(SCL)GPIO5, ...

#define OLED_RESET???-1 // Reset pin # (or -1 if sharing Arduino reset pin)

#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

//oled


const int TrigPin = 11;

const int EchoPin = 12;

float distance;


void startinfo() {

?display.clearDisplay();


?display.setTextSize(2);???????// Normal 1:1 pixel scale

?display.setTextColor(SSD1306_WHITE);????// Draw white text

?display.setCursor(0, 0);??????// Start at top-left corner

?display.println(F("System"));

?display.setTextSize(2);

?display.setTextColor(SSD1306_BLACK, SSD1306_WHITE); // Draw 'inverse' text

?display.println("booting");


?display.setTextSize(2);???????// Draw 2X-scale text

?display.setTextColor(SSD1306_WHITE);

?display.println("......");


?display.display();


}



void showinfo(String temp) {

?display.clearDisplay();


?display.setTextSize(2);???????// Normal 1:1 pixel scale

?display.setTextColor(SSD1306_WHITE);????// Draw white text

?display.setCursor(0, 0);??????// Start at top-left corner

?display.println(F("Distance"));

?display.setTextSize(2);

?display.setTextColor(SSD1306_BLACK, SSD1306_WHITE); // Draw 'inverse' text

?display.println("CM: ");


?display.setTextSize(2);???????// Draw 2X-scale text

?display.setTextColor(SSD1306_WHITE);

?display.println(temp);


?display.display();


}




void setup()

{ // 初始化串口通信及連接 SR04 的引腳

?Serial.begin(115200);

?// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally

?if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {

??Serial.println(F("SSD1306 allocation failed"));

??for (;;); // Don't proceed, loop forever

?}


?// Show initial display buffer contents on the screen --

?// the library initializes this with an Adafruit splash screen.

?display.display();

?delay(2000); // Pause for 2 seconds

?startinfo() ;

?delay(1000);


?pinMode(TrigPin, OUTPUT);

?// 要檢測引腳上輸入的脈沖寬度,需要先設(shè)置為輸入狀態(tài)

?pinMode(EchoPin, INPUT);

?Serial.println("Ultrasonic sensor:");

}

void loop()

{

?// 產(chǎn)生一個(gè) 10us 的高脈沖去觸發(fā) TrigPin

?digitalWrite(TrigPin, LOW);

?delayMicroseconds(2);

?digitalWrite(TrigPin, HIGH);

?delayMicroseconds(10);

?digitalWrite(TrigPin, LOW);

?// 檢測脈沖寬度,并計(jì)算出距離

?distance = pulseIn(EchoPin, HIGH) / 58.00;

?Serial.print(distance);

?Serial.print("cm");

?Serial.println();

?showinfo(String (distance));

?delay(1000);

}

arduino入門18-進(jìn)階-OLED1306+HCSR04超聲波測距儀#跟著J的評論 (共 條)

分享到微博請遵守國家法律
伊宁县| 南华县| 格尔木市| 南岸区| 乌鲁木齐县| 手游| 深水埗区| 汤原县| 合肥市| 太仓市| 高碑店市| 甘孜| 崇文区| 华坪县| 丰顺县| 尖扎县| 宁南县| 都昌县| 吴桥县| 那曲县| 汝阳县| 广灵县| 惠水县| 济阳县| 肃宁县| 大石桥市| 武定县| 宁河县| 泌阳县| 藁城市| 衡阳县| 拉孜县| 洪湖市| 阿克苏市| 监利县| 博罗县| 白沙| 池州市| 定安县| 宽甸| 海林市|