2023年4月24日月曜日

microbit :: keyestudio ks0308 dcmotor-driver-board/

 Keyestudio KS0308でDCモーターを使う | YahboomとKeyestudio micro:bit教材情報 (micro-bit.info)  大枠では、 これを参考にするがpin1,pin2が書いてない!

多分、no-pwm方式の説明だろう、pwm方式にするには

下記にあるようにpin 14だけでなくpin 1,pin 2にも仕込む必要があった 

https://wiki.keyestudio.com/Ks0308_keyestudio_Motor_Drive_Breakout_Board_for_micro_bit メーカーの説明に由来する 要注意だった! 

VMに単3x3つないだらmicrobitの面倒もみてくれた!

基盤をみるとtb015a3/6612fngとあり https://tomosoft.jp/design/?p=10695で

tb6612fngをつかっていたが、どうも同一のドライバのようだ そこにあるコードで

p14,p1,p2の役割が氷解した

----------------double gear box :: 初期設定でp1,p2をアナログ設定が肝心----

radio.onReceivedString(function (receivedString) {
basic.showString(receivedString)
if (receivedString == "f") {
basic.showLeds(`
. . # . .
. # # # .
# . # . #
. . # . .
. . # . .
`)
pins.analogWritePin(AnalogPin.P1, 1023)
pins.digitalWritePin(DigitalPin.P12, 1)
pins.digitalWritePin(DigitalPin.P13, 0)
pins.analogWritePin(AnalogPin.P2, 1023)
pins.digitalWritePin(DigitalPin.P15, 1)
pins.digitalWritePin(DigitalPin.P16, 0)
basic.pause(500)
pins.analogWritePin(AnalogPin.P1, 1023)
pins.digitalWritePin(DigitalPin.P12, 0)
pins.digitalWritePin(DigitalPin.P13, 0)
pins.analogWritePin(AnalogPin.P2, 1023)
pins.digitalWritePin(DigitalPin.P15, 0)
pins.digitalWritePin(DigitalPin.P16, 0)
} else if (receivedString == "b") {
basic.showLeds(`
. . # . .
. . # . .
# . # . #
. # # # .
. . # . .
`)
pins.analogWritePin(AnalogPin.P1, 1023)
pins.digitalWritePin(DigitalPin.P12, 0)
pins.digitalWritePin(DigitalPin.P13, 1)
pins.analogWritePin(AnalogPin.P2, 1023)
pins.digitalWritePin(DigitalPin.P15, 0)
pins.digitalWritePin(DigitalPin.P16, 1)
basic.pause(500)
pins.analogWritePin(AnalogPin.P1, 1023)
pins.digitalWritePin(DigitalPin.P12, 0)
pins.digitalWritePin(DigitalPin.P13, 0)
pins.analogWritePin(AnalogPin.P2, 1023)
pins.digitalWritePin(DigitalPin.P15, 0)
pins.digitalWritePin(DigitalPin.P16, 0)
} else if (receivedString == "t") {
basic.showLeds(`
# # # # .
# . . # .
# . . # .
# . # # #
# . . # .
`)
pins.analogWritePin(AnalogPin.P1, 1023)
pins.digitalWritePin(DigitalPin.P12, 0)
pins.digitalWritePin(DigitalPin.P13, 1)
pins.analogWritePin(AnalogPin.P2, 1023)
pins.digitalWritePin(DigitalPin.P15, 1)
pins.digitalWritePin(DigitalPin.P16, 0)
basic.pause(500)
pins.analogWritePin(AnalogPin.P1, 1023)
pins.digitalWritePin(DigitalPin.P12, 0)
pins.digitalWritePin(DigitalPin.P13, 0)
pins.analogWritePin(AnalogPin.P2, 1023)
pins.digitalWritePin(DigitalPin.P15, 0)
pins.digitalWritePin(DigitalPin.P16, 0)
}
})
radio.setGroup(132)
pins.digitalWritePin(DigitalPin.P14, 1)
basic.showIcon(IconNames.Heart)
basic.forever(function () {
})


0 件のコメント:

コメントを投稿