Code Maintenance & Programming Rules

 This guide outlines essential best practices spanning code style, architectural design, debugging, testing, performance, and portability—all aimed at reducing the long-term cognitive load of code maintenance. 🎨 1. Style Code is written for humans to read, and only incidentally for computers to execute. Variable Naming : Use descriptive names for global variables, and short names for local variables. Precision and Consistency : Use active names for functions (e.g., calculateTotal ). Above all, keep your coding style consistent throughout the project. Structure & Expressions : Use a consistent indentation and brace ( {} ) style to show program structure visually. Use the natural form for expressions. Use parentheses to make the semantics unambiguous. Break up overly complex expressions to keep them clear. Side Effects & Macros : Beware of functions with side effects. Avoid function-like macros; if unavoidable, parenthesize the macro body and arguments carefully. Magic Numbe...

Arduino 序列繪圖家 (Arduino serial plotter)

Aduino 序列繪圖家是在Arduino 1.6.6增加的功能,以往要將感測器收集到的資料化成圖時,往往都使用 Porcessing 來輔助,但Arduino 1.6.6以後的版本就可以直接使用序列繪圖家來呈現了。一起試試看畫底下的三角函數圖形吧。


硬體材料:
Arduino UNO x 1

語法說明:
單一資料輸出時
Serial.println(data1);

兩筆資料要同時輸出時
Serial.print(data1);
Serial.print(" ");
Serial.println(data2);
或是
Serial.print(data1);
Serial.print("\t");
Serial.println(data2); 

範例程式:


從Arduino IDE 開啟序列繪圖家

示範影片(Demo videos):

若您覺得文章寫得不錯,請點選文章上的廣告,來支持小編,謝謝。

If you like this post, please click the ads on the blog or buy me a coffee. Thank you very much.

留言

這個網誌中的熱門文章