Code Monkey home page Code Monkey logo

pxt-makerbit-ir-receiver's Introduction

MakerBit IR Receiver

Build Status

MakeCode extension for Keyestudio Infrared Wireless Module Kit. The extension should also work with other with IR receivers and NEC compatible IR remotes.

MakerBit Board

The MakerBit connects to the BBC micro:bit to provide easy connections to a wide variety of sensors, actuators and other components.

http://makerbit.com/

MakerBit MakerBit+R
MakerBit MakerBit+R with motor controller

Documentation

makerbit.connectIrReceiver

Connects to the IR receiver module at the specified pin and configures the IR protocol.

makerbit.connectIrReceiver(DigitalPin.P0, IrProtocol.Keyestudio)

Parameters

  • pin - digital pin with an attached IR receiver
  • protocol - the IR protocol to be detected, for example IrProtocol.Keyestudio or IrProtocol.NEC

makerbit.onIrButton

Do something when a specific button is pressed or released on the remote control.

makerbit.onIrButton(IrButton.Ok, IrButtonAction.Pressed, () => {})

Parameters

  • button - the button to be checked
  • action- the trigger action
  • handler - body code to run when the event is raised

makerbit.irButton

Returns the code of the IR button that was pressed last. Returns -1 (IrButton.Any) if no button has been pressed yet.

makerbit.irButton()

makerbit.onIrDatagram

Do something when a specific button is pressed or released on the remote control.

makerbit.onIrDatagram(() => {})

Parameters

  • handler - body code to run when the event is raised

makerbit.irDatagram

Returns the IR datagram as 32-bit hexadecimal string. The last received datagram is returned or "0x00000000" if no data has been received yet.

makerbit.irDatagram()

makerbit.wasIrDataReceived

Returns true if any IR data was received since the last call of this function. False otherwise.

makerbit.wasIrDataReceived();

makerbit.irButtonCode

Returns the command code of a specific IR button.

makerbit.irButtonCode(IrButton.Number_9)

Parameters

  • button - the button

MakeCode Example

makerbit.connectIrReceiver(DigitalPin.P0, IrProtocol.Keyestudio)

makerbit.onIrButton(IrButton.Ok, IrButtonAction.Released, function () {
    basic.showIcon(IconNames.SmallHeart)
})

makerbit.onIrButton(IrButton.Ok, IrButtonAction.Pressed, function () {
    basic.showIcon(IconNames.Heart)
})

basic.forever(function () {
    if (makerbit.wasAnyIrButtonPressed()) {
        basic.showNumber(makerbit.irButton())
    }
})

License

Licensed under the MIT License (MIT). See LICENSE file for more details.

Supported targets

  • for PXT/microbit
  • for PXT/calliope

pxt-makerbit-ir-receiver's People

Contributors

engineer2designer avatar philipphenkel 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.