LoginSignup
2
3

More than 5 years have passed since last update.

Digisparkを動かす

Posted at

Digispark

DigisparkはUSBに直接挿せるマイコン(ATTiny85). ソフトでUSB制御.
keyboardやmouseのエミュレートなど得意
* digiStump : Digispark Development board
* Digispark - The tiny, Arduino enabled, usb dev board!
* (参考) 安価なUSB直挿しマイコンDigisparkのススメ

購入

  • HiLetgo Digispark Kickstarter ATTINY85 Digispark 超小型Arduino互換 (183円)

    一応、ちゃんと使えてますが、クローンだとP5がリセットピンになっているようなので、そこだけ要注意です。
    DigisparkのQ&Aフォーラムでは、クローンではP5がI/Oに使えずリセットになっているのが有ると書かれてました。

  • rev.3 というのはclone?!

設定

http://homemadegarbage.0t0.jp/digispark-1
http://digistump.com/wiki/digispark/tutorials/connecting

Digisparkへの書き込み

Digisparkにはリセットボタンがないため、書込みボタンをクリック後”Plug in device now…”と表記されてからDigisparkをUSBポートに差し込む。問題がなければ書き込みが開始する。
いちいち抜き差し面倒なのでダイソーのスイッチ付きUSBコネクタや延長コードがあると便利です。

  • HUB経由だと書き込みうまく動作せず.PC直結でうまく書き込めた.
  • ArduinoIDEなしで単体でつないでも認識繰り返すだけで正解
  • シリアルportは割り当てされないため未設定でよい.

詳細

Differences (from the Arduino) and limitations
http://digistump.com/wiki/digispark/quickref

Pin outs:

All pins can be used as Digital I/O
Pin 0 → I2C SDA, PWM (LED on Model B)
Pin 1 → PWM (LED on Model A) ★ 手元のDigisparkはModel A
Pin 2 → I2C SCK, Analog In
Pin 3 → Analog In (also used for USB+ when USB is in use)
Pin 4 → PWM, Analog (also used for USB- when USB is in use)
Pin 5 → Analog In

Many existing libraries will not work with the Digispark: For I2C devices check out the TinyWireM library, which makes it super simple to port an I2C based device library over to use with the Digispark.

sample

#include "DigiKeyboard.h"

void setup() {
  // don't need to set anything up to use DigiKeyboard
  pinMode(1  , OUTPUT);
}


void loop() {
  // this is generally not necessary but with some older systems it seems to
  // prevent missing the first character after a delay:
  DigiKeyboard.sendKeyStroke(0);

  // Type out this string letter by letter on the computer (assumes US-style
  // keyboard)
  digitalWrite(1, HIGH);  
  DigiKeyboard.println("ryu!");

  DigiKeyboard.delay(500);
  digitalWrite(1, LOW);  

  // It's better to use DigiKeyboard.delay() over the regular Arduino delay()
  // if doing keyboard stuff because it keeps talking to the computer to make
  // sure the computer knows the keyboard is alive and connected
  DigiKeyboard.delay(5000);
}
2
3
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
2
3