女人被狂躁到高潮视频免费无遮挡,内射人妻骚骚骚,免费人成小说在线观看网站,九九影院午夜理论片少妇,免费av永久免费网址

當(dāng)前位置:首頁(yè) > 工業(yè)控制 > 電路設(shè)計(jì)項(xiàng)目集錦
[導(dǎo)讀]我們將使用Arduino創(chuàng)建一個(gè)簡(jiǎn)單的“Dino Run”游戲,并使用PCBX在線模擬。

把經(jīng)典的Dino Run變成親身體驗(yàn)!使用Arduino Nano,以有趣,引人入勝的方式將互動(dòng)游戲帶入生活!

我們將使用Arduino創(chuàng)建一個(gè)簡(jiǎn)單的“Dino Run”游戲,并使用PCBX在線模擬。

硬件需求

?Arduino板(如Arduino Uno)

?OLED顯示屏(如SSD1306)

?按鈕

?電阻器(10kΩ按鈕)

?連接電線

軟件需求

?Arduino IDE編碼

?用于模擬項(xiàng)目的PCBX在線模擬器

接線圖

在深入編碼部分之前,讓我們先設(shè)置電路。這是連接OLED顯示器和Arduino按鈕的基本接線圖:

OLED顯示器連接:

?VCC到Arduino 5V

?GND到Arduino GND

?SCL到Arduino A5 (I2C時(shí)鐘)

?SDA到Arduino A4 (I2C數(shù)據(jù))

按鈕連接:

?一端到Arduino引腳2

?另一側(cè)到GND(帶上拉電阻連接5V)

?用PCBX模擬項(xiàng)目

要在線模擬這個(gè)Arduino項(xiàng)目:

?訪問(wèn)PCBX:進(jìn)入PCBX在線仿真網(wǎng)站。

?模擬項(xiàng)目在線:項(xiàng)目代碼和詳細(xì)信息在這里:

結(jié)論

現(xiàn)在,您已經(jīng)使用Arduino創(chuàng)建了一個(gè)簡(jiǎn)單的“Dino Run”游戲,并使用PCBX在線模擬了它。這個(gè)項(xiàng)目不僅展示了基本的游戲機(jī)制,還使您熟悉使用I2C設(shè)備,如OLED顯示器和Arduino。你可以隨意修改游戲。

代碼

#include

#include

#include

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

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

#define BUTTON_PIN 2 // Pin for the jump button

// Declaration for an SSD1306 display connected to I2C (Wire)

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

// Bitmap data for the dinosaur image

const unsigned char dinosaur[] PROGMEM = {

0x00,0x00,0xFF,0x80,0x00,0x01,0xFF,0x80,0x00,0x03,0xFF,0xC0,0x00,0x03,0x3F,0xC0,

0x00,0x03,0xFF,0xC0,0x00,0x03,0xFF,0xC0,0x00,0x03,0xFF,0xC0,0x00,0x03,0xFF,0xC0,

0x00,0x03,0xF0,0x00,0x00,0x07,0xFF,0x00,0xC0,0x0F,0xFF,0x00,0xC0,0x3F,0xF0,0x00,

0xE0,0xFF,0xF0,0x00,0xF1,0xFF,0xFC,0x00,0xFF,0xFF,0xFE,0x00,0x7F,0xFF,0xF0,0x00,

0x3F,0xFF,0xF0,0x00,0x1F,0xFF,0xF0,0x00,0x0F,0xFF,0xE0,0x00,0x07,0xFF,0xE0,0x00,

0x03,0xFF,0xC0,0x00,0x03,0xFF,0xC0,0x00,0x03,0xF8,0x70,0x00,0x03,0x80,0x00,0x00,

0x03,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x80,0x00,0x00,};

int dinosaurX = 10; // Initial x position of the dinosaur

int dinosaurY = 35; // Initial y position of the dinosaur

int dinosaurHeight = 26; // Height of the dinosaur image

int dinosaurWidth = 27; // Width of the dinosaur image

bool jumping = false; // Flag to indicate if the dinosaur is jumping

int jumpHeight = 5; // Jump height in pixels

int jumpSpeed = 10; // Speed of the jump

int jumpCounter = 0; // Jump counter

bool buttonPressed = false; // Flag to indicate if the button has been pressed

bool gameOver = false; // Game over flag

int score = 0; // Score

int obstacleX = SCREEN_WIDTH; // Initial x position of the obstacle

int obstacleY = 40; // y position of the obstacle

int obstacleWidth = 10; // Width of the obstacle

int obstacleHeight = 20; // Height of the obstacle

int obstacleSpeed = 8; // Speed of the obstacle

void setup() {

pinMode(BUTTON_PIN, INPUT_PULLUP); // Set the button pin as input with pull-up resistor

if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // 0x3C is the I2C address of the OLED display

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

for(;;); // Do not proceed

}

