Can we do things with the MeArm?

In this section you will learn

back to Main

Remember, hand written notes are really important.

Make notes on things that trip you up, things you understand in your own words, things that you want to look further into or places to look at later (python programming tutorials etc) and your findings as you go through.

Take a photo with your phone of the notes and email them to me. This is extra-credit stuff, do this and you have to do less other school-work! Don't do this and you;ll be practising your writing more etc!

The more work you put in here that we can use to prove you've been learning things, the less other work you have to do! Be kind to yourself, spend a little extra time on this, or spend a lot of time later because you didn't..

To control a Servo Motor

Adafruit{:target="_blank"}

And now, a reference you can use: Servo.py{:target="_blank"}

So that one looks really good, upload servo.py and then you create a servo object and throw an angle at it: ```python import servo PIN_NUMBER = a0

servo = servo.Servo(PIN_NUMBER) servo.write_angle(15) # move to 15 degrees! :) ```

Here is another I found:

Micropython docs{:target="_blank"}

That one is a bit more complicated as it's talking about duty cycles and the like, thats a bit advanced for now but just to note, that's what the servo.py example does inside, it's just wrapping it with niceness so you raise it by saying a pin, then just sling degrees at it.

Having read that all we really need to do though is this to setup the servo and move it ot the first duty cycle position:

python from machine import Pin, PWM servo = PWM(Pin(2), freq=50, duty=77)

then update the object with a different duty cycle like this to move it:

python servo.duty(30) servo.duty(122)

...yeah that's all I got for now, :|