标签:
最近在开发过程中,用到了Arduino开发板以及其IDE:Arduino,这个IDE使用起来很方便,编码也很简单,但有一点美中不足的是Arduino只能输出数值,不能绘图,所以就用到了另外一款串口调试软件----SerialChart.
废话不多说,直接上程序。
Arduino程序
1 void setup() { 2 // put your setup code here, to run once: 3 Serial.begin(9600); 4 } 5 6 void loop() { 7 // put your main code here, to run repeatedly: 8 int sensorValue0=analogRead(A0); 9 sensorValue0=sensorValue0*4; 10 int sensorValue1=analogRead(A1); 11 sensorValue1=sensorValue1*4; 12 int sensorValue2=analogRead(A2); 13 sensorValue2=sensorValue2*4; 14 15 Serial.print(sensorValue2,DEC); 16 Serial.print(‘,‘); 17 Serial.print(sensorValue0,DEC); 18 Serial.print(‘,‘); 19 Serial.print(sensorValue1); 20 Serial.print(","); 21 Serial.println(" "); 22 delay(100); 23 }
这里需要注意的是在每行最后一个数据出后,首先要打印逗号,再打印换行符,我看其他很多教程上都没有逗号,这样就会使最后一个数据无法绘制图形
Arduino配置文件
1 [_setup_] 2 port=COM6 3 baudrate=9600 4 5 width=10000 6 height=4000 7 background_color = white 8 9 grid_h_origin = 3000 10 grid_h_step = 1 11 grid_h_color = #EEE 12 grid_h_origin_color = #CCC 13 14 grid_v_origin =10 15 grid_v_step =15 16 grid_v_color = #EEE 17 grid_v_origin_color=#CCC 18 [_default_] 19 min=0 20 max=3000 21 22 23 [sensorValue2] 24 color=blue 25 26 27 [sensorValue0] 28 color=pink 29 30 31 32 [sensorValue1] 33 color=gold
运行结果,
标签:
原文地址:http://www.cnblogs.com/zzu-liulei/p/5942838.html