Skip to main content

A Python module for the 4tronix Bit:bot XL.

Project description

bitbotxl

A Python module for the 4tronix Bit:bot XL.

You might use this with the Visual Studio Code extension found at https://github.com/oivron/microbit-extension-vscode. The extension is available from Visual Studio Code Marketplace.

Installation

pip install bitbotxl

Usage

See documentation and examples for the Bit:bot XL below.

See micro:bit Micropython API for a complete documentation on how to use the micro:bit.

Import

To use this module in your Python script:

from bitbot import *

Bit:bot XL documentation/API

# Set left/right bias to match motors.
# Direction: LEFT or RIGHT.
# Bias in %.
bias(direction, percent)
# Move robot forward or reverse at speed.
# Direction: FORWARD or REVERSE.
# Speed in %.
go(direction, speed)
# Move robot forward or reverse at speed for milliseconds.
# Direction: FORWARD or REVERSE.
# Speed in %.
# Duration in milliseconds.
goms(direction, speed, duration)
# Rotate robot left or right at speed.
# Direction: LEFT or RIGHT.
# Speed in %.
spin(direction, speed)
# Rotate robot left or right at speed for milliseconds.
# Direction: LEFT or RIGHT.
# Speed in %.
# Duration in milliseconds.
spinms(direction, speed, duration)
# Sound a buzz for milliseconds.
# Duration in milliseconds.
buzz(duration)
# Read line sensor.
# Directon: LEFT or RIGHT.
linesensor(direction)
# Read ultrasonic distance sensor.
# Returns distance in cm.
sonar()
# Stops the Bit:bot.
stop()

Examples

Simple examples on how to use the line sensor and the ultrasonic distance sensor. You need to add additional code to create complete scripts.

Adjust the arguments for speed and duration according to your own preferences.

Line sensor

# Let Bit:bot follow a dark line.
if (bitbot.linesensor(RIGHT) == 1):
    bitbot.spinms(RIGHT, 10, 1) # Adjusts direction. Arguments need to have very small values.
elif (bitbot.linesensor(LEFT) == 1):
    bitbot.spinms(LEFT, 10, 1) # Adjusts direction. Arguments need to have very small values.
else:
    bitbot.go(FORWARD, 50)
# Let Bit:bot drive between two dark lines.
if (bitbot.linesensor(RIGHT) == 1):
    bitbot.spinms(LEFT, 10, 1)
elif (bitbot.linesensor(LEFT) == 1):
    bitbot.spinms(RIGHT, 10, 1)
else:
    bitbot.go(FORWARD, 50)

Sonar

# Stop, reverse and spin the Bit:bot when it gets close to an object.
# The sonar() method returns the distance to the nearest object in cm.
bitbot.go(FORWARD, 50)
if bitbot.sonar() < 20:
    bitbot.stop()
    bitbot.goms(REVERSE, 50, 700)
    bitbot.spinms(RIGHT, 50, 200)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

bitbotxl-0.0.2-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file bitbotxl-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: bitbotxl-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for bitbotxl-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f88cc8ef6a05539090c488780d021d85caed1a92ed0ee08bacc3a194a2a43f1d
MD5 32fcdf6e8d833447ea7b8a4c94916586
BLAKE2b-256 d688fb10280d755f83bd552c98aaf2fdc5e103ebdf9e92718373763405c7dd03

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page