You can control servos (small ones) from a Micro:Bit directly. Following a link from the David Whale (Twitter @whaleygeek) , thank you, took me to a Kitronik blog post, https://www.kitronik.co.uk/blog/using-bbc-microbit-control-servo/, which has the answer.
The code uses Microsoft Blocks taken from the post, runs the servos 180 degrees and back again, when button A is pressed. It does exactly what it should. I am also using the Tower Pro SG90 servo.
Can it be replicated in Micropython? This is a new mini project, there seems to be little out there yet on how do this but the best so far is this video by PHILG2864:
The closest I have is the following, it is essentially there.
from microbit import *
pin0.set_analog_period(20)
while True:
pin0.write_analog(180)
sleep(1000)
pin0.write_analog(1)
sleep(1000)
Setting the time period to 20ms pin0.set_analog_period(20)seems by experiment (and used in the video above) to be best value so far. The reason for pin0.write_analog(1) set to 1 instead of 0, 0 seems to stop the whole thing.
All opinions in this blog are the Author's and should not in any way be seen as reflecting the views of any organisation the Author has any association with. Twitter @scottturneruon
Robots and getting computers to work with the physical world is fun; this blog looks at my own personal experimenting and building in this area.
Subscribe to:
Post Comments (Atom)
DIY Data Science with microbits
DIY Data Science: A Complete Guide to Data Logging with the Micro:bit V1 Whether you are a STEM teacher looking for a classroom lab solution...
-
In the previous blog posts for this 'series' "It is a good time...." Post 1 looked at the hardware unpinning some of...
-
The Raspberry Pi Foundation recently released a programming activity Alien Language , with support Dale from Machine Learning for Kids , tha...
-
You don't need to buy a robot to get programming a robot, now there are a range of free and relatively simple to start with robot simula...

No comments:
Post a Comment