[問題] arduion變數監看問題

看板ASM (組合語言)作者 (溫柔殺手)時間7年前發表 (2018/05/07 14:56), 7年前編輯推噓4(4012)
留言16則, 5人參與, 7年前最新討論串1/1
各位版上的大大晚上好。 我正在練習一個LED自保持,直到Button 再次Taggle時才改變LED狀態的程式 目前遇到的問題如下,如果按鈕按的時間比較長,動作就會異常。 目前推估應該是Loop持續執行,導致變數一直被更新,所以動作異常。 所以想問一下有沒有哪一個IDE可以查看變數變化? 我的環境及程式如下。 HW:Arduino UNO version 3 IDE: Arduino 1.8.5 for windwos // constants won't change. They're used here to set pin numbers: const int buttonPin = 2; // the number of the pushbutton pin const int ledPin = 13; // the number of the LED pin // variables will change: int buttonState = 0; // variable for reading the pushbutton status int LEDstatus = 0; //if LEDstaus = 0, LED off, LEDstatu = 1, LED on void setup() { // initialize the LED pin as an output: pinMode(ledPin, OUTPUT); // initialize the pushbutton pin as an input: pinMode(buttonPin, INPUT); } void loop() { // read the state of the pushbutton value: buttonState = digitalRead(buttonPin); // check if the pushbutton is pressed. If it is, the buttonState is HIGH: if (buttonState == HIGH) { // turn LED on: LEDstatus = 1 - LEDstatus; } if (LEDstatus == 1){ digitalWrite(ledPin, HIGH); } else { // turn LED off: digitalWrite(ledPin, LOW); } } -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 123.195.98.141 ※ 文章網址: https://www.ptt.cc/bbs/ASM/M.1525705009.A.5E7.html ※ 編輯: yimean (123.195.98.141), 05/07/2018 23:00:59

05/07 23:12, 7年前 , 1F
你先跑DigitalReadSerial這個範例,開監控視窗看
05/07 23:12, 1F

05/07 23:13, 7年前 , 2F
然後再看Debounce這個範例
05/07 23:13, 2F

05/07 23:33, 7年前 , 3F

05/07 23:33, 7年前 , 4F
5%9c%a8-arduino-uno-r3-%e8%aa%bf%e8%a9%a6debug%e8%8d
05/07 23:33, 4F

05/07 23:33, 7年前 , 5F
%89%e7%a8%bf%e7%a2%bc/
05/07 23:33, 5F

05/08 10:08, 7年前 , 6F
@god145145請問一下您說的監控視窗是指串連列阜的嗎?
05/08 10:08, 6F

05/08 10:08, 7年前 , 7F
可是我的動作都是在本地完成,並沒有跟電腦做溝通。
05/08 10:08, 7F

05/08 14:03, 7年前 , 8F
你想要監看就是連電腦,把變數進去顯示啊
05/08 14:03, 8F

05/08 14:04, 7年前 , 9F
05/08 14:04, 9F

05/08 14:22, 7年前 , 10F
樓主習慣寫在桌上電腦,筆電執行的程式吧!那才會容易監
05/08 14:22, 10F

05/08 14:22, 7年前 , 11F
看。
05/08 14:22, 11F

05/08 14:26, 7年前 , 12F
Arduino是另一台獨立的電腦,執行中的變數另一台電腦是無
05/08 14:26, 12F

05/08 14:26, 7年前 , 13F
法監看的,除非你加寫程式碼主動列印或傳輸出來。
05/08 14:26, 13F

05/08 14:31, 7年前 , 14F
不然,就要用模擬器了!但我沒聽過有Arduino和相關元件
05/08 14:31, 14F

05/08 14:31, 7年前 , 15F
的模擬器耶!
05/08 14:31, 15F

05/08 20:54, 7年前 , 16F
原來如此,感謝各位大大的解惑。
05/08 20:54, 16F
文章代碼(AID): #1Qy6anNd (ASM)
文章代碼(AID): #1Qy6anNd (ASM)