create every day - 福野泰介の一日一創

Manipulate 10 Servos on IchigoJam (PCA9685 via I2C)

2017/04/08 23:55:00
#ichigojam #maker #english 

It's very easy to manipulate a servo on IchigoJam.

PWM 2,100:WAIT60:PWM 2,200

2 means OUT2, 100 means 0.1msec. You can control from 50 to 200 to manipulate the servo.

OUT2-5 supports PWM command. So you can connect up to 4 servos. Do you want to more? Yes we can!

Use this the kit using NXP PCA9685. You can connect 16 servos to this unit and control by I2C. Maximum capacity to manipulate is 992 servos using 16 units cause each unit can have a I2C slave address.


It's very easy to connect. Connect 5V/SCL/SDA/GND/VCC to same name pin on IchigoJam. And connect servos as many as you want (up to 16).

1 'servo 16 (for ver 1.2beta43) 10 POKE#700,#10,100,#A1 20 IF I2CW(#40,0,#700,1) STOP 30 A=I2CW(#40,#FE,#701,1) 40 A=I2CW(#40,0,#702,1) 50 CLV:N=10 60 M=400:FOR I=1 TO N:[I*2-1]=M:NEXT:GSB@SVO 65 WAIT 30 67 FOR J=1 TO 2 70 FOR I=1 TO N:[I*2-1]=150+RND(600-150):NEXT:GSB@SVO 80 NEXT 90 GOTO 60 100 @SVO 110 CLS:FOR I=1 TO N:LC 10,I*2:?HEX$(I-1),[I*2-1]:NEXT 120 A=I2CW(#40,6,#800,4*N) 130 WAIT30:RTN

This is demo program to manipulate 10 servos (on the movie).
10-40 set the frequency of PWM (have to stop before setting)
60 reset positions
70 set randam positions
100-130 sub function to manipulate servos and show them number


Try make your original robot!

links
- I2C接続16チャンネル サーボ&PWM駆動キット: 組立キット 秋月電子通商 電子部品 ネット通販 (PCA9685)
- マイクロサーボ9g SG-90: サーボ 秋月電子通商 電子部品 ネット通販 (servo)
- Raspberry Piで10個のサーボモーター動かしてみた: EeePCの軌跡
- 歩行ロボットをつくるにはまずこれ!【サーボ編2】 - いそぷろのブログ
- Overview | Adafruit 16-Channel Servo Driver with Arduino | Adafruit Learning System

Tweet
クリエイティブ・コモンズ・ライセンス
この作品は「Creative Commons — CC BY 4.0」の下に提供されています。
CC BY 福野泰介 - Taisuke Fukuno / @taisukef / high-res profile image