Giter Site home page Giter Site logo

calliope-bitbot's Introduction

BitBot Package for Microsoft PXT

Build Status GitHub Tag

This library provides a Microsoft PXT package for BitBot, see https://4tronix.co.uk/bitbot/.

Driving the motor

Use bitbot.motor(..) to drive motor either forward or reverse. The value indicates speed and is between -1023 to 1023. Minus indicates reverse.

// Drive 1000 ms forward
bitbot.motor(BBMotor.All, 1023);
basic.pause(1000);

// Drive 1000 ms reverse
bitbot.motor(BBMotor.All, -1023);
basic.pause(1000);

// Drive 1000 ms forward on left and reverse on right
bitbot.motor(BBMotor.Left, 1023);
bitbot.motor(BBMotor.Right, -1023);
basic.pause(1000);

Buzz sound

To use the buzzer, just use bitbot.buzz(..) function with either 1 (sound) or 0 (no-sound).

// Buzz for 100 ms
bitbot.buzz(1);
basic.pause(100);
bitbot.buzz(0);

Read line sensor

The BitBot has two line-sensors: left and right. To read the value of the sensors, use bitbot.readLine(..) function.

// Read left and right line sensor
let left = bitbot.readLine(BBLineSensor.Left);
let right = bitbot.readLine(BBLineSensor.Right);

Read light sensor

Light sensors can be read using bitbot.readLight(..) function.

// Read left and right light sensor
let left = bitbot.readLight(BBLightSensor.Left);
let right = bitbot.readLight(BBLightSensor.Right);

Read sonar value

If you have mounted the optional sonar sensor for the BitBot you can also use the bitbot.sonar(..) function to read the distance to obstacles.

// Read sonar values
let v1 = bitbot.sonar(BBPingUnit.MicroSeconds);
let v2 = bitbot.sonar(BBPingUnit.Centimeters);
let v3 = bitbot.sonar(BBPingUnit.Inches);

NeoPixel helpers

The BitBot has 12 NeoPixels mounted. This library defines some helpers for using the NeoPixels.

// Show all leds
bitbot.neoSetColor(neopixel.colors(NeoPixelColors.Red));
bitbot.neoShow();

// Clear all leds
bitbot.neoClear();
bitbot.neoShow();

// Show led at position 1
bitbot.neoSetPixelColor(0, neopixel.colors(NeoPixelColors.Red));
bitbot.neoShow();

// Show led rainbow
bitbot.neoRainbow();
bitbot.neoShow();

// Show led rainbow and shift
bitbot.neoRainbow();
bitbot.neoShift();
bitbot.neoShow();

// Show led rainbow and rotate
bitbot.neoRainbow();
bitbot.neoRotate();
bitbot.neoShow();

// Set brightness of leds
bitbot.neoBrightness(100);
bitbot.neoShow();

// Use neo() variable
bitbot.neo().clear();
bitbot.neo().show();

Supported targets

  • for PXT/microbit

License

Apache 2.0

calliope-bitbot's People

Contributors

drerik avatar james-calliope avatar pelikhan avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.