display.clearDisplay(); // Clear the display

display.setTextSize(1); // Set text size

display.setTextColor(WHITE); // Set text color

}

void loop() {

if (gameOver) {

display.clearDisplay();

display.setCursor(0, 0);

display.println("Game Over!");

display.println("Score: " + String(score));

display.display();

delay(2000);

return;

}

// Check if the button is pressed (button is normally HIGH, LOW when pressed)

if (!jumping && !buttonPressed && digitalRead(BUTTON_PIN) == LOW) {

buttonPressed = true;

jumping = true;

jumpCounter = 0; // Reset jump counter when starting a jump

}

if (jumping) {

if (jumpCounter < jumpHeight) {

// Ascend phase

dinosaurY -= jumpSpeed;

} else if (jumpCounter >= jumpHeight && jumpCounter < jumpHeight * 2) {

// Descend phase

dinosaurY += jumpSpeed;

} else {

// End jump

jumping = false;

dinosaurY = 35; // Reset the dinosaur to the initial y position

buttonPressed = false; // Reset button pressed flag

}

jumpCounter++;

}

// Move the obstacle

obstacleX -= obstacleSpeed;

if (obstacleX < -obstacleWidth) {

obstacleX = SCREEN_WIDTH;

score++;

}

// Collision detection

if (dinosaurX < obstacleX + obstacleWidth && dinosaurX + dinosaurWidth > obstacleX &&

dinosaurY < obstacleY + obstacleHeight && dinosaurY + dinosaurHeight > obstacleY) {

gameOver = true;

}

display.clearDisplay(); // Clear the display

display.drawBitmap(dinosaurX, dinosaurY, dinosaur, dinosaurWidth, dinosaurHeight, WHITE); // Draw the dinosaur

display.fillRect(obstacleX, obstacleY, obstacleWidth, obstacleHeight, WHITE); // Draw the obstacle

drawRoad(); // Draw the road

display.setCursor(0, 0);

display.print("Score: ");

display.println(score);

display.display(); // Update the display

delay(10); // Small delay for smoother animation

}

void drawCross(int x, int y, int width, int height) {

display.drawLine(x, y, x, y + height, WHITE);

display.drawLine(x + width, y, x + width, y + height, WHITE);

display.drawLine(x, y + height / 2, x + width, y + height / 2, WHITE);

}

void drawRoad() {

int roadWidth = 130; // Width of the road (in pixels)

int roadHeight = 2; // Height of the road (in pixels)

int roadX = (SCREEN_WIDTH - roadWidth) / 2; // Center the road horizontally

int roadY = SCREEN_HEIGHT - roadHeight; // Position the road at the bottom

display.fillRect(roadX, roadY, roadWidth, roadHeight, WHITE);

int lineSpacing = 10;

for (int i = 0; i < roadWidth; i += lineSpacing) {

display.drawLine(roadX + i, roadY, roadX + i, roadY + roadHeight, BLACK);

}

}

本文編譯自hackster.io

本站聲明: 本文章由作者或相關(guān)機(jī)構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點(diǎn),本站亦不保證或承諾內(nèi)容真實(shí)性等。需要轉(zhuǎn)載請(qǐng)聯(lián)系該專(zhuān)欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請(qǐng)及時(shí)聯(lián)系本站刪除。
換一批
延伸閱讀

為解決使用現(xiàn)有接裝紙分離裝置生產(chǎn)“視窗煙支”時(shí)出現(xiàn)的安裝調(diào)整難度大、耗時(shí)長(zhǎng)、穩(wěn)定性差,煙支接裝紙外觀質(zhì)量缺陷率高等問(wèn)題,設(shè)計(jì)了一種接裝紙三級(jí)分離和控制裝置。通過(guò)接裝紙初步分離、分離定位控制和最終定位輸送裝置模塊化設(shè)計(jì),且...

關(guān)鍵字: 視窗煙支 接裝紙 分離 控制

構(gòu)建了機(jī)載電源特性測(cè)試系統(tǒng) , 包括硬件平臺(tái)和軟件平臺(tái):硬件平臺(tái)用于產(chǎn)生電源特性測(cè)試所需激勵(lì)信號(hào) , 軟件 平臺(tái)實(shí)現(xiàn)電源特性測(cè)試架構(gòu)的 自動(dòng)切換和電源特性的數(shù)據(jù)采集;硬件平臺(tái)由APS15000線性功放 、LVA2500線...

關(guān)鍵字: 電源特性測(cè)試 測(cè)試切換 數(shù)據(jù)采集 自動(dòng)控制

作為業(yè)內(nèi)持續(xù)專(zhuān)注于物聯(lián)網(wǎng)(IoT)芯片開(kāi)發(fā)的廠商,Silicon Labs(芯科科技)自2021年剝離基礎(chǔ)設(shè)施與汽車(chē)(I&A)業(yè)務(wù)后,全力聚焦物聯(lián)網(wǎng)領(lǐng)域。而隨著物聯(lián)網(wǎng)邁向全場(chǎng)景無(wú)縫連接與人工智能(AI)端側(cè)賦能的新階段,...

