based on MakerBit IR Receiver by 1010Technologies
MakeCode extension for set of IR receiver VS1838B HX1838 and Mini Slim controller (product name can vary depending on the seller - see pictures bellow). Kit usually includes 5mm IR LED for construction of your own transmiter.
unsoldered components | soldered board |
IR receiver chip is focused to use with Arduino and Raspberry Pi, however, works with micor:bit and calliope too. According to VS1838B datasheet, it features:
- [ frequency ] 38 kHz
- [ working voltage ] 2.7 – 5.5 V DC
- [ Receiver Distance ] 22 – 25 m
- [ Size ] 7.4 mm x 6.2 mm x 5.3 mm
Mini Slim infrared remote controller |
Some sellers could print their logo on controller, but functionality should be same.
- [ buttons ] 17 function keys; the effective life of 20,000 pressings
- [ frequency ] 38 kHz
- [ effective angle ] 60°
- [ transmission distance ] cca 8 m (specific and surroundings, the receiver sensitivity and other factors)
Open this page at https://github.com/BrickHackers/pxt-IR-VS1838
This repository can be added as an extension in MakeCode.
- open https://makecode.microbit.org/
- click on New Project
- click on Extensions under the gearwheel menu
- search for https://github.com/BrickHackers/pxt-IR-VS1838 and import the IR VS1838 extension
Connects to the IR receiver module at the specified pin.
irVS1838.connectIrReceiver(DigitalPin.P0)
pin
- digital pin with an attached IR receiver
Connects to the IR receiver module at the specified pin. Display it on LED matrix. [ NOTE ] Display animation take some time. This function was added for log pin during testing.
irVS1838.connectIrReceiverVisual(DigitalPin.P0)
pin
- digital pin with an attached IR receiver
Do something when a specific button is pressed or released on the remote control.
irVS1838.onIrButton(IrButton.Ok, IrButtonAction.Pressed, () => {})
button
- the button to be checkedaction
- the trigger actionhandler
- body code to run when the event is raised
Returns the code of the IR button that was pressed last. Returns -1 (IrButton.Any) if no button has been pressed yet.
irVS1838.irButton()
Do something when a specific button is pressed or released on the remote control.
irVS1838.onIrDatagram(() => {})
handler
- body code to run when the event is raised
Returns the IR datagram as 32-bit hexadecimal string. The last received datagram is returned or "0x00000000" if no data has been received yet.
irVS1838.irDatagram()
Returns true if any IR data was received since the last call of this function. False otherwise.
irVS1838.wasIrDataReceived();
Returns the command code of a specific IR button.
irVS1838.irButtonCode(IrButton.Num9)
button
- the button
irVS1838.connectIrReceiver(DigitalPin.P0)
basic.forever(function () {
if (irVS1838.wasAnyIrButtonPressed()) {
basic.showNumber(irVS1838.irButton())
}
})
irVS1838.onIrButton(IrButton.OK, IrButtonAction.Pressed, function () {
basic.showIcon(IconNames.Heart)
})
irVS1838.onIrButton(IrButton.OK, IrButtonAction.Released, function () {
basic.showIcon(IconNames.SmallHeart)
})
Licensed under the MIT License (MIT). See LICENSE file for more details.
- for PXT/microbit
- for PXT/calliope