#Hi. Suggestions for decoding IR button
1 messages · Page 1 of 1 (latest)
This results in an icon showing when I push a button on an IR remote.
let lastSignal = 0
basic.forever(function () {
let currentSignal = pins.digitalReadPin(DigitalPin.P0)
if (currentSignal == 0 && lastSignal == 1) {
basic.showIcon(IconNames.Happy)
}
lastSignal = currentSignal
})
If it's the one with the GRY that one is annoying to wire correctly but if it wasnt wired correctly (ie: power to GND, GND to power) it would be always on also a led on it supposed to light up when it receive something even before your code
are you seeing a led when you use the remote and is it connected to a PWM pin ?
anyway when Im back from work maybe I can help double check the wiring with you if it's the one with pins saying G R Y
is that the one u have: ? I use elegoo stuff too
so yeah the top-left thingie on the far-left side of the breakout is a led, just tried it light up when it gets an IR wave
I dont know makecode but what I know is that everytime you press a touch on your remote you should get a stream of bits
In there there should be a keycode and in your code you would associate a keycode with an action you want to do. Like Power button on the remote could be 81740
so the ir receiver would says they got a stream like 10011111101001100 cuz they are supposed to get the stream and send it in digital stream form
AFter that the next step would be to identify the exact protocol your remote uses to have 100% accuracy on keycode and other infos (like mine has a TV, VCR and AUX switch so the keycodes are the same, but there is a peripheral info the stream too)
That was my first project after doing all the arduino tutorial so hopefully I can help 🙂
Also going to asks the obvious , but you tried the microbits IR extension I guess ?
because that ir receiver is very common but just works a bit oddly
@topaz prairie Thanks! Need to go teach, but I’ll study your response later. I got as far as detecting, but not decoding: https://davebsoft.com/programming-for-kids/classes/stp/2024-25/trimester3.html#2025-03-27
Dave Briccetti writes software for clients, and teaches computer science, electronics and making to kids.
I tried all the extensions I could find, without success, and with ChatGPT for an hour or so, even tried using MicroPython.