Arduino Struct 使用範例

Arduino Struct 使用範例

更新於 發佈於 閱讀時間約 2 分鐘

介紹如何在Arduino 使用 Struct ,以下是範例程式碼

typedef struct

{

int red;

int green;

int blue;

}RGB; //這裡是先定義RGB的結構

RGB color; //color 為RGB結構的變數

void setup() {

Serial.begin(9600); //arduino 連接電腦

color.red=100; //color.red 放入100

color.green=200; //color.green 放入200

color.blue=120; //color.blue 放入120

Serial.println(color.red); //print 在序列阜視窗

Serial.println(color.green);

Serial.println(color.blue);

}

以上為Arduino struct的簡單範例


avatar-img
程式_筆記
3會員
28內容數
寫程式的筆記,把一些自學寫過的程式放上來
留言
avatar-img
留言分享你的想法!
程式_筆記 的其他內容
ESP32 連接 GPS模組 讀取gps 模組資料
本文來介紹(紀錄)如何用python 寫出目前時間
字典中的候選人居住地排列沒有按照字母排,且有重複,想印出候選人居住地並依字母順序排列
簡單介紹 如何在list中放入dictionary
python dictionary 簡單用法
ESP32 連接 GPS模組 讀取gps 模組資料
本文來介紹(紀錄)如何用python 寫出目前時間
字典中的候選人居住地排列沒有按照字母排,且有重複,想印出候選人居住地並依字母順序排列
簡單介紹 如何在list中放入dictionary
python dictionary 簡單用法