Arduino IDE as Simple Oscilloscope
使用的語法
- Serial.begin(115200);
- Serial.println(變數名稱);
- Serial.print(" ");
程式碼範例-單一變數
void setup() { Serial.begin(115200); } void loop() { for (int i = 0; i <= 250; i+=10) { Serial.println(i); delay(5); } for (int i = 250; i >= 0; i-=10) { Serial.println(i); delay(5); } for (int i = 0; i >= -250; i-=10) { Serial.println(i); delay(5); } for (int i = -250; i <= 0; i+=10) { Serial.println(i); delay(5); } }
程式碼範例-多個變數
int Var1 = 0; int Var2 = 0; void setup() { // put your setup code here, to run once: Serial.begin(115200); } void loop() { for (Var1 = 0,Var2 = 250; Var1 <= 250; Var1+=10) { Serial.print(Var1); Serial.print(" "); Serial.println(Var2); delay(5); } for (Var1 = 250,Var2 = 0; Var1 >= 0; Var1-=10) { Serial.print(Var1); Serial.print(" "); Serial.println(Var2); delay(5); } for (Var1 = 0,Var2 = -250; Var1 >= -250; Var1-=10) { Serial.print(Var1); Serial.print(" "); Serial.println(Var2); delay(5); } for (Var1 = -250,Var2 = 0; Var1 <= 0; Var1+=10) { Serial.print(Var1); Serial.print(" "); Serial.println(Var2); delay(5); } }
應用方面
1.可以看ADC 的讀取資料
2.看計算的數值
3.資料處理
4. ...
參考資料
https://docs.arduino.cc/software/ide-v2/tutorials/ide-v2-serial-plotter
沒有留言:
發佈留言