For the receiver, for the remote control I used, the time the signal was 0 doesn't matter so it isn't measured (it's the opposite of the time the signal is 1). If you were using a different brand of remote control socket then it could be different...
For:
var bits = (CODE & ~0b11111) | command;
You're correct - it makes the last 5 bits of the code zero, and then it adds in the command. This is because the last 5 bits contain the command code. They could have just been zeroed when CODE was set, but I wanted to make it so you could just copy and paste the code you got in order to make it work.
socketOn = !socketOn; is just so that when you press the button on Espruino, it toggles the socket between turning on and turning off. If you had two buttons you could assign one to sendMultiple(0b11110); and one to sendMultiple(0b01110);...
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
For the receiver, for the remote control I used, the time the signal was 0 doesn't matter so it isn't measured (it's the opposite of the time the signal is 1). If you were using a different brand of remote control socket then it could be different...
For:
You're correct - it makes the last 5 bits of the code zero, and then it adds in the command. This is because the last 5 bits contain the command code. They could have just been zeroed when
CODE
was set, but I wanted to make it so you could just copy and paste the code you got in order to make it work.socketOn = !socketOn;
is just so that when you press the button on Espruino, it toggles the socket between turning on and turning off. If you had two buttons you could assign one tosendMultiple(0b11110);
and one tosendMultiple(0b01110);
...