1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

安価なArduinoProMicro互換機は、delay等が当てにならない?【要検証】

Last updated at Posted at 2016-03-21

自作キーボードのために、AliExpressでArduinoProMicro互換機を輸入しました。キー入力感度調整のため、delay関数を利用していましたが、思ったようなdelay具合になっていなかったので書き残します。

主題

  • 事象:スケッチ書き込み〜USB抜線までと、USB再結線までのディレイの待ち時間が違う。USB抜線まではdelayの待ち時間が短く、再結線後は待ち時間が遅延する。
  • 事実:書き込み直後に60秒待つするプログラムによる計測…書き込み直後→60秒でwhileに突入、再結線直後→60秒でechoは10秒を示した。Arduino1秒が現実の6秒くらい?
  • 気づいたとき:再結線時のマウスエミュレーションによるカーソル移動時に、ガビガビになる。(ディレイが伸びるので、マウス操作が処理落ちのように見える)
  • 対処1:millisでディレイを代替する→効果なしhttps://www.arduino.cc/en/Tutorial/BlinkWithoutDelay
  • 対処2:書き込みのボードを変えてみる。(ArduinoLeonard、AruduinoMicro、SparkfunProMicro16MHz→効果なし
  • 対処3:Arduinoのフェーズビットを変更する→書き込み機器がないので未検証。
  • 解決:できてない
blinkを適当にコピペ
// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 13 as an output.
  pinMode(13, OUTPUT);
}
int count=0;
// the loop function runs over and over again forever
void loop() {
    while (!Serial) {
      ; // wait for serial port to connect. Needed for native USB port only
    }
  count++;
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for a second
    count++;
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second
  Serial.println(count);
  if(count>=60){
    while(true){
    }
    
  }
}

ところで

対応中に書き込みボードをミスってどうにもならない状態(レンガ状態??日本ではなんていうのだろう?)になったので、復帰方法を探した。ProMicoroはデフォルトでリセットスイッチないので、自前でスイッチを用意するか、リード線で、簡単にできるとわかった。(外国からの輸入モノだったので、リセット機能が効かないかと超焦っりました。リセット機能は輸入物でもちゃんと効くんだよ〜という意味で書き残しておきます。)
適当にProMicro互換を買った方は、正しいボードを選択してください。(SparkfunのページからボードパッケージをDLして使いましょう。)

RSTとGNDを繋いで、ボタンをポチポチ2回押せばリセットできます。
Lランプがないので、COMポートをこまめにチェックしないとです。

How to Revive a “Bricked” Pro Micro

Reset to Bootloader

ちなみに買ったのはこれ。

rul
ttp://www.aliexpress.com/item/Mini-Leonardo-Pro-Micro-ATmega32U4-5V-16MHz-Module-For-Arduino-Best-Quality/32284746884.html
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?