I am violating my own choice to only provide assistance with official authentic supported boards @user107037, but as the issue is with an existing code example, and with the spirit of X-Mas upon us, I'll have Santa send through a few observations.
It would be cleaner to wrap the setWatch() within it's own function, and call that function within the E.on('init', ... that is structured correctly in place. Insert as the very first line before the intervals are set.
L40 points to an invalid pin name, maybe a habit left over from Arduino development?
L45 and L55 I believe it is setTimeout rather than setInterval that is required.
'The only thing I need is to understand how to connect the IR diode'
From the image within the link provided in #5 post, the IR transmit diode is across Pins A5 and A6. See the third bulleted point that indicates to connect the shortest leg, the cathode to pin A5 It's current limiter resistor makes use of the internal pullup.
The separate second setWatch() function is missing. See the last function on that page and take a close look at how the 'times' array of pulses is sent out through the IR diode by investigating the 'Send the pulses' comment there.
Good luck! Have fun and have a Happy Holiday Season!!
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.
Mon 2019.12.23
I am violating my own choice to only provide assistance with official authentic supported boards @user107037, but as the issue is with an existing code example, and with the spirit of X-Mas upon us, I'll have Santa send through a few observations.
It would be cleaner to wrap the
setWatch()
within it's own function, and call that function within theE.on('init', ...
that is structured correctly in place. Insert as the very first line before the intervals are set.L40 points to an invalid pin name, maybe a habit left over from Arduino development?
L45 and L55 I believe it is setTimeout rather than setInterval that is required.
From the image within the link provided in #5 post, the IR transmit diode is across Pins A5 and A6. See the third bulleted point that indicates to connect the shortest leg, the cathode to pin A5 It's current limiter resistor makes use of the internal pullup.
The separate second
setWatch()
function is missing. See the last function on that page and take a close look at how the 'times' array of pulses is sent out through the IR diode by investigating the 'Send the pulses' comment there.Good luck! Have fun and have a Happy Holiday Season!!