tag:blogger.com,1999:blog-91307268492488510412024-02-08T08:42:22.150+01:00Deddies LabElectronics blog - custom electronics, DIY projects and Raspberry PiDeddies Labhttp://www.blogger.com/profile/16480149250377086609noreply@blogger.comBlogger18125tag:blogger.com,1999:blog-9130726849248851041.post-20941174414479077252014-09-13T20:56:00.000+02:002014-09-14T15:52:31.425+02:00DIY speed measurement with Raspberry PiI am working on a high tech bird house for in my backyard. I am hoping next spring it will be occupied by a couple of great tits. <br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9d_QL_mXA4n2P6MTJri1_S2FWVD0-K9GSPC5RacfOcqNcqf5drh6Vsz3gEuZFNrVMW7Ck9o7_SrO2CmMyk17iCNOdDqfs39dizSbEvWlUJQo2yvGVEV9HdN8TJtGCqJRU140DD_RLPImA/s1600/GreatTit002.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9d_QL_mXA4n2P6MTJri1_S2FWVD0-K9GSPC5RacfOcqNcqf5drh6Vsz3gEuZFNrVMW7Ck9o7_SrO2CmMyk17iCNOdDqfs39dizSbEvWlUJQo2yvGVEV9HdN8TJtGCqJRU140DD_RLPImA/s1600/GreatTit002.jpg" height="255" width="400" /></a></div>
<br />
<div style="text-align: center;">
<interupt></interupt>***********************INTERUPT**************************</div>
Did I just write 'great tits'? Yes I did, in Dutch it is just a simple 'koolmees', but Google translator actually translates this to 'great tit'. I thought Google was being funny, but when searching images of a great tit, you actually get pictures of <a href="https://www.google.nl/search?q=great+tit&client=firefox-a&hs=efP&rls=org.mozilla:nl:official&channel=sb&source=lnms&tbm=isch&sa=X&ei=m_0TVOGwA4iNO__GgLAD&ved=0CAgQ_AUoAQ&biw=1366&bih=657" target="_blank">great tits</a> instead of .... great tits [link removed by author].<br />
<div style="text-align: center;">
***********************/INTERUPT***********************</div>
<br />
Anyway, the plan is that a pair of little great tits start their family in my birdhouse. And I will be on the front row. The birdhouse will be equiped with a night vision camera, a bunch of sensors and a scale to weigh the bird's nest. It is all connected to a Raspberry Pi and made visible on a web site. More will follow this autumn.<br />
<br />
One of the features will be a couple of light gates that monitor the birds flying in and out. This setup can also be used for measuring the speed of an object passing each of the light gates. In the demo video you see I can shoot my finger with a speed of 7m/s. That is more then 25km/h or 15mph. I even managed to reach 11m/s once off-camera. So you now know that you can pick your nose and shoot the content with 40km/h (25mph)!<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/YcCPJm1C8e0?feature=player_embedded' frameborder='0'></iframe> </div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
The picture below shows the schematics. It has two 3mm IR leds (I don't know the type numbers) that are powered by the 3V3 supply of the Raspberry Pi. The leds don't need to be very powerful because the IR receivers will only be 3cm away. These receivers are <a href="http://www.vishay.com/docs/81531/bpw85a.pdf" target="_blank">BPW85</a> NPN phototransistors that are sensitive to visible and IR light. The base voltage is dependent of the amount of light that it receives which allows current to flow from collector to emitter. I used a 10K variable resistor to be able to tune the voltage drop to a HIGH level of 3V3 that I can feed to the RPi. So, when the lightpath is blocked it outputs 0V, and 3V3 when the lightpath is not blocked. I found out that when I increased the distance between IR transmitter and receiver to over 4cm the light wasn't strong enough to reach a 3V3 voltage drop. If so, you have to increase the current through the leds or make a buffer (like a Darlington pair) to make it work.</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgetR2BBlgTsu8wsRkY3XkDivwW5EQ9YBhYC5dECjWDSDJSuH_5_-hghU3ZJOUbMebVpIDk_AByXuDCOm5itWhtdQ04mrfTInyDSe6GgpgJXYJjQ6JycZjxvWMdHaPGXzUC8Ylf0ZYI827p/s1600/IR_speed_measurement.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgetR2BBlgTsu8wsRkY3XkDivwW5EQ9YBhYC5dECjWDSDJSuH_5_-hghU3ZJOUbMebVpIDk_AByXuDCOm5itWhtdQ04mrfTInyDSe6GgpgJXYJjQ6JycZjxvWMdHaPGXzUC8Ylf0ZYI827p/s1600/IR_speed_measurement.JPG" height="300" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
The software is made in Python. The standard way of checking for inputs on the Rpi is with polling (<i>if GPIO.input(x): blablabla</i>). In my previous blog post I got a tip to use edge triggering, which is faster, more reliable and relieves the CPU. Basically the program is always sleeping, only when one of the GPIO inputs goes from a HIGH ('lightpath is unblocked') to a LOW ('lightpath is blocked') level a dedicated function is called. This feature is explained very thorough on <a href="http://www.adafruit.com/blog/2013/03/22/how-to-use-interrupts-with-python-on-the-raspberry-pi-and-rpi-gpio/" target="_blank">Adafruit</a>, but the code below shows the basic example how to use it.</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
The code waits for a falling edge on both GPIO inputs 2 and 3 (pins 13 and 15). If one the two is triggered, it checks if the other input was already triggered. If this is the case it calculates the time difference in microseconds for a precise measurement. The distance between the light gates is 3cm, which is needed to calculate the speed.</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
For the upcoming birdhouse application it also checks if the bird entered or left the birdhouse, but for the booger shooter application I suggest you always shoot in one direction, that is AWAY from you.</div>
<br />
The code can be found here (<a href="http://pastebin.com/9C1JVCrH" target="_blank">link</a>):<br />
<iframe src="http://pastebin.com/embed_iframe.php?i=9C1JVCrH" style="border: none; height: 500px; width: 100%;"></iframe> <br />
<br />Deddies Labhttp://www.blogger.com/profile/16480149250377086609noreply@blogger.com1tag:blogger.com,1999:blog-9130726849248851041.post-72487148593554932262014-08-17T15:18:00.001+02:002014-08-19T22:12:50.867+02:00Pi-files: Frontdoor light switch based on local sunset/sunrise<div style="text-align: justify;">
I have a couple of front door LED lights which I would like to switch on automatically during the evening/night. The two conventional methods that are commonly available had their disadvantages:</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1K7N65uM0FA9eKP71tElPgQWp_2vVPhaBM-54mOabnFVKsAyc4PK65r45Mn-mJqfbCFP2fqlOY8TAIDFEGRB1Te2W-CYjdbKdeBOtRnYM3KQFogc7ByskaE4WeaLOsrLBRLDGfhyphenhyphenDD-NF/s1600/buitenlicht1.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1K7N65uM0FA9eKP71tElPgQWp_2vVPhaBM-54mOabnFVKsAyc4PK65r45Mn-mJqfbCFP2fqlOY8TAIDFEGRB1Te2W-CYjdbKdeBOtRnYM3KQFogc7ByskaE4WeaLOsrLBRLDGfhyphenhyphenDD-NF/s1600/buitenlicht1.JPG" height="300" width="400" /></a></div>
<br /></div>
<div style="text-align: justify;">
A timer switch is the easiest and cheapest solution, but doesn't take into account day light savings. Besides that, in Einhoven, the Netherlands where I live in december the sun sets around 16:30 while in June it doesn't get dark before 22:00. A simple timer doesn't take that into account either.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Since you only want the lights on when it gets dark, instead of time you can also use a light sensor to distinguish day and night. You have these front door lights that have this built in. The problem that I had with these devices is that they start bouncing ('flickering') around sunset/sunrise. They constantly turn on/off which causes damage to the LED lights I was using. This cost me already several expensive led lights.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Since I already have a Raspberry Pi installed in the hall way (used for the <a href="http://deddieslab.blogspot.nl/2014/08/pi-files-doorbell-alert-with.html" target="_blank">doorbell alert</a>) I might as well hook up the front door lights. You can find on the Internet all sorts of <span id="goog_179806063"></span><a href="http://zonsondergang.info/" target="_blank">timetables <span id="goog_179806064"></span>for the sunset/sunrise</a>, so my Rpi should be able to use that same information as well. A small search on the world wide web led me to a Python package called <a href="http://rhodesmill.org/pyephem/" target="_blank">PyEphem</a>. This package can be used to do astronomical calculations and can tell you for example where a certain object (e.g. the sun) is with respect to the observer (which is me standing in my front yard). Very conveniently it also can calculate for you the upcoming sunset and sunrise. Isn't that exactly what I need?!?</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
The LED lights are powered with a 12V AC-DC transformer. I put together a small electronics board to be able to use the GPIO's 3V3 of the Rpi to switch the 12V LEDs. I used a <a href="http://www.irf.com/product-info/datasheets/data/irl3103.pdf" target="_blank">IRL3103</a> N-FET. This is not really a deliberate choice but like most of my transistor/FET choices based on what I have lying around in the lab. Be aware that the N-FET needs to be able to switch with a Gate-Source voltage of 3V3. For example an IRF540 (which I used for a <a href="http://deddieslab.blogspot.nl/2014/05/motion-detection-for-12v-ledbar.html" target="_blank">motion detector for a 12V ledbar</a>) doesn't switch with this voltage (Here I solved it by using a smaller BS170 N-FET and use that to switch a IRF 9540 P-FET). I added a manual switch to override the automatic switch in case I just want to turn on the lights. Parallel to the front door LEDs is a test led with a resistor onboard to be able to test the functionality without having to connect the actual front door lights.</div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAWmLBvosUtdJaQ5HwLq0GTe_iqwFKX2FZgTdheQji01SR-JaX6qiKBi3FQcoKlDn48jWJj6U5Wd5pauMeDEd0EHSGNpQ7SXVH9JqQJMg45j7gsGkqhsdQ9AEecVF8Hepbb_nvlSUgqc_X/s1600/rpi_frontdoorlights_edit.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAWmLBvosUtdJaQ5HwLq0GTe_iqwFKX2FZgTdheQji01SR-JaX6qiKBi3FQcoKlDn48jWJj6U5Wd5pauMeDEd0EHSGNpQ7SXVH9JqQJMg45j7gsGkqhsdQ9AEecVF8Hepbb_nvlSUgqc_X/s1600/rpi_frontdoorlights_edit.jpg" height="285" width="400" /></a></div>
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggxfkNxNZfOOAe3mFbAfEZV-RWrWJZrGlO5SQ2elzNniZaxfD0RSgPYtFOjc4NpO1XdSCcC6SH3xy3c8FdEURbmpG3FjoLlpcI6DwjFaRWn0OPRV-yrU1Y5eki6VPT6i-np38XDnRME0aS/s1600/buitenlicht2.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggxfkNxNZfOOAe3mFbAfEZV-RWrWJZrGlO5SQ2elzNniZaxfD0RSgPYtFOjc4NpO1XdSCcC6SH3xy3c8FdEURbmpG3FjoLlpcI6DwjFaRWn0OPRV-yrU1Y5eki6VPT6i-np38XDnRME0aS/s1600/buitenlicht2.JPG" height="400" width="400" /></a></div>
</div>
<div style="text-align: justify;">
<br />
I use GPIO pins 18 and 22 to switch the two LED's. You can switch LED's with only one output, but I thought it is a nice additional feature to switch them separately to be able to also create a spooky program for Halloween or something like that.</div>
<div style="text-align: justify;">
After including the PyEmphem package I have to indicated where the observer is located. I used <a href="http://itouchmap.com/latlong.html" target="_blank">itouchmap</a> which can translate an address to a latitude and longitude coordinates. Being an observer in Eindhoven means you are located at [51.5, 5.5]. The PyEphem package calculated the next sunrise and sunset and returns these values. I do this every minute and compare the two; if the next sunset if further away in time than the next sunrise, it means it is night. The other way around means daytime. The LED lamps are switched based on the day/night status.<br />
<br />
The code can be found here (<a href="http://pastebin.com/WPvPB3RA" target="_blank">link</a>):<br />
<iframe src="http://pastebin.com/embed_iframe.php?i=WPvPB3RA" style="border: none; height: 500px; width: 100%;"></iframe> <br />
<br /></div>
<br />
<div style="text-align: justify;">
<div class="code_box">
<br /></div>
</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
Deddies Labhttp://www.blogger.com/profile/16480149250377086609noreply@blogger.com1tag:blogger.com,1999:blog-9130726849248851041.post-58530880625152272412014-08-04T16:06:00.000+02:002014-08-19T21:40:41.437+02:00Pi-files: Doorbell alert with pushmessage and mail with webcam footage<div style="text-align: justify;">
<span style="font-size: small;">Actually the first 'project' I ever did with a Raspberry Pi was sending a push message to my Iphone. It was 2012, I was lying sick in bed and found a new app on my Iphone called <a href="https://pushover.net/" target="_blank">Pushover</a> (what else to do when you're sick?). With Pushover you can send and receive custom made push messages. On the website I found a simple Python script to send messages. I knew the Rpi was able to run Python code, so here my Rpi adventures started. Within 30 minutes I was able to receive 'hello world' on my phone (needless to say I wasn't lying in bed anymore). Seeing 'hello world' on your screen is like the software equivalent of the blinking led, THE coolest feature ever!</span></div>
<div style="text-align: justify;">
<span style="font-size: small;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-size: small;">I decided to hook up this push message feature with my doorbell. The idea is that every time somebody rings the doorbell, I get a push message that there is somebody at the door. The wires of the doorbell were already connected to a wireless transmitter and I wanted to keep that functionality. I used a relay to combine the transmitter with a switch on the GPIO header of the Raspberry Pi.</span></div>
<div style="text-align: justify;">
<span style="font-size: small;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_0VxnHHy3iZY_9Hj6L0nUx-2zDvP4TxXSUh6DdctvAc7cqvBwqV__l3G5C5O4MgjSd3zbRaF2xWMfHZaDgpciFy_t6tP1ujo_Fq3FRPsEJMyhDUIJuDf4EnlgugTqqTYKjXD4sKvWyy7I/s1600/doorbell_watcher_schematic3.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_0VxnHHy3iZY_9Hj6L0nUx-2zDvP4TxXSUh6DdctvAc7cqvBwqV__l3G5C5O4MgjSd3zbRaF2xWMfHZaDgpciFy_t6tP1ujo_Fq3FRPsEJMyhDUIJuDf4EnlgugTqqTYKjXD4sKvWyy7I/s1600/doorbell_watcher_schematic3.JPG" height="300" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiI50Myk7p6Usvd3yHGinRqcZZ_UqrrOB915e_O6aSuVFzdonjr-x8iFPJbEY1rFDO2L7Rb1tbno6G2xaIq-ppAuXwW2FszV2pHPGM4HmxIwZueLzBhmMM4KJcyOp9pws09Vu-_ompb5TPC/s1600/doorbell_watcher_schematic2.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><br /></a></div>
<div style="text-align: justify;">
<span style="font-size: small;">The led and 330R resistor can be installed in the actual doorbell, so the person can find the doorbell and is triggered when the button is pressed in case he/she doesn't actual hear the bell (the led turns off when the doorbell is pressed). The 100u capacitor and flyback diode are to limit voltage peaks when using the relay. The 'test' switch is available close to the GPIO header to test the (software) functionality of the doorbell alert. The relay and test switch are connected to pin11 (GPIO0) of the Rpi.</span></div>
<div style="text-align: justify;">
<span style="font-size: small;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<span style="font-size: small;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqTRn_VVIfyLnH_7Fjeg4baaMNuZIwguiiVH24PGCXfwdPrvjtHu2P8Fr_VPtc5OE24XPCBLomVqxz4hMakXn0y8XkZyDj4e1KQlk8lc-eF1Hdr4NVlBqgik0MMpGpXE5IwUIDO2S2Mzuq/s1600/IMG_1854.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqTRn_VVIfyLnH_7Fjeg4baaMNuZIwguiiVH24PGCXfwdPrvjtHu2P8Fr_VPtc5OE24XPCBLomVqxz4hMakXn0y8XkZyDj4e1KQlk8lc-eF1Hdr4NVlBqgik0MMpGpXE5IwUIDO2S2Mzuq/s1600/IMG_1854.JPG" height="266" width="400" /></a></span></div>
</div>
<div style="text-align: justify;">
<span style="font-size: small;">The Python code looks as follows. First the necessary libraries are included and the GPIO header is configured:</span></div>
<div style="text-align: justify;">
<span style="font-size: x-small;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: "Courier New",Courier,monospace; font-size: x-small;">#import libs</span></div>
<div style="text-align: justify;">
<span style="font-family: "Courier New",Courier,monospace; font-size: x-small;">import RPi.GPIO as GPIO</span></div>
<div style="text-align: justify;">
<span style="font-family: "Courier New",Courier,monospace; font-size: x-small;">import httplib, urllib<br />import time<br />from time import sleep, localtime, strftime </span></div>
<div style="text-align: justify;">
<span style="font-family: "Courier New",Courier,monospace; font-size: x-small;"><br />#display no warnings (on command line)<br />GPIO.setwarnings(False)</span></div>
<div style="text-align: justify;">
<span style="font-family: "Courier New",Courier,monospace; font-size: x-small;">#set GPIO: use RPi board pin numbers<br />GPIO.setmode(GPIO.BOARD) #alternative is GPIO.BCM (Broadcom names)<br />#set pin 11 as input<br />GPIO.setup(11, GPIO.IN) #Input: doorbell (relay)</span></div>
<div style="text-align: justify;">
<span style="font-size: small;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-size: small;">A seperate function is written for the push message. This is mainly copied from the Pushover <a href="https://pushover.net/faq#technical-how" target="_blank">FAQ</a> section (<i>'How do I send Pushover notifications in Python?'</i>). The token (<i>'push_token'</i>) and user ID (<i>'push_user'</i>) you get when you sign in on the website. There you can also select the devices on which you want to receive the push messages.</span></div>
<div style="text-align: justify;">
<span style="font-size: small;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-size: x-small;"><span style="font-family: "Courier New",Courier,monospace;">#set up push message (pushover)</span></span></div>
<div style="text-align: justify;">
<span style="font-size: x-small;"><span style="font-family: "Courier New",Courier,monospace;">def push(text):<br /><br /> push_token = 'xxx'<br /> push_user = 'yyy'<br /><br /> conn = httplib.HTTPSConnection("api.pushover.net:443")<br /> conn.request("POST", "/1/messages.json",<br /> urllib.urlencode({"token": push_token,<br /> "user": push_user,<br /> "message": text,}), </span></span></div>
<div style="text-align: justify;">
<span style="font-size: x-small;"><span style="font-family: "Courier New",Courier,monospace;"> {"Content-type": "application/x-www-form-urlencoded" })<br /> conn.getresponse()</span></span></div>
<span style="font-size: small;"><br /></span>
<span style="font-family: Arial,Helvetica,sans-serif; font-size: small;"><span style="font-family: Times,"Times New Roman",serif;">The main loop checks for the GPIO input regularly. I added a tiny bit of delay (<i>sleep</i>) to relieve the CPU. When the doorbell is pressed, it takes the current date and time and adds that to the push message.</span><i><br /></i></span><br />
<span style="font-size: small;"><br /></span>
<span style="font-size: x-small;"><span style="font-family: "Courier New",Courier,monospace;">while 1:<br /><br /> sleep(0.1) #relieves CPU load big time!<br /> <br /> #if doorbell is pressed...<br /> if GPIO.input(11):<br /><br /> #determine date/time and add to message<br /> timestr_date = strftime("%a %d %b %Y", localtime()) <br /> timestr_time = strftime("%H:%M:%S", localtime()) <br /><br /> mess = "Doorbell pressed on {}, {}.".format(timestr_date,timestr_time)<br /> print "\n"<br /> print mess</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "Courier New",Courier,monospace;"><br /></span></span><span style="font-size: small;"><span style="font-size: x-small;">
</span><span style="font-family: "Courier New",Courier,monospace;"><span style="font-size: x-small;"> push(mess)</span> </span></span><br />
<div style="text-align: justify;">
<span style="font-size: small;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-size: small;">When this all worked it was time to extend the doorbell alert feature. Not only I want to know that there is someone at the door, I also would like to know who was at the door, especially when I am not at home. I added a Logitech C270 webcam to the setup to capture snapshots and a short movie.</span><br />
<span style="font-size: small;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<span style="font-size: small;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXLiXd85w9Z0IzvBIbTfj2a2GBtSs_7PKR1E1-JSRqeE4ulnuIQIr6ia-c6zUbvKjbw2UCppaPumodGn3936Aqw7L4NJtqtxnwl4AmHCD5-VXpUAjCeNa9qSTZVMMe7SZPK6VC-Ik0iyWG/s1600/IMG_1856.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXLiXd85w9Z0IzvBIbTfj2a2GBtSs_7PKR1E1-JSRqeE4ulnuIQIr6ia-c6zUbvKjbw2UCppaPumodGn3936Aqw7L4NJtqtxnwl4AmHCD5-VXpUAjCeNa9qSTZVMMe7SZPK6VC-Ik0iyWG/s1600/IMG_1856.JPG" height="266" width="400" /></a></span></div>
<span style="font-size: small;"><br /></span>
<span style="font-size: small;">A Python mail script is supposed to send it all to my mailbox. The mail functionality I didn't invent myself, I just relied on the beautiful internet community. On <a href="http://kutuma.blogspot.nl/2007/08/sending-emails-via-gmail-with-python.html" target="_blank">Kutuma's Ramblings</a> I found almost exactly what I needed. The only difference is that I wanted to sent multiple attachments. For that I changed the mail function a little bit:</span></div>
<div style="text-align: justify;">
<span style="font-family: "Courier New",Courier,monospace; font-size: small;"><br /></span></div>
<div style="text-align: justify;">
<b><span style="font-family: "Courier New",Courier,monospace; font-size: x-small;">def mail(to, subject, text, attachments=[]):<br /><br /> gmail_user = 'XXX@gmail.com'<br /> gmail_pwd = 'YYY'<br /><br /> #add attachments to a list<br /> assert type(attachments)==list<br /><br /> msg = MIMEMultipart()<br /><br /> msg['From'] = gmail_user<br /> msg['To'] = to<br /> msg['Subject'] = subject<br /><br /> msg.attach(MIMEText(text))<br /><br /> for attach in attachments:<br /> part = MIMEBase('application', 'octet-stream')<br /> part.set_payload(open(attach, 'rb').read())<br /> Encoders.encode_base64(part)<br /> part.add_header('Content-Disposition',<br /> 'attachment; filename="%s"' % os.path.basename(attach))<br /> msg.attach(part)<br /><br /> mailServer = smtplib.SMTP("smtp.gmail.com", 587)<br /> mailServer.ehlo()<br /> mailServer.starttls()<br /> mailServer.ehlo()<br /> mailServer.login(gmail_user, gmail_pwd)<br /> mailServer.sendmail(gmail_user, to, msg.as_string())<br /> mailServer.close()</span></b></div>
<div style="text-align: justify;">
<span style="font-size: small;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-size: small;">You can now add the attachments as an comma separated array:</span></div>
<div style="text-align: justify;">
<span style="font-size: x-small;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: "Courier New",Courier,monospace; font-size: x-small;">mail("xxx@gmail.com",mess,mess,["screen1.jpg","screen2.jpg","screen3.jpg","movie.avi"])</span></div>
<div style="text-align: justify;">
<span style="font-size: small;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<span style="font-size: small;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3vwryJepa-TkK7ZU3-0HcVVXckW9WRcKVSl5SeR2PyovpFxbFA1eY2l1ezYOBtn25xRFQHuCZTOTd9m1MhCWsgeEXxiJf1yDb6yBd3FYpaPcrJ3tH8Ap3ssujtctBwZiiTkdglAuKyreU/s1600/email.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3vwryJepa-TkK7ZU3-0HcVVXckW9WRcKVSl5SeR2PyovpFxbFA1eY2l1ezYOBtn25xRFQHuCZTOTd9m1MhCWsgeEXxiJf1yDb6yBd3FYpaPcrJ3tH8Ap3ssujtctBwZiiTkdglAuKyreU/s1600/email.png" height="267" width="640" /></a></span></div>
<span style="font-size: small;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-size: small;">As you can see I added three snapshots and one movie as attachments. They all come from the <a href="http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHome" target="_blank">Motion</a> package which is a linux package to capture motion on a webcam. To be honest, I actually don't use the motion feature of that package, but I tried several other solutions (like FFMpeg or something) and came across a bunch of issues with compiling, frame rates etc. The Motion package served my purpose the best. </span></div>
<div style="text-align: justify;">
<span style="font-size: small;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-size: small;">NB. The Raspberry Pi that I am using is a model A, which is not capable of using the <a href="http://www.raspberrypi.org/product/camera-module/" target="_blank">official Rpi camera module</a> with its cool movie and snapshot features.</span></div>
<div style="text-align: justify;">
<span style="font-size: small;"><br /></span>
<span style="font-size: small;">To install the Motion package, run the following command:</span><br />
<span style="font-size: x-small;"><span style="font-family: "Courier New",Courier,monospace;">pi@raspberrypi ~ $ sudo apt-get install motion libv4l-0 uvccapture</span></span><br />
<span style="font-size: small;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-size: small;">I added some additional modules to the import section of the Python script described above and added the code below to the main loop. Starting the webcam is done right after the doorbell is pressed. After capturing the snapshots and sending the push message, the program waits 60 seconds until the webcam is stopped. After this the mail is send with the snapshots and movie.</span></div>
<div style="text-align: justify;">
<span style="font-size: small;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-size: x-small;"><span style="font-family: "Courier New",Courier,monospace;">import subprocess</span></span></div>
<div style="text-align: justify;">
<span style="font-size: x-small;"><span style="font-family: "Courier New",Courier,monospace;">import shutil #high-level file operations</span></span></div>
<div style="text-align: justify;">
<span style="font-size: x-small;"><span style="font-family: "Courier New",Courier,monospace;"><br /></span></span></div>
<div style="text-align: justify;">
<span style="font-size: x-small;"><span style="font-family: "Courier New",Courier,monospace;"> #if doorbell is pressed...<br /> if GPIO.input(11):</span></span></div>
<div style="text-align: justify;">
<span style="font-size: x-small;"><span style="font-family: "Courier New",Courier,monospace;"><br /></span></span></div>
<div style="text-align: justify;">
<span style="font-size: x-small;"><span style="font-family: "Courier New",Courier,monospace;"> #start webcam (motion package)<br /> print "\n"<br /> print "Start webcam (Motion)"<br /> </span></span></div>
<div style="text-align: justify;">
<span style="font-size: x-small;"><span style="font-family: "Courier New",Courier,monospace;"> #subprocess.call("sudo /etc/init.d/motion start", shell=True)<br /> subprocess.call("sudo motion", shell=True)</span></span></div>
<div style="text-align: justify;">
<span style="font-size: x-small;"><span style="font-family: "Courier New",Courier,monospace;"><br /></span></span></div>
<div style="text-align: justify;">
<span style="font-size: x-small;"><span style="font-family: "Courier New",Courier,monospace;"> #copy (save) most recent snapshot of webcam<br /> print "\n"<br /> for k in range(3):<br /> sleep(3)</span></span></div>
<div style="text-align: justify;">
<span style="font-size: x-small;"><span style="font-family: "Courier New",Courier,monospace;"> sour_path = '/home/pi/rpi/webcam/motion/snapshot.jpg'<br /> dest_file = '/home/pi/rpi/webcam/motion/screen%d.jpg' %k<br /> shutil.copy2(sour_path, dest_file)<br /> print 'Snapshot captured: %s' %(dest_file) </span></span></div>
<div style="text-align: justify;">
<span style="font-size: small;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-size: small;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-size: small;"><i><span style="font-family: Arial,Helvetica,sans-serif;"> </span></i><span style="font-family: Times,"Times New Roman",serif;">****** Sending push message (see above) ******</span><i><span style="font-family: Arial,Helvetica,sans-serif;"> </span></i></span></div>
<div style="text-align: justify;">
<span style="font-size: small;"><i><span style="font-family: Arial,Helvetica,sans-serif;"><br /></span></i></span></div>
<div style="text-align: left;">
<span style="font-size: x-small;"><span style="font-family: "Courier New",Courier,monospace;"> print "wait 60 seconds"<br /> sleep(60)<br /> </span></span></div>
<div style="text-align: left;">
<span style="font-size: x-small;"><span style="font-family: "Courier New",Courier,monospace;"> #stop webcam<br /> print "Stop webcam"<br /> subprocess.call("sudo /etc/init.d/motion stop", shell=True) </span></span></div>
<div style="text-align: left;">
<span style="font-size: x-small;"><span style="font-family: "Courier New",Courier,monospace;"><br /></span></span></div>
<div style="text-align: left;">
<span style="font-size: x-small;"><span style="font-family: "Courier New",Courier,monospace;"> #send mail via Gmail</span></span></div>
<div style="text-align: left;">
<span style="font-size: x-small;"><span style="font-family: "Courier New",Courier,monospace;"> mail("xxx@gmail.com",mess,mess,</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "Courier New",Courier,monospace;"> ["screen1.jpg","screen2.jpg","screen3.jpg","movie.avi"])</span></span></div>
<div style="text-align: justify;">
<span style="font-size: small;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<span style="font-size: small;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjauWaQfsubqxAPFpr0zVndNdJLhr-tieG3fngHe0NVAg3JIr5FinJfNpA7OsK4ApRZhk0IWzDd96zGqHy0E_WHr53CAIn1RzUeuWZxU7GbTarEDpSiDSDtB0ds66W054d4OB5-FQmd0mC9/s1600/doorbell1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjauWaQfsubqxAPFpr0zVndNdJLhr-tieG3fngHe0NVAg3JIr5FinJfNpA7OsK4ApRZhk0IWzDd96zGqHy0E_WHr53CAIn1RzUeuWZxU7GbTarEDpSiDSDtB0ds66W054d4OB5-FQmd0mC9/s1600/doorbell1.jpg" height="178" width="320" /> </a></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-size: small;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-size: small;"> <iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.blogger.com/video.g?token=AD6v5dyHkECG_9ISTePx6GboQAE0zgQkp-aqoQAElHDe6zexymsRp5q-PyzM054yi7NxZgsySBYdXjU8vjsfhG0tBg' class='b-hbp-video b-uploaded' frameborder='0'></iframe></span></div>
<span style="font-size: small;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-size: small;">The motion package has a pretty big configuration file where you can configure all sorts of things. Most of the items speak for their own. The file can be edited with nano:</span><br />
<span style="font-size: small;"><br /></span>
<span style="font-size: x-small;">pi@raspberrypi</span><span style="font-size: x-small;"> ~ $ sudo nano /etc/motion/motion.conf </span><br />
<span style="font-size: small;"><br /></span>
<span style="font-size: small;">For the doorbell alert let me highlight the most important sections:</span><br />
<span style="font-size: small;"><br /></span>
<span style="font-size: small;"><b><i># File to store the process ID, also called pid file. (default: not defined)<br />process_id_file /var/run/motion/motion.pid </i></b></span><br />
<span style="font-size: small;">The folder /var/run/motion needs to be present. In my latest Raspbian (Debian Wheezy) OS I encountered a bug (as far as I can tell) that this folder is gone every time I boot up the Rpi. For that reason I added a check and create the folder if necessary:</span><br />
<span style="font-size: small;"><br /></span>
<span style="font-family: Arial,Helvetica,sans-serif; font-size: x-small;">import os</span><br />
<span style="font-family: Arial,Helvetica,sans-serif; font-size: x-small;"><br />folder = "/var/run/motion"</span><br />
<span style="font-family: Arial,Helvetica,sans-serif; font-size: x-small;">if not os.path.exists(folder):<br /> print "Folder does not exist. Create folder " + folder<br /> os.makedirs(folder) </span><br />
<span style="font-size: small;"><i><b><br /></b></i></span>
<span style="font-size: small;"><i><b># Image width/height (pixels). Valid range: Camera dependent, default: 352/288<br />width 1280<br />height 720</b></i></span></div>
<div style="text-align: justify;">
<span style="font-size: small;">Bigger images won't hurt!</span><br />
<span style="font-size: small;"><br /></span>
<span style="font-size: small;"><b><i># Maximum number of frames to be captured per second.<br /># Valid range: 2-100. Default: 100 (almost no limit).<br />framerate 2</i></b></span><br />
<span style="font-size: small;">I only use two frames per second to keep the movie size as small as possible.</span><br />
<span style="font-size: small;"><br /></span>
<span style="font-size: small;"><i><b># Always save images even if there was no motion (default: off)<br />output_all on</b></i></span><br />
<span style="font-size: small;">I don't use the motion detection features so I want all images to be saved</span><br />
<span style="font-size: small;"><br /></span>
<span style="font-size: small;"><i><b># Use ffmpeg to encode a timelapse movie <br /># Default value 0 = off - else save frame every Nth second<br />ffmpeg_timelapse 0.5</b></i></span><br />
<span style="font-size: small;"><br /></span>
<span style="font-size: small;"><i><b># Make automated snapshot every N seconds (default: 0 = disabled)<br />snapshot_interval 1</b></i></span><br />
<span style="font-size: small;">Save snapshots every second</span><br />
<span style="font-size: small;"><br /></span>
<span style="font-size: small;"><i><b># Target base directory for pictures and films<br /># Recommended to use absolute path. (Default: current working directory)<br />target_dir /home/pi/rpi/webcam/motion </b></i></span><br />
<span style="font-size: small;">Location where all files are stored</span><br />
<span style="font-size: small;"><i><b><br /></b></i></span>
<span style="font-size: small;"><i><b># File path for snapshots (jpeg or ppm) relative to target_dir<br />snapshot_filename snapshot</b></i></span><br />
<span style="font-size: small;">All snapshots are given the same name (no timestamp) to save storage space.</span><br />
<span style="font-size: small;"><br /></span>
<span style="font-size: small;"><i><b># File path for motion triggered ffmpeg films (mpeg) relative to target_dir<br />movie_filename movie </b></i></span><br />
<span style="font-size: small;">Each movie is given the same name (no timestamp) to save storage space.</span><br />
<span style="font-size: small;"><br /></span>
<span style="font-size: small;">That's it for now! I am already thinking of new features like face recognition, direct videostream, and a call back option to actually talk to the person at the door wherever I am. The sky is the limit! Unfortunately my spare time as well :)</span><br />
<span style="font-size: small;"><br /></span>
<span style="font-size: small;">Below a picture of my custom storage box which is located in the meter cupboard (again, is that really the correct translation for the dutch word 'meterkast'?). It houses a Raspberry Pi model A, an interface board (on the right) with the well famous <a href="http://deddieslab.blogspot.nl/2014/07/pi-files-heartbeat.html" target="_blank">heartbeat </a>led. On the left two boards for the doorbell and one for the front door light which I will explain in another post soon.</span><br />
<span style="font-size: small;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<span style="font-size: small;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4uqHqlQvEsYqs81ZRFdbqKi_UHcItKE7RZ-zk6dYpfJjzRAuAR4yG1P6vJUB0OVprdeBV8j88MxdjUvjaK0tXtdrG8AqVksh1yoBTdaQYsGizVduS_9uq1LJyRWeW0ZkMeTFXA7XB8Oa7/s1600/IMG_1848.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4uqHqlQvEsYqs81ZRFdbqKi_UHcItKE7RZ-zk6dYpfJjzRAuAR4yG1P6vJUB0OVprdeBV8j88MxdjUvjaK0tXtdrG8AqVksh1yoBTdaQYsGizVduS_9uq1LJyRWeW0ZkMeTFXA7XB8Oa7/s1600/IMG_1848.JPG" height="300" width="400" /></a></span></div>
<span style="font-size: small;"><br /></span>
<span style="font-size: small;"><br /></span></div>
Deddies Labhttp://www.blogger.com/profile/16480149250377086609noreply@blogger.com24tag:blogger.com,1999:blog-9130726849248851041.post-41012356020017442752014-07-27T14:32:00.003+02:002014-08-17T21:44:09.681+02:00Pi-files: Heartbeat<div style="text-align: justify;">
It has been a bit quite here on Deddies lab's blog. That doesn't mean that nothing came out of the lab. Actually a lot has happened, but I didn't had the opportunity (or was a bit too lazy) to post it here. Since I took a lot from the DIY community, I feel obliged to return also my findings, struggles and results back to that same community. Only then we all can grow!</div>
<br />
<div style="text-align: justify;">
Last couple of years, I invested most of my (spare) time in the <a href="http://www.raspberrypi.org/" target="_blank">Raspberry Pi</a> platform. I don't think I have to explain anything about this versatile mini computer. Just google around and you will find tons of projects. I myself was attracted at first to the Rpi because of the General Purpose IO's (GPIO) possibilities which can be used to connect simple inputs (switches) and outputs (nothing beats a blinking led!). I was (still am) used to work with Atmel microcontrollers, where also the pins can be configured as input and output pins. So being able to use the same IO functionality but then combined with ethernet, a decent user interface, etc. etc. etc. opened a whole new world of possibilities.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Let's start easy; Sometimes it is difficult to see from the outside of the Pi is running or not. It has some status leds onboard, but when built in a box and stuffed away in a cupboard (like I have) the status leds are not so easy to see. So for that purpose I made a simple heartbeat. It is just a blinking led, but starts automatically when the Pi boots up, so it indicates when the Pi is alive and kicking!</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
I have a revision A of the RPi in my 'meterkast' (is it really 'meter cupboard'?). For this heartbeat and some other projects (<a href="http://deddieslab.blogspot.nl/2014/08/pi-files-doorbell-alert-with.html" target="_blank">doorbell alert</a>, <a href="http://deddieslab.blogspot.nl/2014/08/pi-files-frontdoor-light-switch-based.html" target="_blank">front door lights</a>) I made a dedicated interface board. It also has a led which is clearly visible from the outside</div>
<div style="text-align: justify;">
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYnATbNkbhCzXzb87PTdM0aPhxAd578Dm66_DIt51aUAo6ucUPf-SAxoEqeh8ukLwO67ayYMXBViLoCiAW0PG6m9bnJviWeRGsaDul1HGGOOrbm46SH-IYJZNHeVTlkurYhW_eSRyjUPfw/s1600/foto+1.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYnATbNkbhCzXzb87PTdM0aPhxAd578Dm66_DIt51aUAo6ucUPf-SAxoEqeh8ukLwO67ayYMXBViLoCiAW0PG6m9bnJviWeRGsaDul1HGGOOrbm46SH-IYJZNHeVTlkurYhW_eSRyjUPfw/s1600/foto+1.JPG" height="320" width="240" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGUmxgMW8sW01RF0xU4w35kEMV9qKoGDPdsJEMgMWdXKM5HNyH2WQcdGRhyGjuBVkwBYrfsAVRZtnW32aJD0TqxXMoWbV96C16jcgXqGHeZXDdB33uHsz6JLlbKIEt2hrlew4WQpN-hM1p/s1600/foto+4_edit.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGUmxgMW8sW01RF0xU4w35kEMV9qKoGDPdsJEMgMWdXKM5HNyH2WQcdGRhyGjuBVkwBYrfsAVRZtnW32aJD0TqxXMoWbV96C16jcgXqGHeZXDdB33uHsz6JLlbKIEt2hrlew4WQpN-hM1p/s1600/foto+4_edit.JPG" height="320" width="240" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYnATbNkbhCzXzb87PTdM0aPhxAd578Dm66_DIt51aUAo6ucUPf-SAxoEqeh8ukLwO67ayYMXBViLoCiAW0PG6m9bnJviWeRGsaDul1HGGOOrbm46SH-IYJZNHeVTlkurYhW_eSRyjUPfw/s1600/foto+1.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"></a></div>
</div>
<div style="text-align: justify;">
<br />
This led is connected to pin 16 of the GPIO header, which is called GPIO4. No, this doesn't make sense, and apparently there is a difference between the physical Raspberry Pi names and Broadcom names. I made a Python script (called heartbeat.py) where I can first configure the IO's:</div>
<div style="text-align: justify;">
<br /></div>
<i><span style="color: lime;">#Libraries/modules</span><br /><span style="color: #76a5af;">import </span>RPi.GPIO as GPIO<br /><span style="color: #76a5af;">from </span>time import sleep<br /><span style="color: lime;"><br />#display no warnings (on command line)</span><br />GPIO.setwarnings(<span style="color: #76a5af;">False</span>)<br /><span style="color: lime;">#use RPi board pin numbers</span><br />GPIO.setmode(GPIO.BOARD)<br /><span style="color: lime;">#set pin 16 as output</span><br />GPIO.setup(<span style="color: red;">16</span>, GPIO.OUT)</i><br />
<br />
<div style="text-align: justify;">
The 'sleep' module is inserted to make the led blink. The while loop makes the led blink indefinite:<br />
<br />
<i><span style="color: #76a5af;">print </span><span style="color: #999999;">"Start heartbeat\n"</span><br /><span style="color: #76a5af;">while </span><span style="color: red;">1</span>:<br /><br /> GPIO.output(<span style="color: red;">16,1</span>)<br /> sleep(<span style="color: red;">0.5</span>)<br /> GPIO.output(<span style="color: red;">16,0</span>)<br /> sleep(<span style="color: red;">0.5</span>)</i></div>
<br />
You can run this script from the command line:<br />
<i><br /></i>
<i><span style="color: lime;">pi@raspberrypi</span> <span style="color: #76a5af;">~ $</span> sudo python /home/pi/gpio/scripts/heartbeat.py <span style="color: red;">&</span></i><br />
<br />
When you want to run the script automatically after boot up of the Rpi, you have to edit <b>/etc/rc.local</b>:<br />
<br />
<i><span style="color: lime;">pi@raspberrypi</span> <span style="color: #76a5af;">~ $</span> </i>sudo nano /etc/rc.local<br />
<br />
<i>#!/bin/sh -e<br />#<br /># rc.local<br />#<br /># This script is executed at the end of each multiuser runlevel.<br /># Make sure that the script will "exit 0" on success or any other<br /># value on error.<br />#<br /># In order to enable or disable this script just change the execution<br /># bits.<br />#<br /># By default this script does nothing.</i><br />
<br />
<i>python /home/pi/gpio/scripts/heartbeat.py & </i><br />
<br />
<i>exit 0</i><br />
<br />
Save the file with Ctrl+X. Make sure that the Python script is executable:<br />
<i><br /></i>
<i><span style="color: lime;">pi@raspberrypi</span> <span style="color: #76a5af;">~ $</span> sudo chmod 755 /home/pi/gpio/scripts/heartbeat.py</i><br />
<br />
You can check if the script is executable if you see the 'x' in the permission overview:<br />
<br />
<i><i><span style="color: lime;">pi@raspberrypi</span> <span style="color: #76a5af;">~ $</span> </i>ls -la</i><br />
<br />
<i>-rwxr-xr-x 1 root root 261 Jul 21 21:34 heartbeat.py</i><br />
<br />
Reboot the Pi and see the led blink:<br />
<br />
<i><i><span style="color: lime;">pi@raspberrypi</span> <span style="color: #76a5af;">~ $</span> </i></i>sudo shutdown -r nowDeddies Labhttp://www.blogger.com/profile/16480149250377086609noreply@blogger.com0tag:blogger.com,1999:blog-9130726849248851041.post-35250734946086476802014-05-29T11:57:00.001+02:002014-05-30T07:51:47.901+02:00Motion Detection for 12V ledbar<div style="text-align: justify;">
On an <a href="http://www.radiovlooienmarkt.nl/" target="_blank">electronic flea market</a> I bought two 50cm 12V (700ma) ledbars. They were quite bright and only cost 6 euro a piece. I still needed a proper lighting solution for my work bench and thought these could perfectly serve that purpose.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
With some two components conductive glue I glued them on a aluminum strip for thermal conductivity. A wooden frame prevents to look right into the leds when you enter the room. It definitely gives a nice bright even illuminated work bench.</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbQXvGtbEDeYB5MmOVsW_yEfMLERLNtyx0dvuXISoF0Q_XWa3TqH_oRbD3W47CmlzePPEuMAXHnvjESdM9HJidb48YylzfOIZnmIDVCfNPB58Gr0siPFLsKyBZhvo5yZzcQ8Bs2c6FBwXi/s1600/ledbar_collage.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbQXvGtbEDeYB5MmOVsW_yEfMLERLNtyx0dvuXISoF0Q_XWa3TqH_oRbD3W47CmlzePPEuMAXHnvjESdM9HJidb48YylzfOIZnmIDVCfNPB58Gr0siPFLsKyBZhvo5yZzcQ8Bs2c6FBwXi/s1600/ledbar_collage.JPG" height="400" width="400" /> </a></div>
<div class="separator" style="clear: both; text-align: justify;">
</div>
<div class="separator" style="clear: both; text-align: justify;">
I didn't want to use a switch to turn the lights on and off. It is just not cool! Recently I bought 10 PIR motion detection sensor modules (<a href="http://goo.gl/Bc8W4B" target="_blank">HC-SR501</a>) on ebay for only 10 euro (How can they even make that for one euro?). I thought one of these can do the job for me when I approach my bench.</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
The PIR sensor module outputs 3V3 when motion is detected. Sensitivity and ON time can be adjusted on the module. It operates on supply voltages between 4.5 and 20V so the 12V (1.5A) adapter I need to power the ledbars can also power the PIR sensor. I wanted to use an IRF540 NFET to switch the leds, but this NFET doesn't open up completely with a Vgs of 3V3 which limits the current flowing through the leds. That is why I used a smaller BS170 NFET that can be triggered with 3V3. R1 is a 10K resistor to prevent a floating gate signal. Due to another 10K resistor (R2) at the drain of the BS170 an inverted signal of the PIR sensor is available, so a PFET (IRF9540) can invert back that signal to switch on the ledbars. For troubleshooting purposes I added a jumper to put 12V directly on the ledbars and a test led (always add a test led!) to see the circuit works properly even if the ledbars are not connected.</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihZ1SgcoByDCJs_Cuqxct0AlBcTdDSgd8F8C1zqXQmLBPz0jXx3finGyzzoZ_kF0ElYznv5HQRRCatj4AOmdslddJs6BsvvsjqA2sPC-R40_LCoakOMgPrZvkbRyz4ApTCp1p67fZOj1Vg/s1600/schematics.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihZ1SgcoByDCJs_Cuqxct0AlBcTdDSgd8F8C1zqXQmLBPz0jXx3finGyzzoZ_kF0ElYznv5HQRRCatj4AOmdslddJs6BsvvsjqA2sPC-R40_LCoakOMgPrZvkbRyz4ApTCp1p67fZOj1Vg/s1600/schematics.JPG" height="300" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
I stuffed everything into a small plastic storage box that I found in
the kitchen and made it possible to rotate the whole box to be able to
point the PIR sensor towards the workbench. It turned out to be a very
nice local lighting solution. I doesn't turn on when I enter the room or
walk around, only when I enter the work bench it turns on. Altogether it didn't cost me more then 15 euros, I don't believe you can buy something like this for so little money.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvgoNAH8FiruPQXcLVNI-jd7typQH2Wy86414C_mt1EidjtOr4Vii4O-pGnnjg52EBBS0cIufftKZPI0NSdbWg386wwYltAntt7O4Iw-dPsxcfVj8lpkzx8Z_zQUwyZZ6mypTo8S6_Tulu/s1600/motiondetector_collage02.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvgoNAH8FiruPQXcLVNI-jd7typQH2Wy86414C_mt1EidjtOr4Vii4O-pGnnjg52EBBS0cIufftKZPI0NSdbWg386wwYltAntt7O4Iw-dPsxcfVj8lpkzx8Z_zQUwyZZ6mypTo8S6_Tulu/s1600/motiondetector_collage02.JPG" height="400" width="400" /></a></div>
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
Deddies Labhttp://www.blogger.com/profile/16480149250377086609noreply@blogger.com1tag:blogger.com,1999:blog-9130726849248851041.post-53327330752729451732012-01-08T21:07:00.000+01:002012-01-08T21:07:02.487+01:00Mystery LED in a box: part 7My friends were so pleased with my sewing craftmanship that they decided to releave us from our duty. No more morse code, no more assignments...<br />
<br />
One day we blinked with our eyes and we found our selfmade wallet filled with a decent amount of dough. Our assigment was fullfilled! <br />
<br />
<div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjF4DESGF3P3aADV3qtuxLqDvvGV8ZGpdqRG-vxyQq0oNfIT76zRb1T9KfakTacjOnOGcHHxTDsvom1WrFXtE47Soe17KfYRRHl3ZxnN8C7iILEpJk0-_hwHUeJUO14Qr_jtYiP-dgxzmeL/s1600/P1080989.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjF4DESGF3P3aADV3qtuxLqDvvGV8ZGpdqRG-vxyQq0oNfIT76zRb1T9KfakTacjOnOGcHHxTDsvom1WrFXtE47Soe17KfYRRHl3ZxnN8C7iILEpJk0-_hwHUeJUO14Qr_jtYiP-dgxzmeL/s320/P1080989.JPG" width="320" /></a></div><br />
A little trip down memory lane:<br />
<br />
<a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-0.html">Mystery LED in a box: part 0</a>: The suprise!<br />
<a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-1.html">Mystery LED in a box: part 1</a>: <span class="short_text" id="result_box" lang="en"><span class="hps">Reconnaissance mission</span></span><br />
<a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-2.html">Mystery LED in a box: part 2</a>: Tin soldier<br />
<a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-3.html">Mystery LED in a box: part 3</a>: Epromising website<br />
<a href="http://deddieslab.blogspot.com/2011/08/mystery-led-in-box-part-4.html" target="">Mystery LED in a box: part 4</a>: Chat me up, baby<br />
<a href="http://deddieslab.blogspot.com/2011/11/mystery-led-in-box-part-5.html" target="_blank">Mystery LED in a box: part 5</a>: d2hhdCB0aGUgZnVjaw==<br />
<a href="http://deddieslab.blogspot.com/2011/12/mystery-led-in-box-part-6.html" target="_blank">Mystery LED in a box: part 6</a>: So sew me...<br />
<br />
Thanks, buddies.... who's next by the way?<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5LgVOeWxthVmA1GMb3M4dztR6Bmwj62FDMbB4GBuKswulFFFAA3PdWM29xnDtVqbyRV-Jpa75WZ2mlX-nncUzCNP8kVJyBPiKk0wneSadI04DJ6hh6GAUOTkS_pqFY_Izch6hRKWYTEch/s1600/P1080997.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5LgVOeWxthVmA1GMb3M4dztR6Bmwj62FDMbB4GBuKswulFFFAA3PdWM29xnDtVqbyRV-Jpa75WZ2mlX-nncUzCNP8kVJyBPiKk0wneSadI04DJ6hh6GAUOTkS_pqFY_Izch6hRKWYTEch/s320/P1080997.JPG" width="320" /></a></div>Deddies Labhttp://www.blogger.com/profile/16480149250377086609noreply@blogger.com1tag:blogger.com,1999:blog-9130726849248851041.post-17681142259356299792011-12-18T22:38:00.006+01:002012-01-08T21:12:58.633+01:00Mystery LED in a box: part 6see also: <a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-0.html">Mystery LED in a box: part 0</a><br />
see also: <a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-1.html">Mystery LED in a box: part 1 </a><br />
see also: <a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-2.html">Mystery LED in a box: part 2 </a><br />
see also: <a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-3.html">Mystery LED in a box: part 3</a><br />
see also: <a href="http://deddieslab.blogspot.com/2011/08/mystery-led-in-box-part-4.html" target="">Mystery LED in a box: part 4</a><br />
see also: <a href="http://deddieslab.blogspot.com/2011/11/mystery-led-in-box-part-5.html" target="_blank">Mystery LED in a box: part 5</a><br />
<br />
How do you <span style="font-size: small;">respond </span>to a sentence like the following:<br />
<br />
<div style="text-align: center;"><span style="font-size: small;">U'2F'UBMU'SI'G'5HY'W'KGZ'W'V'UI'H'B'VCNR'LBW'9UBMV'LI'G'1LDC'B'QDW'XSAW'U'</span></div><div style="text-align: center;"><span style="font-size: small;">GBMF'TZ'W'4GZ'W'4GDH'J'VDX'DKY'X'R'1BS'4GQ'MV'3AW'PZI'H'Z'PY'S'B'IBG'9NL'I4UT</span><br />
<br />
<br />
</div><div style="text-align: justify;"><span style="font-size: x-small;"><span style="font-size: small;">Anyone? Nobody? ANYthing? The <a href="http://deddieslab.blogspot.com/2011/11/mystery-led-in-box-part-5.html" target="_blank">last clue</a> kept us busy for a few weeks. </span></span></div><div style="text-align: justify;"></div><div style="text-align: justify;"><span style="font-size: x-small;"><span style="font-size: small;">Shortly after presenting the world our latest progress we found a rather scary letter in our mailbox:</span></span><br />
<span style="font-size: x-small;"><span style="font-size: small;"> </span></span></div><div style="text-align: justify;"></div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7iXTKW8HReD0PvNDAS4mFAFIAAQxMkP36wf5esUCIxJwBw-RcHrUbtwUEK2mmoMd6zAwsQSsRiuLISFO2sbZiYKX8rGyBDPocWIbZeBN1nivH6wA0S1Te1zs2s1dMge-YjQ8MAkIroB2W/s1600/P1080960.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7iXTKW8HReD0PvNDAS4mFAFIAAQxMkP36wf5esUCIxJwBw-RcHrUbtwUEK2mmoMd6zAwsQSsRiuLISFO2sbZiYKX8rGyBDPocWIbZeBN1nivH6wA0S1Te1zs2s1dMge-YjQ8MAkIroB2W/s320/P1080960.JPG" width="320" /></a></div><div style="text-align: justify;"><br />
<span style="font-size: x-small;"><span style="font-size: small;">"All your base are belong to us". Not only one of the most famous<a href="http://en.wikipedia.org/wiki/All_your_base_are_belong_to_us" target="_blank"> internet memes</a> ever but as from now also a big hint to solve our mysterious sentence that should lead us to our wedding gift. Googling it didn't result in a lot of usefull stuff other then a huge amount of odes and also parodies to the subject. After a week of puzzling, googling and trying to tear some usefull information from my friends a little birdy (Thank you!) remerbered my of a mental note that I took during<a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-2.html" target="_blank"> part 2</a> of the queste. The clue of part 2 ended with the number 64</span></span><span style="font-size: x-small;"><span style="font-size: small;"> ("</span></span>VIERENZESTIG")<span style="font-size: x-small;"><span style="font-size: small;">, which was not intended for that assignment. It seemed a bit lost standing there, but I kept it in mind. Maybe it is usefull here.</span></span></div><div style="text-align: justify;"></div><div style="text-align: justify;"><span style="font-size: x-small;"><span style="font-size: small;">Adding '64' to the Google search string 'All your base are belong to us' didn't actually give me something new (except some way too nerdy Microsoft stuff). But hurray, my luck changed when I shortened the string to 'All your base 64'. It showed me various leads to the term 'Base64'. <a href="http://en.wikipedia.org/wiki/Base64" target="_blank">Base64 </a>is an encoding/decoding method that uses a base of 64 characters to encode 8 bit ASCII data. It has various applications and it makes a normal sentence look like it is heavily encrypted. For that it is also used to obfuscate passwords. The Wikipedia site showed with a small example how to decode Base64 encoded data, and manually decoding the first part showed my the first letters of my own name, so I knew I was going the right way. Base64 is not very difficult to encode/decode so there has to be somebody that already made a script for the world wide web. <a href="http://www.motobit.com/util/base64-decoder-encoder.asp" target="_blank">Lucky me!</a></span></span></div><div style="text-align: justify;"></div><div style="text-align: justify;"><span style="font-size: x-small;"><span style="font-size: small;">There was only one thing. Base64 encoding makes a distinction between small and capital letters while Morse code doesn't make this distinction. That was an easy one. It immediately explained the apostrophe ( ' ) characters in the mysterious sentence. A letter followed by an apostrophe means a capital letter, otherwise it is used as a small letter.</span></span><br />
<br />
</div><div style="text-align: justify;"></div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhahB8T2kXhxDKpZqW6LAaI41cOS6p_A5FVCsRlnGW6fh7yWlqhJM59dWiHgPoJUoD45Tj2RQnk1sgd37lUrfLuOi39dmXcCMwsOpTYfOQHIW3i25VtZYPaHMngYkTcD3U6gkErERyDdonJ/s1600/naai.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhahB8T2kXhxDKpZqW6LAaI41cOS6p_A5FVCsRlnGW6fh7yWlqhJM59dWiHgPoJUoD45Tj2RQnk1sgd37lUrfLuOi39dmXcCMwsOpTYfOQHIW3i25VtZYPaHMngYkTcD3U6gkErERyDdonJ/s320/naai.jpg" width="290" /></a></div><div style="text-align: justify;"></div><div style="text-align: center;"><br />
<span style="font-size: x-small;"><span style="font-size: small;">"SANNE, NAAI EEN PORTEMONNEE MET JULLIE </span></span></div><div style="text-align: center;"><span style="font-size: x-small;"><span style="font-size: small;">NAMEN EN TROUWDATUM. BEWIJS VIA BLOG..." </span></span><br />
<br />
</div><div style="text-align: center;"></div><div style="text-align: center;"><span style="font-size: x-small;"><span style="font-size: small;">(Sanne (That's my nickname), sew a wallet with your names </span></span></div><div style="text-align: center;"><span style="font-size: x-small;"><span style="font-size: small;">and wedding date. Show the proof via the blog...) </span></span><br />
<br />
</div><div style="text-align: center;"></div><div style="text-align: justify;"><span style="font-size: x-small;"><span style="font-size: small;">The assignment is a wink to my wife's hobby: <a href="http://mamaslap.blogspot.com/" target="_blank">Sewing </a>and other sorts of crafting. In <a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-2.html" target="_blank">part 2</a> she had to do some soldering on the mystery box, so now it was my turn. And here is the result... And yes, it is geeky and nerdy!</span></span><br />
<br />
</div><div style="text-align: justify;"></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfxmLIiP19LbIMyK2l_gw8y1zwsm2mDiI2tO2Qy29neYPM7WlMmmwLmv8TSVWrM6B-P5pcyLTVHuSgHPUe5trlxxE4l_HWlMzyrPuWTi3e6czAssP9yRLS8Go6nRdyWMgA8ikld_KtVjda/s1600/pictures.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfxmLIiP19LbIMyK2l_gw8y1zwsm2mDiI2tO2Qy29neYPM7WlMmmwLmv8TSVWrM6B-P5pcyLTVHuSgHPUe5trlxxE4l_HWlMzyrPuWTi3e6czAssP9yRLS8Go6nRdyWMgA8ikld_KtVjda/s400/pictures.jpg" width="400" /></a><span style="font-size: x-small;"><span style="font-size: small;"> </span></span></div><div style="text-align: justify;"></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg52eghrKhMkSJ8FC4des87MjodkpBdqjPE_iRTtnS2tk7X_p-1K2iSu9mP6O75YL7BCnYiFtaBC6ptsAU_p128IGJ-i93lpXg6dt83tIwAev4QvGKr5RrmJ8sEkUtbXHVfY2ePSyqulu5U/s1600/P1080957.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg52eghrKhMkSJ8FC4des87MjodkpBdqjPE_iRTtnS2tk7X_p-1K2iSu9mP6O75YL7BCnYiFtaBC6ptsAU_p128IGJ-i93lpXg6dt83tIwAev4QvGKr5RrmJ8sEkUtbXHVfY2ePSyqulu5U/s320/P1080957.JPG" width="320" /></a></div><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibvp3iYXOBRHIFKjhui2CJkjRD37og8pe_M2O3IWnHW-iHu6Lw6laZBVs1iIAgMhfAQ9tT5nY8lVTeh2Pro_G49kh3XZqcul8NckhlYpPxOmMhjSQLO-c2RpYGKO7hUWJIVMfqubKAdo6K/s1600/P1080946.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><br />
</a><object class="BLOGGER-youtube-video" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" data-thumbnail-src="http://i.ytimg.com/vi/8rfzf0L9A_s/0.jpg" height="266" width="320"><param name="movie" value="http://www.youtube.com/v/8rfzf0L9A_s?version=3&f=user_uploads&c=google-webdrive-0&app=youtube_gdata" /><param name="bgcolor" value="#FFFFFF" /><embed width="320" height="266" src="http://www.youtube.com/v/8rfzf0L9A_s?version=3&f=user_uploads&c=google-webdrive-0&app=youtube_gdata" type="application/x-shockwave-flash"></embed></object></div><div style="text-align: justify;"></div><div style="text-align: center;"><br />
<span style="font-size: x-small;"><span style="font-size: small;">What's next? </span></span><br />
<br />
<div style="text-align: left;">see also: <a href="http://deddieslab.blogspot.com/2012/01/mystery-led-in-box-part-7.html" target="_blank">Mystery LED in a box: part 7</a><span style="font-size: x-small;"><span style="font-size: small;"> </span></span><span style="font-size: x-small;"><span style="font-size: small;"> </span></span></div></div>Deddies Labhttp://www.blogger.com/profile/16480149250377086609noreply@blogger.com0tag:blogger.com,1999:blog-9130726849248851041.post-85263886209325115742011-11-26T15:27:00.004+01:002012-01-08T21:12:31.542+01:00Mystery LED in a box: part 5<div style="text-align: justify;">see also: <a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-0.html">Mystery LED in a box: part 0</a><br />
see also: <a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-1.html">Mystery LED in a box: part 1 </a><br />
see also: <a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-2.html">Mystery LED in a box: part 2 </a><br />
see also: <a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-3.html">Mystery LED in a box: part 3</a><br />
see also: <a href="http://deddieslab.blogspot.com/2011/08/mystery-led-in-box-part-4.html" target="">Mystery LED in a box: part 4</a><br />
<br />
I promised in the <a href="http://deddieslab.blogspot.com/2011/08/mystery-led-in-box-part-4.html">previous item</a> to provide an update after my vacation. That was in August! Unfortunately my vacation doesn't take more then 3 months (I wish!). </div><div style="text-align: justify;"><br />
</div><div style="text-align: justify;">It took me quite some time to make the mystery box actually listen to me. I was able to tell it stuff with the <a href="http://deddieslab.blogspot.com/2011/08/mystery-led-in-box-part-4.html">IR transmitter that I had to build</a>, but it looked pretty deaf. The last hint I got was a little assigment to tell the box 'something':</div><br />
<div style="text-align: center;">"JIPPIE NU KAN IK OOK LUISTEREN. ZEG EENS IETS..."</div><div style="text-align: center;"><br />
</div><div style="text-align: justify;"> I figured out that this 'something' had to be the word 'IETS', which is the dutch word for 'something'. 'IETS' has also the advantage to be fairly easy in morse code. Three dots, one dash and again three dots is all it takes (** *- ***).</div><div style="text-align: justify;"><br />
</div><div style="text-align: justify;">Just two weeks ago I found out why me and the box were not on the same level. I made a little mistake with one of the resistors.... <a href="http://www.google.nl/search?q=resistor+color&hl=nl&client=firefox-a&hs=g2e&rls=org.mozilla:nl:official&prmd=imvns&tbm=isch&tbo=u&source=univ&sa=X&ei=6vjQTvvGI8TqOdOwxI4P&ved=0CDoQsAQ&biw=1280&bih=915" target="_blank">3K3 IS NOT THE SAME AS 33K, IDIOT!</a></div><div style="text-align: justify;">The 2K and 3K3 resistors serve as a voltage reference for the incoming photo transistor signal, and using a 33K resistor resulted in a 4.7V reference instead of the intended 3V.</div><div style="text-align: justify;"><br />
</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzdBWIp2VbBNnw7rD2N5NdhV160oHYq6hOP-yu90qPMJ0wb7-prsgA3ev5E6uoFczU-V2CbC-hiHWqNdZGxfiksF7oB0tIo65zXU06Hp1ww_hE5r_tS0PUwujVegO9ZZBAL4L-K_Xgsj4G/s1600/circuit2.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="158" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzdBWIp2VbBNnw7rD2N5NdhV160oHYq6hOP-yu90qPMJ0wb7-prsgA3ev5E6uoFczU-V2CbC-hiHWqNdZGxfiksF7oB0tIo65zXU06Hp1ww_hE5r_tS0PUwujVegO9ZZBAL4L-K_Xgsj4G/s320/circuit2.JPG" width="320" /></a></div><div class="separator" style="clear: both; text-align: center;"> </div><div style="text-align: justify;"><br />
</div><div style="text-align: justify;">Having that fixed the box and I renewed our vows and we were finally on speaking terms again. Telling 'IETS' to it with IR remote control waked it up and gave me a new sequence of morse pulses. I quickly hooked up my datalogger to log the sequence and let Matlab crunch the data:</div><div style="text-align: justify;"><br />
</div><div style="text-align: justify;"></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdFtH2X09mozlDtL-S3Y32pTpJ3-FpNskM1fPp7EfBO6JHr-RfMHAP-krcZKaVmaOGYH9alLLotJu8VKDNkJSfWM8FYkOHWEn68en94uaV5U-Z-6_gnFgkyGicRxdblZ_eiG3JiUR11BVf/s1600/matlab_vrienden.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdFtH2X09mozlDtL-S3Y32pTpJ3-FpNskM1fPp7EfBO6JHr-RfMHAP-krcZKaVmaOGYH9alLLotJu8VKDNkJSfWM8FYkOHWEn68en94uaV5U-Z-6_gnFgkyGicRxdblZ_eiG3JiUR11BVf/s320/matlab_vrienden.jpg" width="320" /> </a></div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div style="text-align: justify;"></div><div style="text-align: center;">"WIE ZIJN JE BESTE VRIENDEN? (IN ALFABETISCHE VOLGORDE)"</div><div style="text-align: center;"><br />
<i>Translated: "Who are your best friends? (in alphabetical order)"</i></div><div style="text-align: justify;"><br />
</div><div style="text-align: justify;">Damn, that looks like a tricky question. This really could cost (or gain) me friends... I took the safe road and picked the names of the people that actually contributed to the wedding present. <br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpG5IeQJC4g7vpw40NZvfhyPXEq8GuhVt4P-W0DIfOVSRXzOtpdl4zC8Y2w8MW3UXwZWSIDNX-3OGAS72Ha1vwEjFxL6jiKQuvC_tcHYStS5wou30XGAlhISsvcDKIaA2J8kD2KcyB2k1t/s1600/P1080859.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpG5IeQJC4g7vpw40NZvfhyPXEq8GuhVt4P-W0DIfOVSRXzOtpdl4zC8Y2w8MW3UXwZWSIDNX-3OGAS72Ha1vwEjFxL6jiKQuvC_tcHYStS5wou30XGAlhISsvcDKIaA2J8kD2KcyB2k1t/s320/P1080859.JPG" width="320" /></a></div><br />
</div><div style="text-align: justify;">But some use their real name and others jotted down their nickname in the card. Some of the guys have actually nicknames that are used so often, their real names are already long forgotten (Bart? And who's Frank?). So multiple options here:<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNk3GTbrGuTBMJyxha32lnArNIhMlmA0_ajlNSax0xP9UO0ns1rfB5g8GezsQw1iY9bi8gNd4Ye5VAa8h_sRkTcu5TViSBPIyHtHW8ynxiHc308g8XemURRdmxAnGtAOAh_4YADTyuEx5q/s1600/codevision_namen.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="128" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNk3GTbrGuTBMJyxha32lnArNIhMlmA0_ajlNSax0xP9UO0ns1rfB5g8GezsQw1iY9bi8gNd4Ye5VAa8h_sRkTcu5TViSBPIyHtHW8ynxiHc308g8XemURRdmxAnGtAOAh_4YADTyuEx5q/s320/codevision_namen.JPG" width="320" /></a></div><br />
Regardless the right answer it promised to be a challenge to send this huge morse code sequence manually, although I realized that is exactly what they did back in the days in WW2. But then they didn't had microcontrollers like we have now so I followed Deddies Labs slogan ("Because anything deserves a microcontroller") and start putting together a morse code generator.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2CH97Ef_IrtuaWkXTQwP6bQ-R6Krw0M2QjwDQG0nkgQwUWR5__BHGZVz2jzEjA_Ch1lH4Z4ZfpCzBYchUSH6WnYNrp8AH5702xpuNyzHuyh5sJ9m4-AJDF_tbVyrOi4qaAEeJRroDKGau/s1600/P1080860.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2CH97Ef_IrtuaWkXTQwP6bQ-R6Krw0M2QjwDQG0nkgQwUWR5__BHGZVz2jzEjA_Ch1lH4Z4ZfpCzBYchUSH6WnYNrp8AH5702xpuNyzHuyh5sJ9m4-AJDF_tbVyrOi4qaAEeJRroDKGau/s320/P1080860.JPG" width="320" /></a></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhf-TdeELMSNHUvpC_yUXEi1T4USQMMlMp5H2FT41LVbXQ5w58vhD7mkAs-s3UiqklCkWOir1POx9tZvTHxWNUBF9DwyDUVbSxzhsflViLZ3xl-V6B5l4PqyFEDHtEuAVkgpwyj0ZPRKByD/s1600/P1080858_detail.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="176" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhf-TdeELMSNHUvpC_yUXEi1T4USQMMlMp5H2FT41LVbXQ5w58vhD7mkAs-s3UiqklCkWOir1POx9tZvTHxWNUBF9DwyDUVbSxzhsflViLZ3xl-V6B5l4PqyFEDHtEuAVkgpwyj0ZPRKByD/s320/P1080858_detail.jpg" width="320" /> </a></div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/FfQ2OL8GAEo?feature=player_embedded' frameborder='0'></iframe></div><br />
That worked! A little bird had told me in the meantime what the most likely answer was to the friends question, and finally the mystery box gave me the next morse sequence. Again twice as fast as the previous clue which was also double as fast as the one before that.... <br />
Inevitably the datalogger needed some more tuning since the <a href="http://deddieslab.blogspot.com/2011/08/mystery-led-in-box-part-4.html">last upgrade which boosted up the sampling frequency to a whopping 40Hz (!!!)</a> proved not to be fast enough (C'mon guys, cut me some slack here). I actually compressed the data before storing it to the USB stick and decompressed it with Matlab (I will explain this later on in a different topic). It is now so freakin' fast that I myself don't even now how fast it is. I probably can expect some phonecalls from the <a href="http://en.wikipedia.org/wiki/Speed_of_light" target="_blank">CERN</a>...<br />
<br />
This clue is probably also the last clue the mystery box will give me, a running led sequence after the hint gives me the impression that its job is finished. I am shedding no tears, it is still electronics and it can't withstand salty water very well:<br />
<br />
<br />
<div style="text-align: center;"><span style="font-size: small;">U'2F'UBMU'SI'G'5HY'W'KGZ'W'V'</span><span style="font-size: small;">UI'H'B'VCNR'LBW'9UBMV'LI'G'</span><span style="font-size: small;">1LDC'B'QDW'XSAW'U'</span></div><div style="text-align: center;"><span style="font-size: small;">GBMF'TZ'W'</span><span style="font-size: small;">4GZ'W'4GDH'J'VDX'DKY'X'R'1BS'</span><span style="font-size: small;">4GQ'MV'3AW'PZI'H'Z'PY'S'B'IBG'</span><span style="font-size: small;">9NL'I4UT</span></div><br />
<br />
<div class="separator" style="clear: both; text-align: center;"></div>What the hell? Is this my final hint? This is not human readable. No easy "Congratulations, the present can be picked up at the trainstation in locker 1306"? Did I read the morse code right? Yes, I think I did! Did something went wrong with compressing the data or did Matlab had a bad day? Not likely.<br />
<br />
Chuckles of recognition of some of my friends gave me definitely the idea that I got the clue right. As you all can understand, more to follow...<br />
<br />
see also: <a href="http://deddieslab.blogspot.com/2011/12/mystery-led-in-box-part-6.html" target="_blank">Mystery LED in a box: part 6</a><br />
see also: <a href="http://deddieslab.blogspot.com/2012/01/mystery-led-in-box-part-7.html" target="_blank">Mystery LED in a box: part 7</a> </div>Deddies Labhttp://www.blogger.com/profile/16480149250377086609noreply@blogger.com0tag:blogger.com,1999:blog-9130726849248851041.post-18314699822658011502011-08-08T22:44:00.007+02:002012-01-08T21:12:16.566+01:00Mystery LED in a box: part 4see also: <a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-0.html">Mystery LED in a box: part 0</a><br />
see also: <a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-1.html">Mystery LED in a box: part 1 </a><br />
see also: <a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-2.html">Mystery LED in a box: part 2 </a><br />
see also: <a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-3.html">Mystery LED in a box: part 3</a><br />
<br />
Days passed by since we fulfilled <a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-3.html">our last assignment</a> considering the mystery LED box without any news. Did we do it right? Were we missing something? Last week the uncertainties suddenly vanished with a envelop that we found on our doormat.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSW0ViH3wFTJMtevcbCiq55bmD5i4ghHu_OZGCbwR3J_PQCWQxrWe9cJaQdJl16IWmCYgeaZRsXFD6nC8zYj_LePx4AxZRHWCEWWi3-Qq8RAB07NeYid9BIjhqjsXBjFZJ2CdYaB5rKsZP/s1600/P1080179.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSW0ViH3wFTJMtevcbCiq55bmD5i4ghHu_OZGCbwR3J_PQCWQxrWe9cJaQdJl16IWmCYgeaZRsXFD6nC8zYj_LePx4AxZRHWCEWWi3-Qq8RAB07NeYid9BIjhqjsXBjFZJ2CdYaB5rKsZP/s320/P1080179.JPG" width="320" /></a></div><br />
In the envelop we found some interesting parts: a micro switch, an IR led, and a BP103 phototransistor. I rushed to the website we found in the previous clue and there we found a new briefing. The 'Grande Finale' was about to take of...<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbMs4Wx7MeqwnZtL44VdAeyWifqsmWXhVohOmtYjvQvdIUeOsaef7NhATkCncTwox8SRSMsVr-dduXuU4i8_0dulRYwYaxgh-Q_jFY6RL4L964aJ_pi79oVRHbFo4mA9g0pR7jiLIfxW-s/s1600/grandefinale.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="175" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbMs4Wx7MeqwnZtL44VdAeyWifqsmWXhVohOmtYjvQvdIUeOsaef7NhATkCncTwox8SRSMsVr-dduXuU4i8_0dulRYwYaxgh-Q_jFY6RL4L964aJ_pi79oVRHbFo4mA9g0pR7jiLIfxW-s/s320/grandefinale.jpg" width="320" /></a></div>Again I had to add stuff to the already pretty stuffed up board and upload a new hexfile to the Attiny. I was asked to build an simple IR transmitter and giving the Attiny the capability to receive IR signals. Instead of one led the board now needed three leds.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgku9t31w7Kx7lLXRYy7qHUnISYcMJZtEFk6e3Tia6zFrD4HxKdN9ZhL61ppx2ETO9pncfoHciocC4eJmCMdVX4gqeh-GaWQz2fAqPopeuZ_DWAx-5rg-p7Fr8XN0RRj_p3Gj6cAQ46RU02/s1600/circuit.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="197" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgku9t31w7Kx7lLXRYy7qHUnISYcMJZtEFk6e3Tia6zFrD4HxKdN9ZhL61ppx2ETO9pncfoHciocC4eJmCMdVX4gqeh-GaWQz2fAqPopeuZ_DWAx-5rg-p7Fr8XN0RRj_p3Gj6cAQ46RU02/s400/circuit.jpg" width="400" /></a></div><br />
The next evening I did my magic and a couple of hours later the mystery box was blinking again...<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2l9DYmY-tzfBooun1SoqQW7tuw4fyPGJGL5EuL2KH3UUlbFBEmbcSVHU8827Y20_v53DmhSPWCM2oWUasQmB0FghvQGz4WfFNDLgZGSYY5z7UYqylKCAh526sIXulA1LkMhmFgkyPFqxa/s1600/P1080419.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2l9DYmY-tzfBooun1SoqQW7tuw4fyPGJGL5EuL2KH3UUlbFBEmbcSVHU8827Y20_v53DmhSPWCM2oWUasQmB0FghvQGz4WfFNDLgZGSYY5z7UYqylKCAh526sIXulA1LkMhmFgkyPFqxa/s320/P1080419.JPG" width="320" /></a></div><br />
It started with a running light, followed by 1 minute of sequential blinking of the middle led, finished by the 3rd led turning on and off only once. Nothing after that, you could almost hear the Atmel sleeping :) In the video you can find the BP103 photo transistor in the box on the left.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/neRAIpwFArQ?feature=player_embedded' frameborder='0'></iframe></div><br />
Diligently I hooked up my ever so useful datalogger! Just before I started recording the new sequence like I did with the previous clues, my attention was caught by the middle led..... Damn! Rat bastards...... the sample rate of the led sequence was definitely faster then 4Hz this time and my datalogger is not capable of<a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-1.html"> recording any faster</a>. And reading the morse code with the naked eye is definitey out of question at those speeds. I knew I should have kept my mouth shut about this bug (or blog about it). Me and my big mouth!<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgb5qUvxR_t-J0ZH9GtWLstdlGvxPm0rzD0OSQj2kT55B0ZEEf1-jw8AoCleY2KoQrsYlFPNh2uZCNtXRnS-k7PfFQUdC_Im4tnWwYNUy0QWPNGx8JfmBPxR7VtYNTTL64AjHMtSIaDtCFB/s1600/P1070972.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="181" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgb5qUvxR_t-J0ZH9GtWLstdlGvxPm0rzD0OSQj2kT55B0ZEEf1-jw8AoCleY2KoQrsYlFPNh2uZCNtXRnS-k7PfFQUdC_Im4tnWwYNUy0QWPNGx8JfmBPxR7VtYNTTL64AjHMtSIaDtCFB/s320/P1070972.JPG" width="320" /></a></div><br />
My friends' goal was definitely to slow down the progress solving the mystery box, apparently I was going to fast for them. Now I had to (quick) fix the datalogger first. And we were about to leave for vacation in a couple of days, were I was forbidden to even think of electronics or dream of Atmels. I agreed with myself to speed up the datalogger and get at least the next clue out of the mystery box before packing my bags.<br />
<br />
From the datalogger's sourcecode I removed everything unnecessary that could slow down the recording. Wow, I did some realy awful programming two years ago. 4 hours and a lot of deleting and rewriting later I managed to get the datalogger to record with an astonishing speed of at least 40Hz. I didn't try to make it faster, a tenfold increase seemed fine by me. I figured my friends not to be that big of assholes... Luckily I was right. After recording and some minor changes to the Matlab script the next sentence popped up:<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtnfp0azHlGvCoNQm9kLPyyuZK1g60i4JMPFpX3mVsmjRVCoV5LTn-RDxVNY3iptipFNnMX2HncDQy6jQzeFgehC2olv9X3b3POm_HU3ZJ_nBPIOkSovf0_4tbmgJ856AxZwS5Aj_oybwt/s1600/matlab_jippie.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtnfp0azHlGvCoNQm9kLPyyuZK1g60i4JMPFpX3mVsmjRVCoV5LTn-RDxVNY3iptipFNnMX2HncDQy6jQzeFgehC2olv9X3b3POm_HU3ZJ_nBPIOkSovf0_4tbmgJ856AxZwS5Aj_oybwt/s400/matlab_jippie.jpg" width="400" /></a></div><br />
<div style="text-align: center;">"JIPPIE NU KAN IK OOK LUISTEREN. ZEG EENS IETS..."</div><br />
Like I already suspected with the IR led and phototransistor the box was now capable of also 'listening'. It 'asked' me to say 'something' to him/it. This 'something' I still have to find out. I really have to pack my suitcases now...<br />
<br />
As you probably already have noticed, a project like this kind of grows on you. Like my 1 year old son it finally starts to listen and I start to understand its babbling. I hope I won't mix up the two, and find myself poking a soldering iron in my son's eye while the mystery box is getting a bath.<br />
<br />
More after my vacation...<br />
<br />
see also: <a href="http://deddieslab.blogspot.com/2011/11/mystery-led-in-box-part-5.html">Mystery LED in a box: part 5 </a><br />
see also: <a href="http://deddieslab.blogspot.com/2011/12/mystery-led-in-box-part-6.html" target="_blank">Mystery LED in a box: part 6</a><br />
see also: <a href="http://deddieslab.blogspot.com/2012/01/mystery-led-in-box-part-7.html" target="_blank">Mystery LED in a box: part 7</a>Deddies Labhttp://www.blogger.com/profile/16480149250377086609noreply@blogger.com0tag:blogger.com,1999:blog-9130726849248851041.post-38270868978899873582011-07-16T22:58:00.005+02:002012-01-08T21:11:34.973+01:00Mystery LED in a box: part 3see also: <a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-0.html">Mystery LED in a box: part 0</a><br />
see also: <a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-1.html">Mystery LED in a box: part 1 </a><br />
see also: <a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-2.html">Mystery LED in a box: part 2 </a><br />
<br />
Still we don't have the contents of the <a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-0.html">wedding present</a> that was given to us on our wedding party. Along the way we found clues telling us to exentend the electronics board with a <a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-1.html">pushbutton </a>and most recently to fill all 128 bytes of the <a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-2.html">EEPROM </a>with the hex value '0x03'.<br />
<br />
To get to the EEPROM I added a 10 pins ISP header to the board to be able to connect it to my <a href="http://www.ic-board.de/product_info.php?info=p62_ICprog-AVR2-0-KANDA.html">programmer</a>. This gave me also the nice opportunity to read the fuse and lock bits to anticipate for any other surprises. Hmm, no surprises here (was I thinking too difficult again? Was I disappointed?), the fuse and lock bits were left alone and still had their default value. I also made a backup of the EEPROM and Flash memory to fix any possible screw-ups.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijQZUpnEzFxvJxbyQVEUwJQ2HA-dvNWej2lYNlGK09pYtFkImYiwqRtCDY0AWik1kxvrFGL0ZK3_9KZ3Yghs9br5M9VGn5vvl4jCkJM27FSDmidCc1mfVGIxLnXghx2ccEVamISyxmonCM/s1600/P1080083.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijQZUpnEzFxvJxbyQVEUwJQ2HA-dvNWej2lYNlGK09pYtFkImYiwqRtCDY0AWik1kxvrFGL0ZK3_9KZ3Yghs9br5M9VGn5vvl4jCkJM27FSDmidCc1mfVGIxLnXghx2ccEVamISyxmonCM/s320/P1080083.JPG" width="320" /></a></div><br />
I used Codevision to read the EEPROM and changed it as requested. Yeehaa, a new Morse sequence!<br />
<br />
"PROFICIAT MET JULLIE SKILZZ. CHECK HTTP://**.***.**.***/DEZONDEVOORBIJ/ OM DE VOLGENDE HINT TE VINDEN. MYMICROCONTROLLERCANBEATTHEHELLOUTOF..."<br />
<br />
(the '*' were actually filled in but are not really relevant here)<br />
<br />
After congratulating us with the achieved result so far we were presented a website for the next clue. Here the clue ended with a seemingly harmless reference to the <a href="http://deddieslab.blogspot.com/2011/01/microcontroller-from-hell.html">coolest bumper sticker ever</a> that hangs on the wall of Deddies Lab. Note taken!<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2ex-9rfd4ombdGvOH9IIYqAjHKpWJ3b4bFf4nKl2yQQ4z6ptZcuaaqX1NP6B8feEvXemojQECX7jl_todf6zUARlberSClBxdjqQ1OKSt1t30iw0RH-A0_VbBh1uqNhA9RrOBvhn1laYj/s1600/website.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="154" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2ex-9rfd4ombdGvOH9IIYqAjHKpWJ3b4bFf4nKl2yQQ4z6ptZcuaaqX1NP6B8feEvXemojQECX7jl_todf6zUARlberSClBxdjqQ1OKSt1t30iw0RH-A0_VbBh1uqNhA9RrOBvhn1laYj/s320/website.jpg" width="320" /></a></div><br />
So, a website. The tips&tricks section on the website gave us a link to the wikipedia site of morse code. We could have used that some time ago! Funny...<br />
<br />
We were told to make a picture of the mystery box with today's newspaper to prove that the cube was still intact. Okay, I maybe broke it a week ago... but it is fixed now. The picture below will lead us further on our quest as promised on the website.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGb9WT52WnTlfXTYy_mjl9Uqg9icKnyMAN4PL05y-4bD27QKEqDifTxJ53KDrA6j__H2Mhwc09xRUctO94x3ya17Lfla4Urh2r3zFdJHHgi5SMeQk7p2xyIVBX251fgyDp4lxmd3fEt3w6/s1600/broken_cube.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGb9WT52WnTlfXTYy_mjl9Uqg9icKnyMAN4PL05y-4bD27QKEqDifTxJ53KDrA6j__H2Mhwc09xRUctO94x3ya17Lfla4Urh2r3zFdJHHgi5SMeQk7p2xyIVBX251fgyDp4lxmd3fEt3w6/s320/broken_cube.jpg" width="240" /></a></div><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhoHOHEjdRuT_F9ofs_SwXITXTAI4wNFR8whrIzJoXYWsd6zj7_qUGhIpJLfVssRhJhGZX6lpchZ_AsHsOzGPFZiLn2Dkz2ag-D3Bh-hK2SQ-JJMYeP8yDh_hQAiCqB8JFuUXkr5nMt-zr4/s1600/P1080086.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhoHOHEjdRuT_F9ofs_SwXITXTAI4wNFR8whrIzJoXYWsd6zj7_qUGhIpJLfVssRhJhGZX6lpchZ_AsHsOzGPFZiLn2Dkz2ag-D3Bh-hK2SQ-JJMYeP8yDh_hQAiCqB8JFuUXkr5nMt-zr4/s320/P1080086.JPG" width="320" /></a></div><br />
It is obviously that somebody is watching our moves. I suppose we have to be carefull with what we say the weeks to come. Hang on...<br />
<br />
see also: <a href="http://deddieslab.blogspot.com/2011/08/mystery-led-in-box-part-4.html">Mystery LED in a box: part 4 </a><br />
see also: <a href="http://deddieslab.blogspot.com/2011/11/mystery-led-in-box-part-5.html">Mystery LED in a box: part 5 </a><br />
see also: <a href="http://deddieslab.blogspot.com/2011/12/mystery-led-in-box-part-6.html" target="_blank">Mystery LED in a box: part 6</a><br />
see also: <a href="http://deddieslab.blogspot.com/2012/01/mystery-led-in-box-part-7.html" target="_blank">Mystery LED in a box: part 7</a>Deddies Labhttp://www.blogger.com/profile/16480149250377086609noreply@blogger.com0tag:blogger.com,1999:blog-9130726849248851041.post-42375313318258059292011-07-16T21:59:00.005+02:002012-01-08T21:11:11.372+01:00Mystery LED in a box: part 2see also: <a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-0.html">Mystery LED in a box: part 0</a><br />
see also: <a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-1.html">Mystery LED in a box: part 1 </a><br />
<br />
Nothing more sexy then a beautiful woman with a 360 degrees celcius piece of metal in her hands. And I recently married her too. Lucky me!<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtKu45rfglzeq2ZCULRkI2ByKKiOn9rLT2mGgZ2E6d76O8STg9eLRbOneExnm-ijuyXrvzsYtuMk7amRpV2A8c39ys0wRZP7-nI0P9ALppmF0MdqJPE7nglEGKPSPdhMZifQDmL4Wa5_tc/s1600/P1080069.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtKu45rfglzeq2ZCULRkI2ByKKiOn9rLT2mGgZ2E6d76O8STg9eLRbOneExnm-ijuyXrvzsYtuMk7amRpV2A8c39ys0wRZP7-nI0P9ALppmF0MdqJPE7nglEGKPSPdhMZifQDmL4Wa5_tc/s320/P1080069.JPG" width="320" /></a></div><br />
In our continuing quest to find our <a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-0.html">wedding present</a> we (and with 'we' I mean Rianne) got the task to <a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-1.html">add a pushbutton</a> to the mystery box. This was easy, even for my soldering virgin.<br />
<br />
The pushbutton revealed a new sequence of Morse code. The Matlab script I wrote for the first clue proved itself robust enough to also give us the next clue:<br />
<br />
"ALLRIGHT. JULLIE DACHTEN TOCH NIET DAT DIT HET AL WAS HE? ZET HET EEPROM VOL MET 0X03 OM NAAR DE VOLGENDE RONDE TE GAAN. VIERENZESTIG"<br />
<br />
The next task is to fill the EEPROM of the Attiny with '0x03'. This would bring us to the next round. The sentence strangely ends with the number 64. I don't know if this means anything for now or later on but I will keep the number in mind.<br />
<br />
Stay tuned....<br />
<br />
see also: <a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-3.html">Mystery LED in a box: part 3 </a><br />
see also: <a href="http://deddieslab.blogspot.com/2011/08/mystery-led-in-box-part-4.html">Mystery LED in a box: part 4 </a><br />
see also: <a href="http://deddieslab.blogspot.com/2011/11/mystery-led-in-box-part-5.html">Mystery LED in a box: part 5 </a><br />
see also: <a href="http://deddieslab.blogspot.com/2011/12/mystery-led-in-box-part-6.html" target="_blank">Mystery LED in a box: part 6</a><br />
see also: <a href="http://deddieslab.blogspot.com/2012/01/mystery-led-in-box-part-7.html" target="_blank">Mystery LED in a box: part 7</a>Deddies Labhttp://www.blogger.com/profile/16480149250377086609noreply@blogger.com1tag:blogger.com,1999:blog-9130726849248851041.post-29937053376963676592011-07-11T23:38:00.006+02:002012-01-08T21:10:38.282+01:00Mystery LED in a box: part 1see also: <a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-0.html">Mystery LED in a box: part 0</a> <br />
<br />
So the puzzling started. After receiving the small transparent<a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-0.html"> mystery box</a> on our wedding party, already the next day I diligently started deciphering the led's ON/OFF sequence.<br />
<br />
As a leftover from a energy monitoring project (that I never finished) I still had a USB datalogger (build around the <a href="http://www.ftdichip.com/Support/Documents/DataSheets/Modules/DS_VDIP1.pdf">VDIP1 </a>module) which can log 4 channels of analogue values as a 10 bits value with a maximal sample rate of about 4Hz. It is unfortunately not faster (the software contains some bugs that I still have to fix), but for the mystery led it seemed appropriate. I plugged in an optical sensor (type unknown) to log when and how long the led is ON and OFF. Not knowing how long a unique data sequence was, I logged the optical sensor for 30 minutes.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAHSqACZOTLbELJyTWDKtj3PZF6iVpibM1ghb_Ue04lv_46KL9BNrabbImXukCZ1vdBuxduwqKY2Tuc4U9Eb7HdXH0gKh686K-M2u4hulruS5NtIC8G1SOPMdduezh5XXzkZDHoxcUBPgM/s1600/foto_datalogger.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAHSqACZOTLbELJyTWDKtj3PZF6iVpibM1ghb_Ue04lv_46KL9BNrabbImXukCZ1vdBuxduwqKY2Tuc4U9Eb7HdXH0gKh686K-M2u4hulruS5NtIC8G1SOPMdduezh5XXzkZDHoxcUBPgM/s320/foto_datalogger.jpg" width="320" /></a></div><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/RDQJm9sdXMQ?feature=player_embedded' frameborder='0'></iframe></div><br />
With the analogue values of the optical sensor stored in a CSV file, I can write some signal processing scripts to analyse the data. In a spreadsheet program the data showed up nicely. A high analogue value (around 700) means the led is ON, the lower values indicate the led is turned OFF. The total sequence was around 7500 samples long. Not a very pleasant job to decipher that by just looking at the led. I definitely needed some software aids for this.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRRrLAUuQNA09LMLCD4PcxVQDzSgvZ24Z4SByWsXakowREDjLAHy0sSNxDCWpfyy9qDDHC2L1YxbZk0vSy__lfQhyWMYIGziCWGW0Q6PUZDw288ObSRa5pDgPkMgqmMCzHj-Js88oWFIOB/s1600/DATA7_fs150ms_200x.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="126" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRRrLAUuQNA09LMLCD4PcxVQDzSgvZ24Z4SByWsXakowREDjLAHy0sSNxDCWpfyy9qDDHC2L1YxbZk0vSy__lfQhyWMYIGziCWGW0Q6PUZDw288ObSRa5pDgPkMgqmMCzHj-Js88oWFIOB/s400/DATA7_fs150ms_200x.jpg" width="400" /></a></div><br />
I have some experience with MATLAB, a widely used mathematical software environment. With MATLAB this shouldn't be difficult to decipher, I figured. A 'small' difficulty was that I had no clue what to look for. It can be a highly encrypted telephone number for which I needed a key, or a 800x600 black&white picture giving us a new clue or even a QR code leading us to a website. I stared at the data for a small week and played around with it viewing it from different angles. But nothing that looked useful.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdUuJXggRB_tHFIHEXdGN4_4KR8tkrqXJ_rEpKyGO6GlLV0-zc6ufKvvwV8_C5wJx7k4PBXlpF7lU3Ng7JowXQ1gj72ckBjpsp37ctWBjCqpjdQTV6_TevF0pf_Y0YejpByTSKeQO8JrQX/s1600/matlab_QR.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdUuJXggRB_tHFIHEXdGN4_4KR8tkrqXJ_rEpKyGO6GlLV0-zc6ufKvvwV8_C5wJx7k4PBXlpF7lU3Ng7JowXQ1gj72ckBjpsp37ctWBjCqpjdQTV6_TevF0pf_Y0YejpByTSKeQO8JrQX/s320/matlab_QR.png" width="320" /></a></div>To make sure I didn't miss any data, I watched the Attiny's led output on an oscilloscoop. Maybe a signal with a frequency higher then a visible sequence of 20Hz would show up. Some of my friends know their way pretty well in in the GHz working areas, so I was aware of some very high frequency clue. Luckily, the Attiny2313 has an internal clock of only 1MHz, and my 15MHz scoop showed no hidden suprise. The data that I had from the datalogger still looked as the only useful data.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrKVQiScmZywezKp_Us2U5ATHP_rEm9ewwO97Nmwc8myXNlc5kDrpcikUkYMxGrtg1E7wIorYfUghuLOUtPmmWMlwwm3fYX1bUrxhiUhdk3ch5cBDG0Pt9m8KO4ld9Hf5GnzYwM9-OEbf9/s1600/foto_scoop.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrKVQiScmZywezKp_Us2U5ATHP_rEm9ewwO97Nmwc8myXNlc5kDrpcikUkYMxGrtg1E7wIorYfUghuLOUtPmmWMlwwm3fYX1bUrxhiUhdk3ch5cBDG0Pt9m8KO4ld9Hf5GnzYwM9-OEbf9/s320/foto_scoop.jpg" width="240" /></a></div><br />
I definitely was thinking too difficult. It was time to get help from my wife (no offense, honey). Maybe she can look at it from a different (non-technical) perpective which I didn't see with my biassed technical view.<br />
Funny thing was that from the beginning I told everybody that a Morse-code would be out of the question, since this should be way to easy to solve for me and would be kind of an insult to me. I must say, I did look at this option, interpreting the '1' as a dash '-' and the '0' as a dot '.'. The spreadsheet sample from the picture above would then be deciphered as '----.-.-.-.'. But it didn't gave me information when a certain letter started or ended, so the data stream could mean a enormous amount of letter combinations. Very hard to go through all that options. I quickly put aside the Morse-code option.<br />
<br />
Eventually it was my brilliant wife that came up with the idea that not the '1''s are dashes and the '0''s are dots but that the lengths of the sequential '1''s were the way to go. So a long stream of '1''s means a dash and a short stream of '1''s means a dot. The length of the '0' streams would then indicate the ending and starting of letters and complete words. The beginning of the data is then deciphered as '-... . ... - .' which means 'BESTE', the dutch word for 'DEAR'.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgckFUaEpxrhdIO7KHHPMbRjI1MHR_3WVusKOzZXuIDTda-GeVGm8GfBq1qOjn3kkwxKCJnpNmlKCEUhbXQaCvprq1SRMpCVaNvpy0nLfkk4IhhDYUuR2vPxHXYyEFSNuLn1uhaf_Gpcd8K/s1600/matlab_data.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="54" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgckFUaEpxrhdIO7KHHPMbRjI1MHR_3WVusKOzZXuIDTda-GeVGm8GfBq1qOjn3kkwxKCJnpNmlKCEUhbXQaCvprq1SRMpCVaNvpy0nLfkk4IhhDYUuR2vPxHXYyEFSNuLn1uhaf_Gpcd8K/s320/matlab_data.png" width="320" /></a></div>Victory was ours! A few hours of additional MATLAB programming eventually gave us the information that we needed.<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzS0JYuD41bF9jZTsaU-GEkAtjeDZm-MoqsjlIFMGfIZRx-ZUGb9WkdRneJvCoh0qw0BEaSvcCoAD7zSr0xahu6FslKahDXTICLL82GOHCKVwmeC6ZOm2WJjxiHVbeKMsaTan9gwC1Sro2/s1600/matlab_commandline.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzS0JYuD41bF9jZTsaU-GEkAtjeDZm-MoqsjlIFMGfIZRx-ZUGb9WkdRneJvCoh0qw0BEaSvcCoAD7zSr0xahu6FslKahDXTICLL82GOHCKVwmeC6ZOm2WJjxiHVbeKMsaTan9gwC1Sro2/s400/matlab_commandline.png" width="400" /></a></div><br />
"BESTE SANNE EN RIANNE, GEFELICITEERD MET JULLIE HUWELIJK. OM DE VOLGENDE AANWIJZING TE VERKRIJGEN MOET RIANNE EEN DRUKKNOP NAAR AARDE AAN PIN7 SOLDEREN."<br />
<br />
The text basically says that my wife Rianne needs to solder a push button between ground and PIN7 on the Atmel.<br />
<br />
That is our first clue, we are going to search for the next one! More to follow....<br />
<br />
see also: <a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-2.html">Mystery LED in a box: part 2</a><br />
see also: <a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-3.html">Mystery LED in a box: part 3</a><br />
see also: <a href="http://deddieslab.blogspot.com/2011/08/mystery-led-in-box-part-4.html">Mystery LED in a box: part 4 </a><br />
see also: <a href="http://deddieslab.blogspot.com/2011/11/mystery-led-in-box-part-5.html">Mystery LED in a box: part 5 </a><br />
see also: <a href="http://deddieslab.blogspot.com/2011/12/mystery-led-in-box-part-6.html" target="_blank">Mystery LED in a box: part 6</a> <br />
see also: <a href="http://deddieslab.blogspot.com/2012/01/mystery-led-in-box-part-7.html" target="_blank">Mystery LED in a box: part 7</a> <br />
<a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-0.html"></a>Deddies Labhttp://www.blogger.com/profile/16480149250377086609noreply@blogger.com0tag:blogger.com,1999:blog-9130726849248851041.post-14421280029052854092011-07-10T21:45:00.006+02:002012-01-08T21:09:57.896+01:00Mystery LED in a box: part 0I could have expected it!<br />
<br />
Last year we build this <a href="http://deddieslab.blogspot.com/2010/09/for-friends-wedding-we-had-to-find-way.html">huge wooden dice</a> for a good friend's wedding stuffed with electronics to prevent the newlyweds from getting their hands on their present too quickly. Two weeks ago it was my turn to tie the knot and guess what: The same guys that stood by my side last year putting the dice together now stood right in front of me all together to give me and the misses an interesting transparant box with some electronic parts in it.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAgkyR6R11WTaF-P9UeFbi-UMQpmz6NKhtbfEoS-3Z498QgTe0YCmmdv_F_9jCc6h3VuWavQ1Z9aPO6Trh4eLHMGX0UKUjoDOO_sAPSWpMTgeyeTZ9Uh_PWVtnFG8pnA60zbWk3rk7eGPV/s1600/Collages.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAgkyR6R11WTaF-P9UeFbi-UMQpmz6NKhtbfEoS-3Z498QgTe0YCmmdv_F_9jCc6h3VuWavQ1Z9aPO6Trh4eLHMGX0UKUjoDOO_sAPSWpMTgeyeTZ9Uh_PWVtnFG8pnA60zbWk3rk7eGPV/s400/Collages.jpg" width="400" /></a></div><br />
<br />
Besides a lot of air the little box was filled with a 9V battery, some voltage regulation with an 7805, an ON/OFF switch, an Atmel's Attiny2313 and a single yellow 3mm led. Although the beers tasted good that evening it didn't take me too long to come up with the idea of flipping the switch. What could such a tiny Atmel do, not considering the fact that the battery could be half filled with explosives ending the party a bit sooner as expected? Luckily for us our friends indeed had only good intentions (so far), and the yellow led started blinking quite decently.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/TUtFdDAeb0w?feature=player_embedded' frameborder='0'></iframe></div><br />
That was it. No big speech afterwards, hints, tips or tricks. The music started playing again, everybody grabbed their beers and we stood their holding a little transparent box with a small blinking yellow led like it was our first born baby. Luckily at the end of the party we got a little hint. Despite the kind of nerdy content of the present we were told that Rianne (my wife) will play a big part in finding the solution...<br />
<br />
My (our) task is to figure out if this box leads us to any clues concerning our wedding gift. Supposing their is indeed a wedding gift besides this small box worth approximately 10 euros. <br />
<br />
More is following soon....<br />
<br />
see also: <a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-1.html">Mystery LED in a box: part 1</a><br />
see also: <a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-2.html">Mystery LED in a box: part 2</a><br />
see also: <a href="http://deddieslab.blogspot.com/2011/07/mystery-led-in-box-part-3.html">Mystery LED in a box: part 3</a><br />
see also: <a href="http://deddieslab.blogspot.com/2011/08/mystery-led-in-box-part-4.html">Mystery LED in a box: part 4 </a><br />
see also: <a href="http://deddieslab.blogspot.com/2011/11/mystery-led-in-box-part-5.html">Mystery LED in a box: part 5 </a><br />
see also: <a href="http://deddieslab.blogspot.com/2011/12/mystery-led-in-box-part-6.html" target="_blank">Mystery LED in a box: part 6</a><br />
see also: <a href="http://deddieslab.blogspot.com/2012/01/mystery-led-in-box-part-7.html" target="_blank">Mystery LED in a box: part 7</a>Deddies Labhttp://www.blogger.com/profile/16480149250377086609noreply@blogger.com1tag:blogger.com,1999:blog-9130726849248851041.post-47112137624722026712011-02-05T15:36:00.004+01:002011-02-05T21:35:11.654+01:00Electronic watering can<div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4N5kKXFpsGcxtSBM7rN8e4z9jAI8RDxwhERBZBUpykKg5GOd33zhACuhVBPfQG3n5i75J4oGsVwZm87szeL9r3mdHGfpPRJVqYIixzuztTbWcm6_DcGUoenTTXjRRj3S4H4lGOFs9K3kz/s1600/P1060450b_edit.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4N5kKXFpsGcxtSBM7rN8e4z9jAI8RDxwhERBZBUpykKg5GOd33zhACuhVBPfQG3n5i75J4oGsVwZm87szeL9r3mdHGfpPRJVqYIixzuztTbWcm6_DcGUoenTTXjRRj3S4H4lGOFs9K3kz/s320/P1060450b_edit.jpg" width="238" /></a></div><br />
<br />
<div style="text-align: justify;"> To get the necesarry carbon dioxide to oxygen conversion Deddies lab is accommodated with a young Ficus Lyrata. To not interrupt its attempt to become the biggest Ficus on earth it needs a weekly dosis of water. That combined with the lab's motto that everything deserves a microcontroller gave inspiration for a little project on a rainy sunday: An automated electronic watering can!</div><br />
<div class="separator" style="clear: both; text-align: center;"></div><div style="text-align: justify;"> No, it is not an R2D2 alike robot holding a watering can. Basically it is a 10 liter reservoir filled with water and a little pump that waters the plant once a week.</div><br />
<div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/x0YKamxX-mE?feature=player_embedded' frameborder='0'></iframe> </div><div class="separator" style="clear: both; text-align: justify;"> To count the days and make the device extremely low on power consumption it uses a simple (mechanical) wall outlet timer that turns on the electronics once a day for only 15 minutes.* In this 15 minutes the day counter is incremented and on the 7th day the pump starts pumping up the water. That is unless their is enough water in the tank (guarded by mr. Duck) and some other preconditions have been met. If mr. Duck notices the water level is getting low, he pulls the rope indicating that no pumping is allowed anymore unless the tank is filled again.</div><div class="separator" style="clear: both; text-align: justify;"><br />
</div><div class="separator" style="clear: both; text-align: justify;"><i>* I could have used a more modern timer that will only turn on the watering can once a week. But as it was still a sunday I made it a kind of scrapheap challenge and used parts I had lying around instead of buying a new timer the next day.</i></div><div class="separator" style="clear: both; text-align: justify;"><br />
</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNJDPlZNVZJ_vanjcLp9xqvYP3CSEtRfRqIzVTdIRGUqTJ6dck48W74kSCDE8zoBjp-JsZlyzc6cTDD8paJZMabrkwY6laszfLXCkAfARWLzfIfsNOnpjJTxud_cATMETjJWgqLv4NiMH-/s1600/collage.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNJDPlZNVZJ_vanjcLp9xqvYP3CSEtRfRqIzVTdIRGUqTJ6dck48W74kSCDE8zoBjp-JsZlyzc6cTDD8paJZMabrkwY6laszfLXCkAfARWLzfIfsNOnpjJTxud_cATMETjJWgqLv4NiMH-/s320/collage.jpg" width="320" /></a></div><div class="separator" style="clear: both; text-align: justify;"><br />
</div><div class="separator" style="clear: both; text-align: justify;">An Atmega8 is used running on its own internal 1 MHz clock. A pushbutton is available to set the day that is most convenient for watering. Besides the timer mode their is also the possibility to give the plant an extra shot of water with the single shot pushbutton. This button is also useful when adjusting the voltage regulator that determines how long the pumps needs to be turned on. The single shot mode can test the amount of water that is pumped up. With the Aux In feature a external trigger signal can start the pump. That is unless the Timer Mode is disabled with the jumper. There is also an additional Aux Out that turns high when the pump is activated. </div><div class="separator" style="clear: both; text-align: justify;">Especially the Aux In and Out features can become useful when this watering can is part of a larger home automated system. Maybe we get plenty of 'rainy sunday afternoons' for Deddies lab to roll out this home automation plan.</div><div class="separator" style="clear: both; text-align: justify;"><br />
</div><div class="separator" style="clear: both; text-align: justify;">When the hole thing was put together and ran the first tests I realized that an important feature was missing. Although mr. Duck indicates the water level is getting low and pumping is not allowed anymore there is still no (auditive/visual) signal to the outside world that the tank needs refilling. So, mr. Duck guards the pump but not the plant. So an addition to the electronics will be needed to fix this.</div><div class="separator" style="clear: both; text-align: justify;"><br />
</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhroT9nb7Ey6XbER2fMUX03ETKT9rUn6YxdssWBLf1bPoexqyrnaMjCWoySDcXukX5BK2Pzqte8xigA4NU2ZSup7v1fzTfCwJ5bH2MU_bw6ugfqQuzwS4YHWuhdi7hRVshS37qm5ef0Y_Bj/s1600/P1060455_edit.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="199" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhroT9nb7Ey6XbER2fMUX03ETKT9rUn6YxdssWBLf1bPoexqyrnaMjCWoySDcXukX5BK2Pzqte8xigA4NU2ZSup7v1fzTfCwJ5bH2MU_bw6ugfqQuzwS4YHWuhdi7hRVshS37qm5ef0Y_Bj/s320/P1060455_edit.jpg" width="320" /></a></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2Sy8ivuwfLtDqr5EGEs7FfkGod3jcBUoD2JK21StAepwtnA5eyTo7Ct0ihvqYf8tKjdw__doFltsfE0tbqI9yIhmmUBYqgrFcyqxJNMF9A2-UOLykVeHcYDW_LiNH4UfpuPxb1nna0KDx/s1600/P1060516.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="181" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2Sy8ivuwfLtDqr5EGEs7FfkGod3jcBUoD2JK21StAepwtnA5eyTo7Ct0ihvqYf8tKjdw__doFltsfE0tbqI9yIhmmUBYqgrFcyqxJNMF9A2-UOLykVeHcYDW_LiNH4UfpuPxb1nna0KDx/s320/P1060516.JPG" width="320" /></a></div><br />
<div class="separator" style="clear: both; text-align: justify;">My Ficus Lyrata needs approximately half a liter per week. With a water reservoir that can contain 10 liters and has a minimum water level of 2 I have to fill the tank every 4 months. Not bad with the water tap at the other side of the house.</div><div class="separator" style="clear: both; text-align: justify;"></div><div class="separator" style="clear: both; text-align: justify;"><br />
</div><div class="separator" style="clear: both; text-align: justify;">Schematics can be found below and C source code for Codevision AVR can also be <a href="http://yourplaceor.mine.nu/files/ewc01.c">downloaded</a>.</div><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3954IRT2RtnHxvP-eKa2Gzl4XiD7nTMeboaiGozE_71fFOhSnvFjtxMWE-A8q9n2SCi822rYLddNHlfB-78LhNph1H1KH2ZhaZteOhmph6apDzaFZEMI5bzO2XNR7nrepLQyHJtdWBB0d/s1600/P1060262b_edit.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="288" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3954IRT2RtnHxvP-eKa2Gzl4XiD7nTMeboaiGozE_71fFOhSnvFjtxMWE-A8q9n2SCi822rYLddNHlfB-78LhNph1H1KH2ZhaZteOhmph6apDzaFZEMI5bzO2XNR7nrepLQyHJtdWBB0d/s320/P1060262b_edit.jpg" width="320" /></a></div><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqvtWlwW7ZUHYYdW2uBqIiNn1sUtOkrrxiGX5U8Oc5wZ3xhM9u9uxmh1HUwFAx2tlJMK2gdFS0-QsvPzQh7r1IpeD1ctcnNWnIt0i7qd7_4ZBBSvrS4lEhX-chCTOJR3NotWjvpxFSDTDo/s1600/electric_watering_can_schematic.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="209" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqvtWlwW7ZUHYYdW2uBqIiNn1sUtOkrrxiGX5U8Oc5wZ3xhM9u9uxmh1HUwFAx2tlJMK2gdFS0-QsvPzQh7r1IpeD1ctcnNWnIt0i7qd7_4ZBBSvrS4lEhX-chCTOJR3NotWjvpxFSDTDo/s320/electric_watering_can_schematic.jpg" width="320" /></a></div><div class="separator" style="clear: both; text-align: justify;"></div>Deddies Labhttp://www.blogger.com/profile/16480149250377086609noreply@blogger.com3tag:blogger.com,1999:blog-9130726849248851041.post-10481481723141146732011-01-19T22:23:00.000+01:002011-01-19T22:23:23.577+01:00Microcontroller from hell<span style="font-family: Arial,Helvetica,sans-serif;">Isn't this the coolest bumper sticker ever? Okay, that is just a matter of opinion, but I think it is pretty awesome... And it is actually not on my bumper, but a wall decoration of Deddies lab for some time</span><span style="font-family: Arial,Helvetica,sans-serif;">.</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjewaPSKf792tZrCOoZBwQqfhuj7LBuSZDfTsPpZU-Sar6wxv2nVXUkVHfG7zSaVVtspMHi5EZENlkb74mipJHU_JT5rZXc6pJ8W6ZmEc3oGhERtaiefVg_uDiJHq22Kk5gj1W1af1OMt1n/s1600/P1060362_edit.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjewaPSKf792tZrCOoZBwQqfhuj7LBuSZDfTsPpZU-Sar6wxv2nVXUkVHfG7zSaVVtspMHi5EZENlkb74mipJHU_JT5rZXc6pJ8W6ZmEc3oGhERtaiefVg_uDiJHq22Kk5gj1W1af1OMt1n/s320/P1060362_edit.jpg" width="320" /></a></div>Deddies Labhttp://www.blogger.com/profile/16480149250377086609noreply@blogger.com0tag:blogger.com,1999:blog-9130726849248851041.post-3752561196113493072011-01-17T22:15:00.001+01:002011-01-17T22:18:14.041+01:00Auto powerdown<div class="separator" style="clear: both; font-family: Arial,Helvetica,sans-serif; text-align: justify;">A little detail from the <a href="http://deddieslab.blogspot.com/2011/01/secret-dicey.html">Secret d'Icey</a> project: I am actually not very familiar with Atmel's own power saving capabilities, so I made a little circuit with FET's. I set it up so that the Atmega328 cuts off its own power when there is no activity for 30 seconds.</div><div class="separator" style="clear: both; font-family: Arial,Helvetica,sans-serif; text-align: justify;"><br />
</div><div class="separator" style="clear: both; font-family: Arial,Helvetica,sans-serif; text-align: justify;"></div><div class="separator" style="clear: both; font-family: Arial,Helvetica,sans-serif; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkuJzNGgRlX36sQilPuBCCLEtaJ7Nbopm_g0BBT-1-s5lRtibfbi6S3MgB51Lew2DgS4vSOxw09TFEzpS_zm6FrLxPcdcW_kxfgw_g7x8wOfRp6btp2R9pHf6U9gdXZoxR6Jp2d4_Tcthyphenhyphen/s1600/schematic_auto_powerdown.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="290" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkuJzNGgRlX36sQilPuBCCLEtaJ7Nbopm_g0BBT-1-s5lRtibfbi6S3MgB51Lew2DgS4vSOxw09TFEzpS_zm6FrLxPcdcW_kxfgw_g7x8wOfRp6btp2R9pHf6U9gdXZoxR6Jp2d4_Tcthyphenhyphen/s320/schematic_auto_powerdown.jpg" width="320" /></a></div><div class="separator" style="clear: both; font-family: Arial,Helvetica,sans-serif; text-align: justify;"><br />
</div><div style="font-family: Arial,Helvetica,sans-serif; text-align: justify;">Default the gate of the P-FET (IRF9530) is pulled up to V+, which is connected to the batteries. This turns off the P-FET and Vs stays 0V. The pulse switch S2 connects the gate to ground and lets the P-FET conduct so Vs become equal to V+. This will power up the circuit that also contains the Atmega328. When the Atmega is turned on the output B2 (pin 5) turns high. This makes also the N-FET IRF540 conduct and makes sure the gate of the P-FET keeps grounded. This takes over the role of the pulse switch.</div><div style="font-family: Arial,Helvetica,sans-serif; text-align: justify;"><br />
</div><div style="font-family: Arial,Helvetica,sans-serif; text-align: justify;">When there is no change in the dice state for 30 seconds the output B2 becomes low, which turns off the N-FET and the gate of the P-FET is again pulled up high to V+. Now the circuit (Vs) is cut off from the batteries.</div><div style="font-family: Arial,Helvetica,sans-serif; text-align: justify;"><br />
</div><div style="font-family: Arial,Helvetica,sans-serif; text-align: justify;"><i>(The IRF540 and IRF9530 are maybe a bit overkill (with a maximum drain current of 22 respectively 12A) but these I had lying around.)</i></div><div style="font-family: Arial,Helvetica,sans-serif; text-align: justify;"><br />
I tend to learn how to use Atmel's power saving functions in the near future, but until then this hardware solution will serve its purpose nicely and maybe it can be useful for other applications.</div>Deddies Labhttp://www.blogger.com/profile/16480149250377086609noreply@blogger.com0tag:blogger.com,1999:blog-9130726849248851041.post-74608368721833827682010-12-01T21:00:00.008+01:002014-05-11T13:36:12.499+02:00Secret d'Icey<div style="font-family: Arial,Helvetica,sans-serif;">
After building the <a href="http://deddieslab.blogspot.com/2010/09/for-friends-wedding-we-had-to-find-way.html">first version</a> of the secret dice in Deddies lab, it was time for an upgrade; Secret d'Icey!</div>
<div style="font-family: Arial,Helvetica,sans-serif;">
Secret d'Icey has the same functionality as its bigger brother, but has some interesting upgrades: It is smaller, lighter, and has a nice chrome 'Icey' look (some coasters from the Ikea do the trick here)*. </div>
<div style="font-family: Arial,Helvetica,sans-serif;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgMPiKClAd7bE3d91xrIwVcRvTHcr3D-LryN5Allxt152OIEiMlnrnUr3rnpDG4zGqakpJjZHr08RLYiPhU-MF5X-2SLRn8JH8IY3SyuG0HCb_PoxL7r9fAQQ2JzNkaWaeu-6DFTOXDf0c/s1600/P1060233.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgMPiKClAd7bE3d91xrIwVcRvTHcr3D-LryN5Allxt152OIEiMlnrnUr3rnpDG4zGqakpJjZHr08RLYiPhU-MF5X-2SLRn8JH8IY3SyuG0HCb_PoxL7r9fAQQ2JzNkaWaeu-6DFTOXDf0c/s400/P1060233.JPG" height="300" width="400" /></a></div>
<div style="font-family: Arial,Helvetica,sans-serif;">
</div>
<div style="font-family: Arial,Helvetica,sans-serif;">
The batteries are easy accesible without giving access to the secret stuff inside. So no auxillary power connection needed to be included here in case the batteries run flat. A three dimensional accelerometer instead of a homemade tilt sensor is used. Another new nice feature is the automated power off function. When the dice is not used (change of dice state) for 30 seconds the power is shut off automatically. The same webshop that provided the accelerometer also had in store a tiny (robot) controller with an Atmega328 on board. This little device is originally designed to control a small robot, but was also very suited for the Secret d'Icey. The dual H-bridge seems overkill, but the single transistors in the H-bridge proved to be very useful.</div>
<div style="font-family: Arial,Helvetica,sans-serif;">
</div>
<br />
<div align="center" class="contentarea">
<table border="0"><tbody>
<tr> <td><div class="separator" style="clear: both; text-align: center;">
<a href="http://www.pololu.com/catalog/product/766"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj38S3hdJ3L0k_kqYUWYgItWoKTUNl50qh5F5Wd_3-mDSXLl51bH0vce0CXplCxEqRIhwU1gE0QodAtCpB5XYy2_odcEK2EnxUzHn0YFXYGlcrbFwUr11X-T22ljoERVKPxxHAcONUSuAO6/s200/0J675.600.jpg" height="170" width="200" /></a></div>
<br /></td> <td><div class="separator" style="clear: both; text-align: center;">
<a href="http://www.pololu.com/catalog/product/1051"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifv1mSXiguvxXtcXgK4lMPY0w_TsMJoI1XCC6PceIJU5b-EY3FQWv1CHxb1AnmRpoXWJn-BMki7mk6QoTr5MEJS6AFVxh1TS6jf5aTW2XoKaqGE215BTGdw8E5mLu-Nlze3uqEpYe6oBkb/s200/0J2239.600.jpg" height="200" width="158" /></a></div>
<br /></td> <td><div class="separator" style="clear: both; text-align: center;">
<a href="http://www.pololu.com/catalog/product/1220"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdJvHL4UMw-v3avkDqLZjvACQ56Ts_CpTKvKXqUrKFGtZuotDueEP5lxgwl0l1IUjpJmgPUYtpt2Ax26p9wsCRTRu_u_VaUa_uiOianvR73M0v9uTlvOKNvypeoLqVEE2m7CazumWR2LDC/s200/0J661.600.jpg" height="158" width="200" /></a></div>
<br /></td> </tr>
</tbody></table>
</div>
<br />
<div style="font-family: Arial,Helvetica,sans-serif;">
<i>* Okay, at the moment this secret dice doesn't serve a higher purpose and is probably destined to stay a piece in the Deddies Lab hall of fame, so I may as well tell you the secret code: 6, 5, 4, 3, 2...... the last number is up to you.</i></div>
<div style="font-family: Arial,Helvetica,sans-serif;">
<br /></div>
<div style="font-family: Arial,Helvetica,sans-serif;">
<i> </i></div>
<br />
<div align="center">
<table border="0"><tbody>
<tr> <td><div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEith11KanYP3LEBucz85pYKHkMnDSbfAREQMGoIFpZLzf5B1sADHoD5Md68zrYdQ3NUd8zvjlLFxdtLClKO2XWeOCnTniPTwJ4yP6Dx95KJDpsnOeCerkiomC373cQVOk8zn-lXOwGi7T1P/s1600/P1050634.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEith11KanYP3LEBucz85pYKHkMnDSbfAREQMGoIFpZLzf5B1sADHoD5Md68zrYdQ3NUd8zvjlLFxdtLClKO2XWeOCnTniPTwJ4yP6Dx95KJDpsnOeCerkiomC373cQVOk8zn-lXOwGi7T1P/s200/P1050634.JPG" height="150" width="200" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
<a href="http://www.blogger.com/post-edit.g?blogID=9130726849248851041&postID=1248891970714856075"></a></td> <td><div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPLT-utfVxAdzhCABWmUURA8JRS_rNnDhk4sx1fhFc3869YT0cjnlfgbni06v4m0h9R0GX9Sl4peAk-Q5SsSejp4dCNsqocxqSj_ff5Iycx6XCcZPUO7YQSQYc5RmFSOBucIYiPKuGaMGo/s1600/P1060234.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPLT-utfVxAdzhCABWmUURA8JRS_rNnDhk4sx1fhFc3869YT0cjnlfgbni06v4m0h9R0GX9Sl4peAk-Q5SsSejp4dCNsqocxqSj_ff5Iycx6XCcZPUO7YQSQYc5RmFSOBucIYiPKuGaMGo/s200/P1060234.JPG" height="150" width="200" /></a></div>
<br />
<br /></td> </tr>
<tr> <td><div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMNWqJpcj1Yx5KQeD9_ycHaqlITYAV9wl5qejhAmaOHCtozC5x99p_M92VVRBZhvI9hUgPq1z3QoKq-4wgUDOd1O8f60vyOG-BbnshaCqHhHZBVmvRqBCepWK9rXauHzswCKTyasYZAmtE/s1600/P1060242.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMNWqJpcj1Yx5KQeD9_ycHaqlITYAV9wl5qejhAmaOHCtozC5x99p_M92VVRBZhvI9hUgPq1z3QoKq-4wgUDOd1O8f60vyOG-BbnshaCqHhHZBVmvRqBCepWK9rXauHzswCKTyasYZAmtE/s200/P1060242.JPG" height="150" width="200" /></a></div>
<br />
<a href="http://www.blogger.com/post-edit.g?blogID=9130726849248851041&postID=1248891970714856075"></a></td> <td><div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiG7UcaBKm-VvoA_ZB-vikIeMa4zdwC_xhzKB9qVOgKkxjjInnj9C3kLx15mLYTdvNn7gNzqr0FtcNLwee_FAwMvnmLQYgJ5LK4b6O_gKAY83tSiVKVB8C3BKMmEy8mi3WKsQGumB2Z_uUw/s1600/P1060246.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiG7UcaBKm-VvoA_ZB-vikIeMa4zdwC_xhzKB9qVOgKkxjjInnj9C3kLx15mLYTdvNn7gNzqr0FtcNLwee_FAwMvnmLQYgJ5LK4b6O_gKAY83tSiVKVB8C3BKMmEy8mi3WKsQGumB2Z_uUw/s200/P1060246.JPG" height="150" width="200" /></a></div>
<br />
<a href="http://www.blogger.com/post-edit.g?blogID=9130726849248851041&postID=1248891970714856075"></a></td> </tr>
</tbody></table>
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjR9jPhRxx7rfMMUE97VPVzjdkhYu4aks8vQ4CN_YU3WaucObTHA_Wjn65T8UJA6QOvOxeJr2aFavH-s2YIFZxZLZDJg7wvZZW7VaeJLhMrn0Zk7UtFJqc_obzKrYCgf3QmgEow_BPIFdBU/s1600/secret_dicey_schematic.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjR9jPhRxx7rfMMUE97VPVzjdkhYu4aks8vQ4CN_YU3WaucObTHA_Wjn65T8UJA6QOvOxeJr2aFavH-s2YIFZxZLZDJg7wvZZW7VaeJLhMrn0Zk7UtFJqc_obzKrYCgf3QmgEow_BPIFdBU/s400/secret_dicey_schematic.jpg" height="290" width="400" /></a></div>
<br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif;">Source:</span><br />
<span style="font-family: Arial,Helvetica,sans-serif;">- <a href="https://dl.dropboxusercontent.com/u/64993530/secret_dicey012a.c">secret_dicey012a.c</a> (winavr) </span><br />
<span style="font-family: Arial,Helvetica,sans-serif;">- <a href="https://dl.dropboxusercontent.com/u/64993530/codevision-dice.c">codevision-dice.c</a> (codevision, included in secret_dicey012a.c) </span>Deddies Labhttp://www.blogger.com/profile/16480149250377086609noreply@blogger.com10tag:blogger.com,1999:blog-9130726849248851041.post-12488919707148560752010-09-30T21:00:00.005+02:002014-06-22T21:57:42.674+02:00Huge Secret DiceFor a friend's wedding we had to find a way to wrap a gift we were going to give to the happy couple. With inpiration from <a href="https://www.youtube.com/watch?v=oOgc-rzm_hM">PICing4fun's</a> microcontroller based secret box we decided to construct our own secret dice. As for the size, bigger was better, this gave us enough space to fit all the parts. Eventually a 20x20x20 cm impressive dice was handed over at the wedding accompanied by a handful of more or less meaningful hints that would reveal a secret code. We also did the kind request not to butcher the dice with a flame thrower or crowbar and suggested to figure out the clues during their upcoming honeymoon.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWZ0aStzMKfP2JYgtoids2oHHkFO4YkhwzV5kzsUe5C7FBelszISemaIKPih1tqVzJhsF1GeTsGSTdRjYeVAg-zzN7kz_RICU4wR5aXTlp-wjGT_an4o1Cp4_9Uz4N0tpsTrU41FOzly8d/s1600/DSC00574.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWZ0aStzMKfP2JYgtoids2oHHkFO4YkhwzV5kzsUe5C7FBelszISemaIKPih1tqVzJhsF1GeTsGSTdRjYeVAg-zzN7kz_RICU4wR5aXTlp-wjGT_an4o1Cp4_9Uz4N0tpsTrU41FOzly8d/s400/DSC00574.JPG" height="300" width="400" /></a></div>
<br />
The basic idea is to turn the dice according the code. When the dice is turned exactly according the code with the right number on the dice facing up, the lit will be unlocked and reveal the goodies that are put inside. The lit is locked by a simple hobby servo, a clever constructed mechanical tilt sensor checks for the right state the dice is in and an always popular Atmega88 does the thinking.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/b2EJdIQr198?feature=player_embedded' frameborder='0'></iframe> </div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<br />
<div align="center">
<table border="0"><tbody>
<tr> <td><div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWk3t_sRas0wLRC7DaOO8wRPXj9iUm2aJ6OkEaJBgnEfWsxsz8-dI1_62dtQhnHQEA72NLKxYgzrz6eMs9mNgk__eHK1OuD03moNJr4IpKt2nHASY7lnlTo_qgKOUTH3HHbBmFfKXJeZF6/s1600/gyro+v2.0.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWk3t_sRas0wLRC7DaOO8wRPXj9iUm2aJ6OkEaJBgnEfWsxsz8-dI1_62dtQhnHQEA72NLKxYgzrz6eMs9mNgk__eHK1OuD03moNJr4IpKt2nHASY7lnlTo_qgKOUTH3HHbBmFfKXJeZF6/s200/gyro+v2.0.JPG" height="150" width="200" /><span id="goog_1518139830"></span><span id="goog_1518139831"></span></a></div>
<br />
<a href="http://www.blogger.com/post-edit.g?blogID=9130726849248851041&postID=1248891970714856075"></a></td> <td><div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNMm_XmnTVChdPbhfuKuUqmuFzZH_qHMkeV9DOA9DQnItXmAikKY5ckGP3dMFluzID6Wxi65SmOrGWJn4wV_D6J9wUAlib58msT5qafXri9fCbulxToXJbBxRQeFdyD8O18F4JFQXvBSNW/s1600/P1040625.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNMm_XmnTVChdPbhfuKuUqmuFzZH_qHMkeV9DOA9DQnItXmAikKY5ckGP3dMFluzID6Wxi65SmOrGWJn4wV_D6J9wUAlib58msT5qafXri9fCbulxToXJbBxRQeFdyD8O18F4JFQXvBSNW/s200/P1040625.JPG" height="150" width="200" /></a></div>
<br />
<a href="http://www.blogger.com/post-edit.g?blogID=9130726849248851041&postID=1248891970714856075"></a></td> </tr>
<tr> <td><div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggW-KkEGZ30lyoiCC_JB-iQV6XonyLsFJ231KFXMylmbjTRLTnnK112VluuDC4Wy3vd6f8dNro_gCJ0jHr9ey4PQWDYxUlQSZS7PsbtrmLZMg0Tm2ASVY9RZn3ZMXRWpnQbZd_qI8WA6aw/s1600/P1040630.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggW-KkEGZ30lyoiCC_JB-iQV6XonyLsFJ231KFXMylmbjTRLTnnK112VluuDC4Wy3vd6f8dNro_gCJ0jHr9ey4PQWDYxUlQSZS7PsbtrmLZMg0Tm2ASVY9RZn3ZMXRWpnQbZd_qI8WA6aw/s200/P1040630.JPG" height="150" width="200" /></a></div>
<br />
<a href="http://www.blogger.com/post-edit.g?blogID=9130726849248851041&postID=1248891970714856075"></a></td> <td><div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTMcsZsydY-hWHdE9x2nfxa0zb6TYnrUk-GbcrVyP3EH1Zlsfrt3rs_6C6J7-4gCPqxXJc_LwdtdZuO4XJLjodNpmlVw73epaHGDKmY5h4rZhvm9nlsZ-CgD25VykEGTncVr_DYMIlkDUq/s1600/P1040628.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTMcsZsydY-hWHdE9x2nfxa0zb6TYnrUk-GbcrVyP3EH1Zlsfrt3rs_6C6J7-4gCPqxXJc_LwdtdZuO4XJLjodNpmlVw73epaHGDKmY5h4rZhvm9nlsZ-CgD25VykEGTncVr_DYMIlkDUq/s200/P1040628.JPG" height="150" width="200" /></a></div>
<br />
<a href="http://www.blogger.com/post-edit.g?blogID=9130726849248851041&postID=1248891970714856075"></a></td> </tr>
</tbody></table>
</div>
<br />
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGJkBwMPwOHgyUCwnmnqc7r0hDceFnGTKEEASXTkUdacV73uygn1H95z9_vNGK8TjCdHdFBfr2mVc-rkMJRxXVKWjxb5uv40bdutVjobXf-dDYGA5XMoAxNubBIC5Tg_t49ljRzwVPXZiX/s1600/secret_dice_schematic.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGJkBwMPwOHgyUCwnmnqc7r0hDceFnGTKEEASXTkUdacV73uygn1H95z9_vNGK8TjCdHdFBfr2mVc-rkMJRxXVKWjxb5uv40bdutVjobXf-dDYGA5XMoAxNubBIC5Tg_t49ljRzwVPXZiX/s400/secret_dice_schematic.jpg" height="290" width="400" /></a></div>
<br />
<span style="font-family: Arial,Helvetica,sans-serif;">Source:</span></div>
<div>
<span style="font-family: Arial,Helvetica,sans-serif;">- <a href="https://dl.dropboxusercontent.com/u/64993530/trueboard_secretdice2.c">trueboard_secretdice2.c</a> (codevision)</span></div>
<div>
<span style="font-family: Arial,Helvetica,sans-serif;">- <a href="https://dl.dropboxusercontent.com/u/64993530/codevision-dice.c">codevision-dice.c</a></span><span style="font-family: Arial,Helvetica,sans-serif;"> (codevision, included in trueboard_secretdice2.c)</span></div>
Deddies Labhttp://www.blogger.com/profile/16480149250377086609noreply@blogger.com0