//LED 右移 跑馬燈
const byte LEDs[] = {0,1,2,3,4,5,6,7};
const byte total = sizeof(LEDs);
void setup()
{
for (byte j=7; j<=0; j--)
{
pinMode(LEDs[j], OUTPUT);
}
}
//=============================
void loop() {
for (byte j=7; j>=0 ; j--)
{
digitalWrite(LEDs[j], HIGH);
delay (250);
digitalWrite(LEDs[j], LOW);
delay(250);
} // for
}
2016年3月27日 星期日
Arduino:stk500_getsync(): not in sync
源自於
http://yehnan.blogspot.tw/2014/10/arduinostk500getsync-not-in-sync.html
Arduino:stk500_getsync(): not in sync
燒錄時,若看到錯誤訊息「avrdude: stk500_getsync(): not in sync: resp=0x00」,雖然知道這代表著電腦端的燒錄程式avrdude不能與微控制器內的bootloader進行溝通,但卻無法知曉錯誤的源頭在哪,因為可能出錯的地方太多了。
底下列出可能導致此錯誤的原因,以及解決辦法:
原因:「工具-板子(Tools-Board)」與「工具-序列埠(Tools-Serial Port)」沒選好
辦法:確認你的板子到底是哪一塊,確認它所連接的序列埠是哪一個,重新設定正確的值
原因:序列埠被佔用了
辦法:關閉佔用序列埠的軟體,或電腦重開機
原因:驅動程式壞了、沒裝好
辦法:重新安裝驅動程式
原因:零件影響了燒錄所需的線路,譬如Uno板燒錄時須經由腳位0與1的線路
辦法:燒錄時拔除相關接線、暫時先拔掉擴充板
原因:舊板子與某些較小型的板子,需要自己按板子上的Reset鍵
辦法:觀看avrdude燒錄時輸出的訊息,在適當的時機按下Reset鍵;多試幾次,嘗試在不同的時間點按下
原因:若是自己買「USB轉Serial介面」模組再加上微控制器晶片,有可能TX與RX接反了
辦法:反過來接試試看
原因:微控制器裡的bootloader壞了,或根本沒有bootloader
辦法:找個ISP燒錄器,重新燒錄bootloader
原因:不明
辦法:電腦重開機
原因:不明
辦法:重新啟動Arduino IDE
原因:不明
辦法:重新拔插USB連接線
原因:不明
辦法:換插別的USB埠
原因:不明
辦法:改用USB集線器或改為直接插電腦的USB埠
原因:不明
辦法:換條USB線
底下列出可能導致此錯誤的原因,以及解決辦法:
原因:「工具-板子(Tools-Board)」與「工具-序列埠(Tools-Serial Port)」沒選好
辦法:確認你的板子到底是哪一塊,確認它所連接的序列埠是哪一個,重新設定正確的值
原因:序列埠被佔用了
辦法:關閉佔用序列埠的軟體,或電腦重開機
原因:驅動程式壞了、沒裝好
辦法:重新安裝驅動程式
原因:零件影響了燒錄所需的線路,譬如Uno板燒錄時須經由腳位0與1的線路
辦法:燒錄時拔除相關接線、暫時先拔掉擴充板
原因:舊板子與某些較小型的板子,需要自己按板子上的Reset鍵
辦法:觀看avrdude燒錄時輸出的訊息,在適當的時機按下Reset鍵;多試幾次,嘗試在不同的時間點按下
原因:若是自己買「USB轉Serial介面」模組再加上微控制器晶片,有可能TX與RX接反了
辦法:反過來接試試看
原因:微控制器裡的bootloader壞了,或根本沒有bootloader
辦法:找個ISP燒錄器,重新燒錄bootloader
原因:不明
辦法:電腦重開機
原因:不明
辦法:重新啟動Arduino IDE
原因:不明
辦法:重新拔插USB連接線
原因:不明
辦法:換插別的USB埠
原因:不明
辦法:改用USB集線器或改為直接插電腦的USB埠
原因:不明
辦法:換條USB線
//左移 跑馬燈
//左移 跑馬燈
//Shift Left LED
const byte LEDs[] = {0,1,2,3,4,5,6,7};
const byte total = sizeof(LEDs);
void setup()
{
for (byte i=0; i<total; i++)
{
pinMode(LEDs[i], OUTPUT);
}
}
//=============================
void loop() {
for (byte i=0; i<total; i++)
{
digitalWrite(LEDs[i], HIGH);
delay (250);
digitalWrite(LEDs[i], LOW);
delay(250);
} // for
} //loop
//Shift Left LED
const byte LEDs[] = {0,1,2,3,4,5,6,7};
const byte total = sizeof(LEDs);
void setup()
{
for (byte i=0; i<total; i++)
{
pinMode(LEDs[i], OUTPUT);
}
}
//=============================
void loop() {
for (byte i=0; i<total; i++)
{
digitalWrite(LEDs[i], HIGH);
delay (250);
digitalWrite(LEDs[i], LOW);
delay(250);
} // for
} //loop
在電腦上 Serial Monitor 依序輸出0~100
//下面的程式將會在電腦上依序輸出0~100
// 範例程式:
int x=0; //宣告正整數變數x初始值為0(全域變數)
void setup(){
Serial.begin(9600); //設定鮑率9600來與電腦連結
}
void loop(){ //主程式開始
x+=1; //不斷的累加x
if(x>100){ //判斷x是否超過100
x=0; //將x值歸0
}
else
{
Serial.println(x); //在螢幕上顯示出x值
}
if (x>1000) x=0 ;
delay(20);
}
// 範例程式:
int x=0; //宣告正整數變數x初始值為0(全域變數)
void setup(){
Serial.begin(9600); //設定鮑率9600來與電腦連結
}
void loop(){ //主程式開始
x+=1; //不斷的累加x
if(x>100){ //判斷x是否超過100
x=0; //將x值歸0
}
else
{
Serial.println(x); //在螢幕上顯示出x值
}
if (x>1000) x=0 ;
delay(20);
}
LED digital Blink
//LED_1 ON, OFF delay 500ms
int LEDPin=13;
void setup()
{
pinMode(LEDPin,OUTPUT);
}
void loop()
{
digitalWrite(LEDPin , HIGH);
delay(500);
digitalWrite(LEDPin , LOW);
delay(500);
}
int LEDPin=13;
void setup()
{
pinMode(LEDPin,OUTPUT);
}
void loop()
{
digitalWrite(LEDPin , HIGH);
delay(500);
digitalWrite(LEDPin , LOW);
delay(500);
}
範例程式,會將x不斷累加但僅在x=100 、200 、300時在螢幕輸出x數值
l本範例程式,會將x不斷累加但僅在x=100
、200 、300時在螢幕輸出x數值
範例程式:
int x=0; //宣告變數(全域變數)
void setup()
{
Serial.begin(9600);
}
void loop()
{
x+=1; //不斷的累加1 x = x + 1 , x++ 意義都一樣
switch(x){ //判定x值,當x值有相對應的case時執行該內容
case 100:
Serial.println(x); //在螢幕上顯示出x值
break;
case 200:
Serial.println(x);
break;
case 300:
Serial.println(x);
break;
default:
//可有可無,若有,當不合以上條件時執行
break ;
} //switch
delay (5);
if (x>500) x=0;
} //loop
寫一個 9x9 乘法表 swtch.... case
//4)利用
switch …case 與
Serial.print Serial.println 指令
void setup()
{
Serial.begin(9600);
}
void loop()
{
for (int i=1 ;i<=9 ;i++)
{
switch (i) {
case 1 : {
for (int j=1 ; j<=9;j++)
{
int x=1*j;
Serial.print ("1") ;
Serial.print ("\t") ;
Serial.print ("*") ;
Serial.print (j) ;
Serial.print ("\t") ;
Serial.print ("=") ;
Serial.print ("\t") ;
Serial.println (x) ;
delay (500);
} //for
break;
} //case
case 2 : {
for (int j=1 ; j<=9;j++)
{
int x=2*j;
Serial.print ("2") ;
Serial.print ("\t") ;
Serial.print ("*") ;
Serial.print (j) ;
Serial.print ("\t") ;
Serial.print ("=") ;
Serial.print ("\t") ;
Serial.println (x) ;
delay (500);
} //for
break;
} //case
case 3 : {
for (int j=1 ; j<=9;j++)
{
int x=3*j;
Serial.print ("3") ;
Serial.print ("\t") ;
Serial.print ("*") ;
Serial.print (j) ;
Serial.print ("\t") ;
Serial.print ("=") ;
Serial.print ("\t") ;
Serial.println (x) ;
delay (500);
} //for
break;
} //case
case 4 : {
for (int j=1 ; j<=9;j++)
{
int x=4*j;
Serial.print ("4") ;
Serial.print ("\t") ;
Serial.print ("*") ;
Serial.print (j) ;
Serial.print ("\t") ;
Serial.print ("=") ;
Serial.print ("\t") ;
Serial.println (x) ;
delay (500);
} //for
break;
} //case
case 5 : {
for (int j=1 ; j<=9;j++)
{
int x=5*j;
Serial.print ("5") ;
Serial.print ("\t") ;
Serial.print ("*") ;
Serial.print (j) ;
Serial.print ("\t") ;
Serial.print ("=") ;
Serial.print ("\t") ;
Serial.println (x) ;
delay (500);
} //for
break;
} //case
case 6 : {
for (int j=1 ; j<=9;j++)
{
int x=6*j;
Serial.print ("6") ;
Serial.print ("\t") ;
Serial.print ("*") ;
Serial.print (j) ;
Serial.print ("\t") ;
Serial.print ("=") ;
Serial.print ("\t") ;
Serial.println (x) ;
delay (500);
} //for
break;
} //case
case 7 : {
for (int j=1 ; j<=9;j++)
{
int x=7*j;
Serial.print ("7") ;
Serial.print ("\t") ;
Serial.print ("*") ;
Serial.print (j) ;
Serial.print ("\t") ;
Serial.print ("=") ;
Serial.print ("\t") ;
Serial.println (x) ;
delay (500);
} //for
break;
} //case
case 8 : {
for (int j=1 ; j<=9;j++)
{
int x=8*j;
Serial.print ("8") ;
Serial.print ("\t") ;
Serial.print ("*") ;
Serial.print (j) ;
Serial.print ("\t") ;
Serial.print ("=") ;
Serial.print ("\t") ;
Serial.println (x) ;
delay (500);
} //for
break;
} //case
default : {
for (int j=1 ; j<=9;j++)
{
int x=9*j;
Serial.print ("9") ;
Serial.print ("\t") ;
Serial.print ("*") ;
Serial.print (j) ;
Serial.print ("\t") ;
Serial.print ("=") ;
Serial.print ("\t") ;
Serial.println (x) ;
delay (500);
} //for
} //case
//============================
} //switch
} //for
} //loop
訂閱:
文章 (Atom)
Easybuilder pro + WOKWI esp32 DHT22 + 4 LED 控制 (MQTT)
Easybuilder pro + WOKWI esp32 DHT22 + 4 LED 控制 (MQTT) 本系統實現了 ESP32 微控制器 (於 Wokwi 模擬環境中執行)與 EasyBuilder Pro 人機介面 (HMI) 透過 MQTT 通訊協定 進行雙向控制與...
-
數位IC設計入門-Verilog combinational logic 8 to 1 Multiplexer 多工器 Behavioral Modeling (& Test Bench) //數位IC設計入門-Verilog combinationa...
-
Line 發報機 Python TKinter (CONFIG_LINE Message API_2.py) import serial import serial.tools.list_ports import tkinter as tk from tkinter import...
-
python pip 不是内部或外部命令 -- 解決方法 要安裝 Pyqt5 1. 首先,開啟命令提示字元。 2. 輸入 pip3 install pyqt5 好像不能執行 ! ! 錯誤顯示 : ‘ pip3 ’ 不是內部或外部命令、可執行的程式或批...