FlashairのGPIOを使ってサーボモータを動かしてみた。
以下の最少構成で動かすことができるかチャレンジ。
・Flashair
・SDカードDip化モジュール
・ブレッドボードミニ
・サーボモータ SG-90
・洗濯ばさみ
完成品がこちら。

名付けて『IoP!』(Internet of Pinch!)
洗濯ばさみもインターネットにつながる時代だね。
Flashair内のHTMLファイルにブラウザからアクセスして、Luaを実行するとGPIOからサーボを動かすための信号が出力されて洗濯ばさみが開く。
GPIIOに関しては過去も記事も参考に。
MOV_0849_x264_002
This is a modal window.
The media could not be loaded, either because the server or network failed or because the format is not supported.
Captions Settings Dialog
Beginning of dialog window. Escape will cancel and close the window.
MOV_0849_x264_003
This is a modal window.
The media could not be loaded, either because the server or network failed or because the format is not supported.
Captions Settings Dialog
Beginning of dialog window. Escape will cancel and close the window.
FlashairのGPIOのみでサーボを動かすためのソースコードはこちら。
まったく実用的ではないが ”こんな遊びもできるよ” ということで。
【IoP.lua】
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | function servo_write(angle, time )
buf = 0
end_j = (angle - 90) * 80 / 90 + 110;
for i = 1, time /20 do
s, indata = fa.pio(0x02, 0x02) --ON
for j = 1,end_j do
buf = buf + 1
end
s, indata = fa.pio(0x02, 0x00) --OFF
sleep(20)
end
return 1
end
r = servo_write(135,3000)
r = servo_write(0,500)
|
「Flashairでサーボモータを動かしてみた」への1件のフィードバック