看板 ASM 關於我們 聯絡資訊
最近小弟在玩Arduino 想請問各位一個問題,問擾小弟很久了! Arduino UNO 以及 Arduino Leonardo 我都有一個 但是在執行以下程式時遇到了答案不同的情況 int a = 0; int b = 0; void setup() { // put your setup code here, to run once: Serial.begin(9600); } void loop() { // put your main code here, to run repeatedly: Serial.println(a); b = a++; Serial.println(b); delay(2000); } 當我用UNO跑以上的程式時答案是a = 0, b = 0 → a = 1, b = 1 當我用Leonardo跑以上的程式時答案是a = 1, b = 1 → a = 2, b = 2 如以下影片連結 https://www.youtube.com/watch?v=hGVp7TDvCNQ
https://youtu.be/qU9qFWxMq-A
真的不懂為什麼?可以請大家幫我解惑嗎? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 163.22.145.122 ※ 文章網址: https://www.ptt.cc/bbs/ASM/M.1470237682.A.6DC.html
soheadsome: UNO用AVR Leonardo用ARM 編譯器實做隨著平台不同 08/03 23:35
chuegou: 感覺是第一串不見了 08/04 00:40
alibuda174: 在setup()裡最後加上 while (!Serial) ; 試試 08/04 06:03
wnmin: 那是因為uno開serial的時候會重新啟動 08/09 07:46
wnmin: 李奧那多不會 08/09 07:46