關(guān)鍵字: 芯科科技 IoT BLE AoA Sub-G AI

永磁同步電機(jī)具有高效節(jié)能 、低噪聲 、高功率密度等顯著優(yōu)點(diǎn) ,特別適用于新能源電動(dòng)汽車(chē)行業(yè) 。針對(duì)城市用輕型 低速電動(dòng)汽車(chē)的應(yīng)用 , 分析了一款內(nèi)置式永磁同步電機(jī)的設(shè)計(jì)方法及特點(diǎn) , 對(duì)汽車(chē)驅(qū)動(dòng)電機(jī)的基本性能及設(shè)計(jì)策略進(jìn)...

關(guān)鍵字: 永磁同步電機(jī) 新能源汽車(chē) 有限元計(jì)算 電機(jī)設(shè)計(jì) 內(nèi)置式

介紹了“W ”型鍋爐的燃燒特性 ,深度調(diào)峰過(guò)程中常見(jiàn)的問(wèn)題及風(fēng)險(xiǎn)點(diǎn) 。結(jié)合某電廠630 MW超臨界機(jī)組在200 MW負(fù) 荷深度調(diào)峰過(guò)程中給煤機(jī)斷煤引起的燃燒惡化工況 ,對(duì)燃燒惡化后的現(xiàn)象 、處理過(guò)程及原因進(jìn)行了全面分...

關(guān)鍵字: “W”型鍋爐 深度調(diào)峰 燃燒惡化 穩(wěn)燃措施

在地鐵供電系統(tǒng)中 ,直流牽引系統(tǒng)故障可能會(huì)導(dǎo)致地鐵列車(chē)失電 ,對(duì)運(yùn)營(yíng)服務(wù)造成嚴(yán)重影響 。地鐵出入場(chǎng)(段)線 的部分直流牽引供電設(shè)備處于露天環(huán)境 , 與正線隧道內(nèi)較為封閉的環(huán)境相比 , 易因外部環(huán)境影響 ,導(dǎo)致設(shè)備故障 。...

關(guān)鍵字: 出入段線 牽引直流開(kāi)關(guān) 電流變化率保護(hù) 跳閘

在現(xiàn)代電力系統(tǒng)中 , 無(wú)論是大電流 、高電壓 、快速運(yùn)行的電源開(kāi)關(guān)系統(tǒng) , 還是高速電機(jī)的驅(qū)動(dòng)系統(tǒng) , 電磁干擾的傳 播一直是系統(tǒng)設(shè)計(jì)的難點(diǎn) 。鑒于此 ,介紹了通過(guò)控制高速開(kāi)關(guān)核心模塊PWM(脈寬調(diào)制)的展頻方式來(lái)減少E...

關(guān)鍵字: 電磁干擾(EMI) 脈寬調(diào)制(PWM) 展頻

水廠作為城市供水系統(tǒng)的重要組成部分 , 其電氣設(shè)計(jì)的合理性和高效性直接關(guān)系到整個(gè)供水系統(tǒng)的穩(wěn)定性和經(jīng) 濟(jì)性 。鑒于此 ,從供配電系統(tǒng) 、設(shè)備選型 、電纜敷設(shè) 、節(jié)能措施及智慧化平臺(tái)等五個(gè)維度 , 結(jié)合現(xiàn)行規(guī)范與工程實(shí)踐...

關(guān)鍵字: 水廠 電氣設(shè)計(jì) 供配電系統(tǒng) 智慧化平臺(tái)

由于負(fù)載的特殊性和運(yùn)行條件的復(fù)雜性 ,海上油氣平臺(tái)的電氣系統(tǒng)功率因數(shù)普遍較低 。這種低功率因數(shù)會(huì)對(duì)電力 系統(tǒng)造成一系列負(fù)面影響 , 包括電能損耗增加 、設(shè)備運(yùn)行效率降低及對(duì)平臺(tái)電力系統(tǒng)的沖擊 。鑒于此 , 結(jié)合具體項(xiàng)目案...

關(guān)鍵字: 油氣平臺(tái) 靜止無(wú)功發(fā)生器(SVG) 功率因數(shù) 無(wú)功補(bǔ)償 改造案例

在電子制造領(lǐng)域,DFM(Design for Manufacturability,可制造性設(shè)計(jì))作為連接研發(fā)與量產(chǎn)的橋梁,通過(guò)在設(shè)計(jì)階段預(yù)判制造風(fēng)險(xiǎn),已成為提升產(chǎn)品良率、降低成本的核心工具。以手機(jī)攝像頭模組封裝工藝為例,...

關(guān)鍵字: DFM BSOB
關(guān)閉