CAVEDU教育團隊技術部落格 / Arduino開發板與實作

Arduino Serial Plotter 玩玩看~ 一元二次函式圖形

✍ CAVEDU 阿吉 - 雜工📅 2015-11-18👁 1,161

Arduino 1.6.6 的新功能就是 Serial plotter,可以把數值直接顯示成圖表了,QQ。這個功能讓好多玩家望穿秋水啊,不然要做資料視覺化只能使外部程式例如 Processing  或 python 進行後續處理。

今天就來玩玩看吧,以下是使用 Serial plotter 繪製一元二次函式圖形的結果,很棒吧

001

可看到語法一樣是 Serial.println(),只是要用Serial plotter 才能看到畫面。

實際測試的狀況下如果同時用 Serial.print 顯示字串的話,Serial plotter 會沒有畫面,另一方面,Serial monitor 與 Serial plotter 無法同時開啟,請注意喔

002

// please open serial potter to see the sine wave~
#include "math.h"

void setup() {
  Serial.begin(9600);
}

void loop() {
  for (double i = -10.0; i <= 10.0 ; i += 0.1) {
    Serial.println(pow(i, 2) + 2 * i + 1);
    delay(10);
  }
}

延伸閱讀:Arduino 軟體更新,命令列工具與序列資料繪圖器新登場

本文發表於Arduino開發板與實作,並標記arduino。

相關文章 📎

打造虛擬鍵盤手勢控制音樂播放器--- 使用Arduino 首次接觸就上手

2024-11-06

《Arduino首次接觸就上手》的進階教學 追憶鳥山明:OLED螢幕上的經典重現

2024-04-23

使用DF燈光/馬達控制板,透過電腦來控制馬達轉速

2022-04-01

【Arduino首次接觸就上手】快速執行AI圖像辨識

2021-11-23

留言 💬 (0)

還沒有留言,來當第一個。