Don't worry about formatting, just type in the text and we'll take care of making sense of it. We will auto-convert links, and if you put asterisks around words we will make them bold.
Tips:
For a full reference visit the Markdown syntax.
Posted by @allObjects
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.
This detector is able to notice sudden light changes and calls a callback function with true and false for increase and decrease of a value beyond a slope (dv / dt). The detector accepts a function for reading the value to adjust to any input: light for Puck, analog values, etc.
Because I did not have the Puck at hand yet, I cross developed in an HTML5 document in the browser. The only failure was that the activity indicator flashing of the red LED impacted the light sensing... all depending the light conditions. Switching to the green LED allowed me to make a clip.
HTML file is attached and can be run from link below. Clicking Create and Start button and then various Light Intensity buttons shows wether an on - increase - or off was detected. For subsequent increases only the first is triggering the callback.
The detecter is part of another project which is also 'complete' but subject of a different conversation some time later: A Morse Code detector built with a Puck that interprets the dot-dash sequences and prints the message in clear text...
From below HTML5/JavaScript code you make a straight copy-paste of the portion between
---BEG---
and---END---
markers into the Espruino Puck Web IDE and uploaded it to the Puck.After upload, the light detector is created by entering
l()
in the console, and started withr()
(for run). Enterings()
stops the detector,r()
gets it going again.Shining light on the Puck or obstructing ling from reaching it creates different values. For the right slope the the callback reports an
on
oroff
in the console with the read value and time.4 Attachments