Loading...
「ツール」は右上に移動しました。
利用したサーバー: wtserver1
33いいね 4,838 views回再生

Microbit and Servo

The following code for the BBC Microbit is written in Micro Python(uP)
You may down load Micro Python from either link below.
https://codewith.mu/
https://github.com/mu-editor/mu/releases
There is an excellent explanation of Micro Python by Tony D. , see this YouTube video:
   • Tour of MicroPython on BBC micro:bit ...  
One difference is that you no longer need to drag the .hex file to your BBC Microbit as shown in the video. You can now just "click" on the "Flash" button on the new version of Python and the file will download automatically to your Microbit, much easier.
Hope you find this helpful.
Also, camera ran out of memory during the taping but most of video is there.
Small Oscilloscope is DS201 https://www.banggood.com/MINI-DSO211-...
Just copy and past the code below.
BUT you must indent "each line" after the "while True" statement by 4 spaces, so the code knows it goes with the "while True".
(I could not get this to come out correctly in the description)
Note: uPython is very picky on indentation, must be a multiple of 4.
Also, you must hit the enter key after the last line of code so uPython knows that the line was ended.

from microbit import *
Servo control:
100 = 1 millisecond pulse all right
200 = 2 millisecond pulse all left
150 = 1.5 millisecond pulse center
10 is 10 milliseconds for period 1/100 Hz
while True:
pin0.set_analog_period(10)
pin0.write_analog(150)
display.show(Image.ARROW_N)
sleep(1000)
pin0.write_analog(100)
display.show(Image.ARROW_E)
sleep(1000)
pin0.write_analog(150)
display.show(Image.ARROW_N)
sleep(1000)
pin0.write_analog(200)
display.show(Image.ARROW_W)
sleep(1000)
pin0.write_analog(150)
display.show(Image.ARROW_N)
sleep(1000)

コメント