updraftplus
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home1/wyolum/public_html/wp-includes/functions.php on line 6114<\/a>So the DOOMSDAY! clock needs to be somewhat weatherproof. With this in mind, we decided to forego any buttons that we’d need to access from the outside of the clock and instead use an infrared remote control that I had laying around from Paralax.<\/p>\n I just now got the ‘duino reading the pulse sequences consistently thanks to some help from the internets.<\/p>\n The first stop was AdaFruit Industries where I picked up a few IR sensors<\/a>. I know there are a few different vendors out there, but I wanted to make sure that the sensor would work with the code and Ada as a super tutorial<\/a> that got us up and running quickly. \u00a0The sample code in the tutorial continually looks for pulses coming in on the IR pin and measures the “pulse widths” or time durations of the electrical pulses coming from the sensor. \u00a0Each button press triggers a train of pulses that are each measured in turn. \u00a0The message is determined by the series of pulse widths.<\/p>\n The image below depicts the pulse widths sequentially on a plot for a single button press to\u00a0illustrate\u00a0the point. \u00a0The blue line shows the on\/off durations, the green line just indicates the on durations (or pulse widths).<\/p>\n <\/a><\/p>\n Where the top image show the raw pulse times, the bottom image indicates weather the each pulse width was above (indicating a binary 1) or below a threshold \u00a0(indicating a binary 0)\u00a0of 1000 uS (1\/1000 of a second). \u00a0After studying the pulse trains from each button press on my remote, I learned that they all start with the same start and stop sequences with a varying message\u00a0occurring\u00a0in the green zone.<\/p>\n So this is enough to get some IR action up and running. \u00a0But I didn’t want to tie up the ‘duino checking for pulses when 99.99% of the time, there will be no pulses. \u00a0Seems like a waste and when the processor gets busy, the response time will lag.<\/p>\n Interrupts are ideal in these situations. \u00a0So much so, it is even worth the hassle of learning how to use them. \u00a0They can be tricky to implement and debug, but with the right help, it was not to hard in this case. \u00a0The right help came from this page<\/a> in the Arduino Playground.<\/p>\n Normally, I would use one of the Arduino predefined hardware interrupts on digital pins 2 and 3. \u00a0They are very straight forward<\/a> to use. \u00a0In my case however, the hardware interrupt pins were already taken and I had to resort to the PCINT pins. \u00a0The ATMEGA328 (heart of Arduino) allows hardware interrupts on each and every pin. \u00a0Which brings us to this page<\/a> on the Playground which shows how.<\/p>\n The idea is to write an interrupt handler that only gets called when a specified event occurs. \u00a0In this case, the event is a change on the IR sensor pin. \u00a0The rest of the code can be be written without much attention to the interrupt handling. \u00a0So if the pin goes from low to high, we start a pulse timer. \u00a0When it goes from high to low, we compute the\u00a0elapsed\u00a0time from the start of the pulse: the pulse width. \u00a0The rest of the interrupt handler checks the pulse width to see if it is above or below the bit threshold and deals with the resulting bit.<\/p>\n What pops out, when a message is\u00a0sandwiched\u00a0by a valid START_SEQ and STOP_SEQ, is a 10-bit numerical value which we can use to trigger higher level events and actions.<\/p>\n Here is some test\u00a0code<\/a> that makes it happen.<\/p>\n","protected":false},"excerpt":{"rendered":" So the DOOMSDAY! clock needs to be somewhat weatherproof. With this in mind, we decided to forego any buttons that we’d need to access from the outside of the clock and instead use an infrared remote control that I had … Continue reading