element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
microbit
  • Learn
  • Learning Center
  • STEM Academy
  • microbit
  • More
  • Cancel
microbit
micro:bit Blog BLE controlled crossbow blot-Control of Pins
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join microbit to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: fyaocn
  • Date Created: 2 Nov 2016 3:56 AM Date Created
  • Views 621 views
  • Likes 2 likes
  • Comments 1 comment
  • bbc micro:bit
  • big ideas
Related
Recommended

BLE controlled crossbow blot-Control of Pins

fyaocn
fyaocn
2 Nov 2016

1、Here is the Pin mapping diagram

image

2、Those pins are available as attributes on the module : microbit.pin0 - microbit.pin20.

Pin 0, Pin 1, Pin 2 are used to control the servo,

Test with the following code:

from microbit import *

while True:

   if pin0.read_digital():

   display.show(Image.HAPPY)

   else:

   display.show(Image.SAD)

This will show different pic when Pin 0 is applied with digital input.

3. The principle of servo

This servo can is controlled by 20ms PWM cycles, 0.5-2.5ms is period of HIGH corresponding to 0-180 degree rotary status, is. 2.5% to 12.5% ratio.

with 0-1023 value for write_analog value. That is 26 - 127.

0.5/20+1023=25.575

2.5/20+1023=127.875

4. Use of Radio

Since there BLE are not supported by Micropython in MicroBit for larger stack, Radio is proposed for wireless control.

First radio shall be imported and radio.on() is called , the radio.receive() can trace message sent by mobile APP with text message sent to control.

 

5. Proposed codes

# Radio controlled servo

import radio

from microbit import *

# Set start parameters and start Radio

display.scroll('Hello, Motors!')

sleep(2000)

radio.on()

set_analog_period(200)

angleAstep=0

angleBstep=0

angleA =0

angleD =0

display.scroll('Ready')

while(True):

    incoming = radio.receive()

    if incoming == 'up1':

        angleAstep= 1

        elif incoming == 'up2':

            angleBstep= 1

            elif incoming == 'down1':

                angleAstep=-1

                elif incoming == 'down2':

                    angleBstep= -1

 

    '''

    Move servo according to direction of angleAstep and angleBstep,

    with value +1 or -1,

    the data reset to 0 after each move

    '''

    if (angleA>26 and angleA < 127):

        pin0.write_analog(angleA)     

        angleA +=5*angelAstep

        sleep(200)

    if (angleB>26 and angleB < 127):

        pin1.write_analog(angleB)     

        angleB +=5*angelBstep

        sleep(200)

    angleAstep=0

    angleBstep=0

 

#Coding on Python editor 

#With referrence to Radio — BBC micro:bit MicroPython 0.0.1 documentation

6. Pin0 and pin1  are output pins for PWM control with servo. It can move up and down and ready for cotton button arrow to fly. For this servo, 5V power shall be needed. Therefore, extra power pack conntected with Vcc and GND to drive the servo.

  • Sign in to reply

Top Comments

  • jsarnold
    jsarnold over 9 years ago +1
    This is a useful, and very clear resource - thank you. For other useful information and projects relating to the BBC Micro:bit I recommend the STEM Micro:bit group - https://www.stem.org.uk/microbit-g…
  • jsarnold
    jsarnold over 9 years ago

    This is a useful, and very clear resource - thank you. For other useful information and projects relating to the BBC Micro:bit I recommend the STEM Micro:bit group - https://www.stem.org.uk/microbit-group

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube