tag:blogger.com,1999:blog-15175021746190448942024-03-04T23:49:43.434-08:00Interactive SquaredMatthewhttp://www.blogger.com/profile/05818659732501156825noreply@blogger.comBlogger18125tag:blogger.com,1999:blog-1517502174619044894.post-5389645318236668602010-07-26T12:15:00.001-07:002010-07-26T12:15:37.706-07:00Video of it in Action<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/g60owdbnlXM&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/g60owdbnlXM&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>Matthewhttp://www.blogger.com/profile/05818659732501156825noreply@blogger.com0tag:blogger.com,1999:blog-1517502174619044894.post-67272590466628788692010-07-22T09:00:00.000-07:002010-07-22T05:57:11.046-07:00Photo fun<a href="http://www.flickr.com/photos/archicroc/4816961329/" title="IMG_0766 by ArchiCroc, on Flickr"><img alt="IMG_0766" height="333" src="http://farm5.static.flickr.com/4076/4816961329_399274d0ce.jpg" width="500" /></a><br />
The gears inside the servo<br />
<br />
<a href="http://www.flickr.com/photos/archicroc/4817584834/" title="IMG_0769 by ArchiCroc, on Flickr"><img alt="IMG_0769" height="333" src="http://farm5.static.flickr.com/4081/4817584834_c6c7251eaa.jpg" width="500" /></a><br />
Making a servo spin continuously: remove the guts and solder power directly to the motor<br />
<br />
<a href="http://www.flickr.com/photos/archicroc/4816960781/" title="IMG_0757 by ArchiCroc, on Flickr"><img alt="IMG_0757" height="333" src="http://farm5.static.flickr.com/4078/4816960781_2eb9831def.jpg" width="500" /></a><br />
<br />
<br />
<a href="http://www.flickr.com/photos/archicroc/4816960439/" title="IMG_0751 by ArchiCroc, on Flickr"><img alt="IMG_0751" height="333" src="http://farm5.static.flickr.com/4079/4816960439_3a7db851fe.jpg" width="500" /></a><br />
waxing the panels<br />
<br />
<a href="http://www.flickr.com/photos/archicroc/4816962377/" title="IMG_0784 by ArchiCroc, on Flickr"><img alt="IMG_0784" height="333" src="http://farm5.static.flickr.com/4099/4816962377_3645716e16.jpg" width="500" /></a><br />
mounting the wheel<br />
<br />
<a href="http://www.flickr.com/photos/archicroc/4816963119/" title="IMG_0796 by ArchiCroc, on Flickr"><img alt="IMG_0796" height="333" src="http://farm5.static.flickr.com/4076/4816963119_62393120a0.jpg" width="500" /></a><br />
center spoke assembly<br />
<br />
<a href="http://www.flickr.com/photos/archicroc/4817586370/" title="IMG_0797 by ArchiCroc, on Flickr"><img alt="IMG_0797" height="333" src="http://farm5.static.flickr.com/4094/4817586370_e2468488a9.jpg" width="500" /></a><br />
We used a spare gear to anchor the shaft to the hub<br />
<br />
<a href="http://www.flickr.com/photos/archicroc/4816964137/" title="IMG_0812 by ArchiCroc, on Flickr"><img alt="IMG_0812" height="330" src="http://farm5.static.flickr.com/4079/4816964137_4f4ff1783c.jpg" width="500" /></a><br />
Hub assembled and the extra length on the bolts cut off<br />
<br />
<a href="http://www.flickr.com/photos/archicroc/4816964217/" title="IMG_0813 by ArchiCroc, on Flickr"><img alt="IMG_0813" height="333" src="http://farm5.static.flickr.com/4142/4816964217_03fde2ef5e.jpg" width="500" /></a><br />
Adding a few more nails to the face plate<br />
<br />
<a href="http://www.flickr.com/photos/archicroc/4816964269/" title="IMG_0814 by ArchiCroc, on Flickr"><img alt="IMG_0814" height="333" src="http://farm5.static.flickr.com/4078/4816964269_3c66045de1.jpg" width="500" /></a><br />
perfecting the tracks with a little filing<br />
<br />
<a href="http://www.flickr.com/photos/archicroc/4816965569/" title="IMG_0833 by ArchiCroc, on Flickr"><img alt="IMG_0833" height="333" src="http://farm5.static.flickr.com/4119/4816965569_aa562d5a54.jpg" width="500" /></a><br />
Fitting the front panels<br />
<br />
<a href="http://www.flickr.com/photos/archicroc/4816964807/" title="IMG_0821 by ArchiCroc, on Flickr"><img alt="IMG_0821" height="333" src="http://farm5.static.flickr.com/4117/4816964807_eb9525ef27.jpg" width="500" /></a><br />
Hub installed and the sliding panels connected<br />
<br />
<a href="http://www.flickr.com/photos/archicroc/4817588542/" title="IMG_0832 by ArchiCroc, on Flickr"><img alt="IMG_0832" height="333" src="http://farm5.static.flickr.com/4079/4817588542_67ce216361.jpg" width="500" /></a><br />
Closed<br />
<br />
<a href="http://www.flickr.com/photos/archicroc/4817588762/" title="IMG_0836 by ArchiCroc, on Flickr"><img alt="IMG_0836" height="333" src="http://farm5.static.flickr.com/4075/4817588762_81610d260f.jpg" width="500" /></a><br />
Open<br />
<br />
<a href="http://www.flickr.com/photos/archicroc/4817588826/" title="IMG_0837 by ArchiCroc, on Flickr"><img alt="IMG_0837" height="333" src="http://farm5.static.flickr.com/4075/4817588826_36ebf18aba.jpg" width="500" /></a><br />
Mounting the servo to the main shaft<br />
<br />
<a href="http://www.flickr.com/photos/archicroc/4817588978/" title="IMG_0839 by ArchiCroc, on Flickr"><img alt="IMG_0839" height="333" src="http://farm5.static.flickr.com/4081/4817588978_4d0040613d.jpg" width="500" /></a><br />
The modified servo connected to the wave machine cam shaft<br />
<br />
<a href="http://www.flickr.com/photos/archicroc/4816966099/" title="IMG_0841 by ArchiCroc, on Flickr"><img alt="IMG_0841" height="333" src="http://farm5.static.flickr.com/4142/4816966099_521d7da814.jpg" width="500" /></a><br />
Rubber band ensure that wave machine paddles are always pressed against the camsMatthewhttp://www.blogger.com/profile/05818659732501156825noreply@blogger.com0tag:blogger.com,1999:blog-1517502174619044894.post-58228518294798047062010-07-22T05:26:00.000-07:002010-07-22T05:38:30.359-07:00ConceptWe started with the concept of an oculus that would open and close in response to some kind of human interaction. In researching precedents we found an expanding <a href="http://www.youtube.com/watch?v=f5l3g2JwCMo">Jupe table</a> by craftsman Theodore Alexander that expanded as it rotates. As we further developed the design we came up with a system that translates rotation into oscillation. This system can be seen as an example of the Coriolis Effect, a natural phenomenon that creates outward forces as a result of rotation. The most familiar examples being hurricanes, typhoons, or even the draining of a bath tub. By mounting the system on a track we are able to control the outward forces created by this phenomenon. <br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhuik02qVm230Z6NKWtKFLONhBTU4Whk91EPScPOCQAcUk2AV9ZrxL6sgV3Q8pgkDkWs1zc10MO5SBHxijsHjWGao6gYHxyzunjTZqgs1cN7UbM-YXtem2y6zoItk7xIgWXYFA9C_WdzgB0/s1600/earth+coriolis.png"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhuik02qVm230Z6NKWtKFLONhBTU4Whk91EPScPOCQAcUk2AV9ZrxL6sgV3Q8pgkDkWs1zc10MO5SBHxijsHjWGao6gYHxyzunjTZqgs1cN7UbM-YXtem2y6zoItk7xIgWXYFA9C_WdzgB0/s320/earth+coriolis.png" /></a><br />
<br />
Using 8 wooden spades connected to a central track system, we were able to tie into a hub assembly using 8 radial arms cut out of ¼” plywood. The Radial arms are connected to the wooden spades using ¼” wood dowels allowing for pinned connections at either end, so, as the central hub assembly rotates, spun by a servo motor and chain drive, the spades move along the track system. The spade pieces were first laser cut out of 1/4" MDF to be used as a template. This template was then used to cut the spade out of the red oak using a bench router. Once all the spades were cut we gave them a finish sanding and sealed them with finishing wax. <br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYrbW4DBR5QhyphenhyphenuMduRe6RRY-p60X4GAhwATsC412z2aCE6lsm1wL_D5EFY3ewVtoaRSgj5gtaULa2zIhEancJHCRcHOpEo8Dj2baSU5O48l3DDSUE-tZlJa7CEhfzY3O4iSyRryNvWnAOW/s1600/12_Template_Routing_md.jpg" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYrbW4DBR5QhyphenhyphenuMduRe6RRY-p60X4GAhwATsC412z2aCE6lsm1wL_D5EFY3ewVtoaRSgj5gtaULa2zIhEancJHCRcHOpEo8Dj2baSU5O48l3DDSUE-tZlJa7CEhfzY3O4iSyRryNvWnAOW/s320/12_Template_Routing_md.jpg" /></a><br />
After designing the oculus we decided that there needed to be more happening in the background so we scoured the web and found an interesting double cam wave machine that was manually operated using two handles <br />
<br />
<img border="0" src="http://www.focsle.org.uk/first/images/WMc1995-med.jpg" width="500" /><br />
<br />
Using this precedent we developed a single cam system that was connected to a modified servo motor which would run when the oculus was opened. The wave machine itself is a relatively simple construct. It is composed of 24 1”x2”x18” wood members (alternating red oak and pine) which are connected using a threaded rod that acts as a fulcrum. Groves are then cut into the bottom of each member to allow for the cam shaft to move smoothly. At the top of each member a rubber band is fitted in place so that each individual member will snap back into place once the cam lobe has passed it.<br />
<br />
In order to make the project more interactive it needed to respond to the presence of the viewer so by installing an infrared proximity sensor we could detect if anyone was standing directly in front of it. We decided it would be fun to mess with people so the project was designed to be operating if no one was directly in front of it but once someone comes in for a closer look, the oculus would close and all motion would cease.Matthewhttp://www.blogger.com/profile/05818659732501156825noreply@blogger.com0tag:blogger.com,1999:blog-1517502174619044894.post-62660592895679135492010-07-22T05:22:00.000-07:002010-07-22T05:22:26.697-07:00Materials1 Arduino Microcontroller<br />
6 L.F. 1 x 12 Red Oak <br />
12 L.F. 1 x 2 Red Oak <br />
4 L.F. 1 x 12 Pine<br />
12 L.F. 1 x 2 Pine <br />
8 L.F. 2 x 4 Pine<br />
1/8” Plywood - 4’ x 8’ Sheet<br />
2 Hi Torque Digital Servo Motors<br />
5/16” Threaded Rod - Approx 24”<br />
2 EA. 5/16” Nuts and Washers <br />
24 Rubber Bands<br />
1/8” Wood Dowels<br />
1/2” Diameter Soft Metal Rod<br />
1/4” Drive Chain - Approx. 24”<br />
1/2” Bearing<br />
1/2” Sprocket (2 Ea.)<br />
2 Straight Metal BracketsMatthewhttp://www.blogger.com/profile/05818659732501156825noreply@blogger.com0tag:blogger.com,1999:blog-1517502174619044894.post-11223718341087112712010-07-22T03:41:00.000-07:002010-07-22T04:01:08.462-07:00CodeHere is how the arduino is currently setup:<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYit3EehYcKDXa_TyCrcjZp1YpMzEc3Xgbn6W7DVaalRaYW_K2blh0UCjGLYtOV5MeI4YEp0PkUsch5PZ5XGmYPIihIDJQqgWPguEolJ9-DWo-q3P9xHmpAtgtvom5ga0XbEGzOvIxXeur/s1600/digital+siminar_bb2.png"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYit3EehYcKDXa_TyCrcjZp1YpMzEc3Xgbn6W7DVaalRaYW_K2blh0UCjGLYtOV5MeI4YEp0PkUsch5PZ5XGmYPIihIDJQqgWPguEolJ9-DWo-q3P9xHmpAtgtvom5ga0XbEGzOvIxXeur/s320/digital+siminar_bb2.png" /></a><br />
Servo is in pin 9 and the proximity sensor in in analog pin 0.<br />
<br />
Code:<br />
<pre>#include <<span style="color: #cc6600;">Servo</span>.h>
#define proximityPin 0
#define maxCount 40
<span style="color: #cc6600;">int</span> proximity = 0;
<span style="color: #cc6600;">Servo</span> centerHub; <span style="color: #7e7e7e;">// create servo object to control a servo </span>
<span style="color: #7e7e7e;">// a maximum of eight servo objects can be created </span>
<span style="color: #cc6600;">int</span> pos = 0; <span style="color: #7e7e7e;">// variable to store the servo position </span>
<span style="color: #cc6600;">boolean</span> state = <span style="color: #cc6600;">true</span>; <span style="color: #7e7e7e;">//true = open, false = close</span>
<span style="color: #cc6600;">int</span> count = 0;
<span style="color: #cc6600;">void</span> <span style="color: #cc6600;"><b>setup</b></span>()
{
centerHub.<span style="color: #cc6600;">attach</span>(9);
<span style="color: #7e7e7e;">// centerHub.write(0); //position 0 is all the way open</span>
<span style="color: #cc6600;"><b>Serial</b></span>.<span style="color: #cc6600;">begin</span>(9600);
}
<span style="color: #cc6600;">void</span> <span style="color: #cc6600;"><b>loop</b></span>()
{
proximity = <span style="color: #cc6600;">analogRead</span>(proximityPin);
<span style="color: #cc6600;"><b>Serial</b></span>.<span style="color: #cc6600;">println</span>(proximity,<span style="color: #006699;">DEC</span>);
<span style="color: #7e7e7e;">//if some one is far away</span>
<span style="color: #cc6600;">if</span>(proximity < 100 && state == <span style="color: #cc6600;">false</span>){
<span style="color: #cc6600;">if</span>(count > maxCount){
<span style="color: #7e7e7e;">//open</span>
<span style="color: #cc6600;">for</span>(pos = 180; pos>=1; pos-=1){
centerHub.<span style="color: #cc6600;">write</span>(pos);
<span style="color: #cc6600;">delay</span>(20);
}
<span style="color: #cc6600;">delay</span>(5000);
state = <span style="color: #cc6600;">true</span>;
count = 0;
} <span style="color: #cc6600;">else</span> {
count++;
}
}
<span style="color: #7e7e7e;">//if some ones comes close</span>
<span style="color: #cc6600;">else</span> <span style="color: #cc6600;">if</span>(proximity > 300 && state == <span style="color: #cc6600;">true</span>){
<span style="color: #cc6600;">if</span>(count > maxCount){
<span style="color: #7e7e7e;">//close</span>
<span style="color: #cc6600;">for</span>(pos = 0; pos < 188; pos += 1) {
centerHub.<span style="color: #cc6600;">write</span>(pos);
<span style="color: #cc6600;">delay</span>(10);
}
<span style="color: #cc6600;">delay</span>(5000);
state = <span style="color: #cc6600;">false</span>;
count = 0;
} <span style="color: #cc6600;">else</span> {
count++;
}
}
<span style="color: #7e7e7e;">//if you are standing the middle</span>
<span style="color: #cc6600;">else</span> {
count = 0;
}
<span style="color: #cc6600;">delay</span>(50);
}
</pre>Matthewhttp://www.blogger.com/profile/05818659732501156825noreply@blogger.com0tag:blogger.com,1999:blog-1517502174619044894.post-17665085893330959662010-07-20T06:06:00.000-07:002010-07-20T06:31:40.281-07:00Laser CuttingOne of the coolest things the USF School of Architecture has is a laser cutter.<br />
<a href="http://www.flickr.com/photos/archicroc/4811573582/" title="IMG_0717 by ArchiCroc, on Flickr"><img alt="IMG_0717" height="333" src="http://farm5.static.flickr.com/4101/4811573582_2e111e9178.jpg" width="500" /></a><br />
Cut marks are drawn in red in autocad and printed to the Versa Laser program<br />
<br />
<a href="http://www.flickr.com/photos/archicroc/4810950307/" title="IMG_0713 by ArchiCroc, on Flickr"><img alt="IMG_0713" height="333" src="http://farm5.static.flickr.com/4093/4810950307_b9324b89bf.jpg" width="500" /></a><br />
Load in material, quarter inch birch plywood<br />
<a href="http://www.flickr.com/photos/archicroc/4810950975/" title="IMG_0726 by ArchiCroc, on Flickr"><img alt="IMG_0726" height="333" src="http://farm5.static.flickr.com/4080/4810950975_d421fb1810.jpg" width="500" /></a><br />
the laser cuts it perfectly<br />
<br />
<a href="http://www.flickr.com/photos/archicroc/4810951135/" title="IMG_0730 by ArchiCroc, on Flickr"><img alt="IMG_0730" height="333" src="http://farm5.static.flickr.com/4093/4810951135_a5d77534f5.jpg" width="500" /></a><br />
<br />
<a href="http://www.flickr.com/photos/archicroc/4811574462/" title="IMG_0733 by ArchiCroc, on Flickr"><img alt="IMG_0733" height="333" src="http://farm5.static.flickr.com/4102/4811574462_8b41b8a8de.jpg" width="500" /></a><br />
The pieces just needed a little push to fall out.<br />
<br />
<a href="http://www.flickr.com/photos/archicroc/4811574602/" title="IMG_0738 by ArchiCroc, on Flickr"><img alt="IMG_0738" height="333" src="http://farm5.static.flickr.com/4120/4811574602_e3655a6e94.jpg" width="500" /></a><br />
The parts assembled for the wave machineMatthewhttp://www.blogger.com/profile/05818659732501156825noreply@blogger.com0tag:blogger.com,1999:blog-1517502174619044894.post-16449280641985792812010-07-06T05:59:00.000-07:002010-07-06T07:32:31.899-07:00Marching towards the finalFor the final, each group has a 2' square to use as a foundation to create some sort of interactive electronic demonstration<br />
<a href="http://www.flickr.com/photos/archicroc/4767178633/" title="IMG_0463 by ArchiCroc, on Flickr"><img alt="IMG_0463" height="333" src="http://farm5.static.flickr.com/4136/4767178633_5a12b862d6.jpg" width="500" /></a><br />
<a href="http://www.flickr.com/photos/archicroc/4767818176/" title="IMG_0498 by ArchiCroc, on Flickr"><img alt="IMG_0498" height="333" src="http://farm5.static.flickr.com/4139/4767818176_f4ec70fcbb.jpg" width="500" /></a><a href="http://www.flickr.com/photos/archicroc/4767819468/" title="IMG_0524 by ArchiCroc, on Flickr"><img alt="IMG_0524" height="333" src="http://farm5.static.flickr.com/4135/4767819468_88cdb05bd8.jpg" width="500" /></a><a href="http://www.flickr.com/photos/archicroc/4767466255/" title="IMG_0596 by ArchiCroc, on Flickr"><img alt="IMG_0596" height="333" src="http://farm5.static.flickr.com/4096/4767466255_b0db7c0643.jpg" width="500" /></a><br />
Our groups design is centered around a roating shaft that will slide panels open and close to reveal some sort of moving backdrop.<br />
<a href="http://www.flickr.com/photos/archicroc/4767182105/" title="IMG_0552 by ArchiCroc, on Flickr"><img alt="IMG_0552" height="333" src="http://farm5.static.flickr.com/4078/4767182105_780bae61a9.jpg" width="500" /></a><br />
<a href="http://www.flickr.com/photos/archicroc/4767819770/" title="IMG_0535 by ArchiCroc, on Flickr"><img alt="IMG_0535" height="333" src="http://farm5.static.flickr.com/4123/4767819770_befe97d3ec.jpg" width="500" /></a><br />
<br />
The shaft is going to be turned by 2 high torq servo link to the center shaft with gears. These parts will be delivered this week.<br />
<br />
Currently the electronic design looks like:<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCsc5mYNIoctUH9uofcEzNOEhPG35ntmSWCiMkXGjSX6V6qCSbbJNCY4MGnfahd9D-WRMtHF7SUdjDiK6Zz9I0TDpkr19oARbvwG5yslKDMYuRG0E_XR5KOwblZ3mIjp65NM78t2qtcLJu/s1600/digital+siminar_bb.png"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCsc5mYNIoctUH9uofcEzNOEhPG35ntmSWCiMkXGjSX6V6qCSbbJNCY4MGnfahd9D-WRMtHF7SUdjDiK6Zz9I0TDpkr19oARbvwG5yslKDMYuRG0E_XR5KOwblZ3mIjp65NM78t2qtcLJu/s320/digital+siminar_bb.png" /></a><br />
For this project we are using a infrared proximity sensor connected to an arduino that will drive the servos. The mechanical design for the background is still being developed so this diagram may change.<br />
<br />
<a href="http://www.flickr.com/photos/archicroc/sets/72157624159894413/">More Photos </a>Matthewhttp://www.blogger.com/profile/05818659732501156825noreply@blogger.com0tag:blogger.com,1999:blog-1517502174619044894.post-15194963104595853352010-06-29T05:41:00.000-07:002010-07-22T06:26:22.667-07:00Hacking a Light ToySo after much frustration with my first attempt I decided to hack a toy instead of making something from scratch. The toy, shown below, just had a push button before, but I wanted to make it come on when the lights went off.<br /><br /><a href="http://www.flickr.com/photos/52257338@N06/4818162966/" title="IMG_3334 by DBAPOZER, on Flickr"><img src="http://farm5.static.flickr.com/4118/4818162966_a7a886b70c.jpg" alt="IMG_3334" width="500" height="375" /></a><br /><br /><a href="http://www.flickr.com/photos/52257338@N06/4817539697/" title="IMG_3335 by DBAPOZER, on Flickr"><img src="http://farm5.static.flickr.com/4095/4817539697_52c66a23bc.jpg" alt="IMG_3335" width="500" height="375" /></a><br /><br />After breaking open the toy I popped out a piece from the back and slipped the wires out of the new hole.<br /><br /><a href="http://www.flickr.com/photos/52257338@N06/4817539845/" title="IMG_3344 by DBAPOZER, on Flickr"><img src="http://farm5.static.flickr.com/4116/4817539845_005b6b7674.jpg" alt="IMG_3344" width="500" height="375" /></a><br /><br />Before adding a sensor I wanted to make sure I could hack it and ran it with a simple blink code.<br />After doing this I was able to manipulate the function by making it strobe on and off. Success!<br /><br /><a href="http://www.flickr.com/photos/52257338@N06/4818163348/" title="IMG_3383 by DBAPOZER, on Flickr"><img src="http://farm5.static.flickr.com/4097/4818163348_7af1fc4353.jpg" alt="IMG_3383" width="500" height="375" /></a><br /><br />Now it's time for the photo resistor.<br /><br /><a href="http://www.flickr.com/photos/52257338@N06/4817540031/" title="IMG_3385 by DBAPOZER, on Flickr"><img src="http://farm5.static.flickr.com/4115/4817540031_8d8b2ed154.jpg" alt="IMG_3385" width="500" height="375" /></a><br /><br />I removed the button to replace it with the photo resistor.<br /><br /><a href="http://www.flickr.com/photos/52257338@N06/4817540093/" title="IMG_3388 by DBAPOZER, on Flickr"><img src="http://farm5.static.flickr.com/4123/4817540093_08e592623b.jpg" alt="IMG_3388" width="500" height="375" /></a><br /><br />Set the resistor with hot glue.<br /><br /><a href="http://www.flickr.com/photos/52257338@N06/4818163542/" title="IMG_3389 by DBAPOZER, on Flickr"><img src="http://farm5.static.flickr.com/4122/4818163542_6241de92ed.jpg" alt="IMG_3389" width="500" height="375" /></a><br /><br />Solder some wires to it.<br /><br /><a href="http://www.flickr.com/photos/52257338@N06/4817540191/" title="IMG_3390 by DBAPOZER, on Flickr"><img src="http://farm5.static.flickr.com/4119/4817540191_31cf8f100c.jpg" alt="IMG_3390" width="500" height="375" /></a><br /><br />Pull out the wires.<br /><br /><a href="http://www.flickr.com/photos/52257338@N06/4817540269/" title="IMG_5576 by DBAPOZER, on Flickr"><img src="http://farm5.static.flickr.com/4117/4817540269_da87c788ef.jpg" alt="IMG_5576" width="500" height="375" /></a><br /><br />Wire it up to the arduino.<br /><br /><a href="http://www.flickr.com/photos/52257338@N06/4818163864/" title="IMG_5578 by DBAPOZER, on Flickr"><img src="http://farm5.static.flickr.com/4122/4818163864_02934ae145.jpg" alt="IMG_5578" width="500" height="375" /></a><br /><br />Lights on...<br /><br /><a href="http://www.flickr.com/photos/52257338@N06/4818163962/" title="IMG_5583 by DBAPOZER, on Flickr"><img src="http://farm5.static.flickr.com/4121/4818163962_faeaac7dd3.jpg" alt="IMG_5583" width="500" height="375" /></a><br /><br />Lights off...<br /><br />The code I used is very simple. It's a combination of the example blink and button.<br /><br />Here's the code:<br /><br />/*<br />photo resistor as a Button<br /><br />Turns on and off anything connected to digital<br />pin 13, when pressing a pushbutton attached to pin 2.<br /><br /><br />The circuit:<br />* LED attached from pin 13 to ground<br />* pushbutton attached to pin 2 from +5V<br />* 10K resistor attached to pin 2 from ground<br /><br />* Note: on most Arduinos there is already an LED on the board<br />attached to pin 13.<br /><br /><br />created 2005<br />by DojoDave <http: org=""><br />modified 17 Jun 2009<br />by Tom Igoe<br /><br /> http://www.arduino.cc/en/Tutorial/Button<br /><br /> modified june 2010<br /> by Richard Meacham<br /> http://interactivesquared.blogspot.com/<br />*/<br /><br />// constants won't change. They're used here to<br />// set pin numbers:<br />const int buttonPin = 2; // the number of the pushbutton pin<br />const int ledPin = 13; // the number of the LED pin<br /><br />// variables will change:<br />int buttonState = 2000 ; // variable for reading the pushbutton status.<br /><br />void setup() {<br /> // initialize the LED pin as an output:<br /> pinMode(ledPin, OUTPUT); <br /> // initialize the pushbutton pin as an input:<br /> pinMode(buttonPin, INPUT); <br />}<br /><br />void loop(){<br /> // read the state of the pushbutton value:<br /> buttonState = digitalRead(buttonPin);<br /><br /> // check if the pushbutton is pressed.<br /> // if it is, the buttonState is HIGH:<br /> if (buttonState == HIGH) { <br /> // turn LED on: <br /> digitalWrite(ledPin, HIGH); // set the LED on<br /> delay(500); // wait for a second<br /> digitalWrite(ledPin, LOW); // set the LED off<br /> delay(250); // wait for a second<br /> }<br /> else {<br /> // turn LED off:<br /> digitalWrite(ledPin, LOW);<br /> }<br />}<br /><br />And the wiring diagram:<br /><br /><a href="http://www.flickr.com/photos/52257338@N06/4818270464/" title="button by DBAPOZER, on Flickr"><img src="http://farm5.static.flickr.com/4114/4818270464_62c0e3854c.jpg" alt="button" width="500" height="194" /></a></http:>MEACHAMhttp://www.blogger.com/profile/12770196583094702925noreply@blogger.com0tag:blogger.com,1999:blog-1517502174619044894.post-26349713178249565552010-06-21T11:09:00.000-07:002010-06-21T11:21:33.152-07:00Brain StormSo I've been working on a list of ideas that I thought might be fun some better than others;<br /><br />Board of balloons that inflate to reflect the location of a person<br /><br />Series of fans that move to blow air away from people<br /><br />Maybe we integrate the idea of a projected touchscreen with sound so that it projects an image on the floor and when you step in a certain area it produces some sort of sound<br /><br />Some type of audio instructions that tell people how to interact with the project, then when they do it something happens<br /><br />Some type of mirror mirror on the wall looking thing that begs to be freed from the "mirror prison" then when you touch it, it screams to leave it aloneMEACHAMhttp://www.blogger.com/profile/12770196583094702925noreply@blogger.com0tag:blogger.com,1999:blog-1517502174619044894.post-25265762259039174542010-06-21T09:11:00.000-07:002010-06-21T09:51:11.322-07:00Multitouch SurfaceI've been looking at precedents for this final installation project and was intrigued by this multitouch surface. Its a little bit on the complicated side but I think we can do within our time constraints. Essentially it is a touchscreen that is attached to a computer in such a way that you dont need a mouse or keyboard. Check out the website below to see some of the applications.<br /><br />Its an interesting project and has the potential to be extremely interactive but its also kind of boring in the sense that it is competely digital; It doesnt move, there arent any interesting mechanics or cool materials. Anyhow, check it out and let me know what you think. Also shoot any ideas you guys might have my way.<br /><br /><a href="http://www.maximumpc.com/article/features/maximum_pc_builds_a_multitouch_surface_computer?page=0%2C0">http://www.maximumpc.com/article/features/maximum_pc_builds_a_multitouch_surface_computer?page=0%2C0</a>Francarlos Riverahttp://www.blogger.com/profile/10628654557259991059noreply@blogger.com0tag:blogger.com,1999:blog-1517502174619044894.post-23473521729621642502010-06-16T21:00:00.000-07:002010-06-16T21:33:39.238-07:00Photos from our first Presentation<iframe scrolling="no" width="400" height="360" frameborder="0" align="center" width="480" src="http://www.flickr.com/slideShow/index.gne?group_id=&user_id=&set_id=72157624159894413&text="></iframe>Matthewhttp://www.blogger.com/profile/05818659732501156825noreply@blogger.com0tag:blogger.com,1999:blog-1517502174619044894.post-46061282024666150312010-06-16T20:50:00.000-07:002010-06-16T20:50:26.612-07:00Arduino ResourcesTake a look at this video<br />
<object height="385" width="640"><param name="movie" value="http://www.youtube.com/v/mABZmZx5m4o&hl=en_US&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/mABZmZx5m4o&hl=en_US&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object><br />
<br />
Then take a look at this <a href="http://www.blogger.com/%20http://physcomp.arduinoeducation.com/home/unit-2/ARDUINO_NOTEBOOKv6.pdf?attredirects=0">intro to coding</a> [pdf]. It covers the basic of code well.<br />
<br />
Next take a look over at <a href="http://www.ladyada.net/learn/arduino/lesson2.html">adafruit's tutorial</a> that walks through each line of the basic blink sketch.<br />
<br />
Remember to have fun!Matthewhttp://www.blogger.com/profile/05818659732501156825noreply@blogger.com0tag:blogger.com,1999:blog-1517502174619044894.post-12684200237248385842010-06-16T11:10:00.000-07:002010-06-17T08:13:55.993-07:00The Idea<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiurGpjWoG9VnQaEss-m4G9ohENReWcmGU6bPx2BhAPHzHcGm5D3Vt1GwUkJ5VGcDKJgYERTYznOzwnYDikuehFDI_ISiRWEGZ4aXI4GlSYV84LLGSqSSZL17iTE___xUufgBcYl1NCOMvc/s1600/P1050127.JPG"><img style="TEXT-ALIGN: center; MARGIN: 0px auto 10px; WIDTH: 240px; DISPLAY: block; HEIGHT: 320px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5483749416046244002" border="0" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiurGpjWoG9VnQaEss-m4G9ohENReWcmGU6bPx2BhAPHzHcGm5D3Vt1GwUkJ5VGcDKJgYERTYznOzwnYDikuehFDI_ISiRWEGZ4aXI4GlSYV84LLGSqSSZL17iTE___xUufgBcYl1NCOMvc/s320/P1050127.JPG" /></a><br /><div><div><div><div><div><div><div><div><div><div><div><div><div><div><u><strong></strong></u></div><div><u><strong></strong></u></div><div><u><strong>The Idea:</strong> </u></div><br /><div>When we were introduced to this project as the "Lamp Monster" I knew I wanted my project to grow when it got angry, and what would piss you off more than getting electricuted by a battery? Essentially, what I came up with was a lamp fixture that opens up to reveal a smaller compartment which houses an LED light source. The LEDs are controlled using a photoresistor allowing for the lights to get brighter as the surrounding environment gets darker (and vise versa) While trying to figure out how to make this thing open and close I considered small gear system attached to a servo motor or a some kind of pully system but it seemed overly complicated for such a simple function. After discussing the project with my brother, a mechanic, we determined that this process could be simplified by using a window motor and regulator assembly from a car. </div><br /><div><strong><u>The Materials:</u></strong></div><div></div><ul><li>Arduino Microcontroller</li><li>Auto Window Motor and Regulator Assembly</li><li>10 LEDs</li><li>12v battery</li><li>Photoresistor</li><li>10k Ohm resistor</li><li>Up/Down toggle switch</li><li>18 ga. wire for motor</li><li>24 ga. wire for lights</li><li>Two 1/4" x 1" machine bolts</li><li>Two 1/4" x 1" coupling nuts</li><li>Two 1/4" x 1" washers</li><li>Approx. 3 sheets of 28" x 40" double ply chip board</li></ul><div><strong><u>Step One:</u></strong></div><br /><div>The first step to contructing this project was building a case that would house the motor and regulator. The housing is composed of two pieces, a main lower case where the motor and regulator will be mounted and an upper light compartment that will be pushed and pulled by the motor. Using a laser cutter and some chip board I cut out the individual pieces for the vertical and horizontal supports, then laminated those pieces until they were four plies thick. Once the glue had cured I assembled the upper and lower portions seperately. On the lower portion of the case I located the mounting studs on the horizontal bracing and driled 1/4" holes for the machine bolts. After attaching the coupling nuts to the mounting studs on the regulator I attached the entire assembly to the lower portion of my case. </div><br /><div></div><img style="TEXT-ALIGN: center; MARGIN: 0px auto 10px; WIDTH: 320px; DISPLAY: block; HEIGHT: 240px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5483748572113649858" border="0" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkswDATc9-XaqhXrvR9wYazi-T5buK4nu5eMgwyxFyVoC7Fs7fXdgrq1puMDSzjkXpClYPNo1ofgOlpHQk47pWQC9WZw5A2G5Q-zYRRAILTNo6BUSE_dDg-rWINUrp23Xs2V_YUNTWgGYF/s320/P1050105.JPG" /><br /><div><u><strong>Step Two:</strong></u></div><br /><div>Now that the motor and regulator assembly were in place I can wire in the switch. Initially, I wanted to have the motor controlled by the arduino board using a proximity sensor (if you got within five feet it would open up otherwise it would close) but I ran into some trouble because the window motor is multidirectional. Whether the motor moves up or down depends on the direction in which the current is flowing. I was able to give dedicated power and ground through the arduino, but I could not figure out how to switch between the two. I hope to revisit this with some assistance but eventually, I ended up using a two way up/down switch to control motion. </div><br /><div></div><img style="TEXT-ALIGN: center; MARGIN: 0px auto 10px; WIDTH: 320px; DISPLAY: block; HEIGHT: 240px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5483747745941817282" border="0" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYkZf1weoPsghCcQAUaTQnF255HqGOkSPGExXed9Zv0QG-Brrk7_oGBzjwMhmxxICKxUbyx0ahJftrqKvP89lU2YuilHJCxaPgyVzouGGFpazx-zGgL9q0LUdRBL07H-KasQsuI2aCzHE-/s320/P1050117.JPG" /><br /><div>Using the two way switch allowed me to reverse the flow of current at will, but the wiring was a little weird. The two center leads go to the main power and ground source. The top and bottom leads are then crossed and spliced (ie. top left and bottom right leads are wired seperately and then spliced together. 2 input, 1 output). Now there are a total of four wires the two from the center that will connect to the battery and the two top and bottom wires that will connect to the motor. The wiring is a little unrefined at the moment but once everything is connected you should be able to move the motor using the switch. </div><br /><div><strong><u>Step Three:</u></strong></div><br /><div>Once the motor was in place and operational I created two light bars using five LED's each. The LED's were wired in series so they would terminate in a single positive and single negative lead per light bar. I made sure to leave enough extra wire as these light bars will be attached to the upper portion of the case and will be moving up and down roughly 12". One of the problems I had once the LEDs were installed was controlling the brightness. I felt as though the lights were underpowered and were not shining as brightly as they could. </div><div><br /></div><img style="TEXT-ALIGN: center; MARGIN: 0px auto 10px; WIDTH: 320px; DISPLAY: block; HEIGHT: 240px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5483746208816110594" border="0" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbzGRrXnjzwYoEgqbha5k2Bvstwmo-f1n5xw-qutvgTVwe2LiqRlxBGyfGp9zpLNdx5J4AlGQEUxmuqr5OxDNc1NKfRDZR6wqEIItZqlyPelilV0I-E5fuHVuDp1Lm8EfsqXPEne5Uuvus/s320/P1050115.JPG" /><br /><div></div><div><strong><u>Step Four:</u></strong></div><br /><div>Now that the wiring was pretty much complete I created two face plates one for the upper and lower case. I created a simple face plate using some basswood and corrugated plastic but you can use any number of materials and turn it into a type of infill excercise. I plan on playing around with this part alot more. </div><br /><img style="TEXT-ALIGN: center; MARGIN: 0px auto 10px; WIDTH: 320px; DISPLAY: block; HEIGHT: 240px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5483745390085082866" border="0" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7Aacaze0pl6bOnU7G6mcacDpU5dpR_0B2kSgwZ4TaBDrJGVhB28bAXpLHwDJlL1E5QvPlVNf8uMzTzud2vM_PB58Is9a47_3JESafB79LrL_udsGnYkeXTemifv4ZATk75crfSf6RxNJW/s320/P1050126.JPG" /><br /><div></div><div><strong><u>Step Five:</u></strong></div><br /><div>Now that everything has been assembled I created the following circuit to controll the LEDS through the Arduino board using a photosensor.<br /></div><br /><ul><li>LED 1 and LED 2 connected from digital pin 9 to ground</li><li>Photoresistor attached from analog pin 0 to ground</li><li>10k ohm resistor attached from analog pin 0 to ground</li></ul><img style="TEXT-ALIGN: center; MARGIN: 0px auto 10px; WIDTH: 320px; DISPLAY: block; HEIGHT: 240px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5483744671267721586" border="0" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEife717WwDfbp5YXzxsY3CeL_scqH7YljnjohSW8afah53rVWJLU0s-B-5mWB3ZKv8B5qAWV_k745Zfetu_5FdwvgO2ipVQkTxCOoTypoUI0rFB20kl1sgCFwC_Z7NPGJQ6C2tma-vPvW47/s320/P1050123.JPG" /><br /><div><strong><u>Step Six:</u></strong></div><br /><div>Once the circuit has been created I used the following code to control the lights</div><div></div><div><span style="font-family:arial;"></span></div><br /><div><span style="font-family:arial;">//Program to control LED through Photoresistor</span></div><div><span style="font-family:arial;">//brightness specified by the value of the analog input</span></div><div><span style="font-family:arial;">// as the environnment gets darker the LEDs get brighter</span></div><br /><div><span style="font-family:arial;"></span></div><div><span style="font-family:arial;"></span></div><div><span style="font-family:arial;">int val = 0; // variable used to store the value coming from the sensor</span></div><div><span style="font-family:arial;">int LED = 9; // defines digital pin 9 as LED</span></div><div><span style="font-family:arial;"></span></div><br /><div><span style="font-family:arial;">void setup() {</span></div><div><span style="font-family:arial;">pinMode(LED, OUTPUT); // defines LED pin as output</span></div><div><span style="font-family:arial;">}</span></div><br /><div><span style="font-family:arial;"></span></div><div><span style="font-family:arial;">void </span><span style="font-family:arial;">loop() {</span></div><div><span style="font-family:arial;">val = analogRead(0);// read the value from the sensor</span></div><div><span style="font-family:arial;">analogeWrite(LED, 15000/val); //makes brightness of LED dependant on analog input</span></div><div><span style="font-family:arial;">// as "val" increases power output decreases</span></div><div><span style="font-family:arial;">delay(10); // stops the program for a period of time</span></div><div><span style="font-family:arial;">}</span></div><br /><div></div><div>This code worked pretty well but there were a couple things I couldnt figure out. I wanted to install a button so that when the lamp was fully open it would hold this button and initiate the lights until it is let go however I couldnt get the button to work with the photosensor the way I wanted it to. In the end I eliminated the button for the sake of time but it is something I hope to revisit with some assistance.</div><div></div><br /><div><img style="TEXT-ALIGN: center; MARGIN: 0px auto 10px; WIDTH: 240px; DISPLAY: block; HEIGHT: 320px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5483739920194067202" border="0" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEha61EBSJrOoHChVwbDetrl-5sOsdcBfalboQunrDt196SrEP1rS0UdDgVGG08XdZUn-X-laeYIYIQsTnHVWpWvAO64nr5iQ-gVPX92CGzJtO0tzCYgIJO-runbS8ZzqR_2b4U-hlRmdJEL/s320/P1050128.JPG" /></div></div></div></div></div></div></div></div></div></div></div></div></div></div>Francarlos Riverahttp://www.blogger.com/profile/10628654557259991059noreply@blogger.com0tag:blogger.com,1999:blog-1517502174619044894.post-47039662934297870872010-06-15T06:19:00.000-07:002010-06-15T06:19:00.654-07:00Distance Sensing LampI built is quick demonstration piece for class today. I wanted to show how you can use a RGB led along with a proximity sensor to create a dynamic experience. I built a lamp that changes colors the closer someone stands to it.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi04kfj9Vxxi5eszzkpS1o6Nm0A09ZwLTzaB8aOOpKvfV7uR36gLk7tFaST7euCCHY3ACe8wQyJTnOJHxSBxNnHLbl3aGp62dqcyfwbA3DBzJrFxLquWVmrBqgJEtN-ZyMTu7oDQV4sCuhr/s1600/IMG_0111.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi04kfj9Vxxi5eszzkpS1o6Nm0A09ZwLTzaB8aOOpKvfV7uR36gLk7tFaST7euCCHY3ACe8wQyJTnOJHxSBxNnHLbl3aGp62dqcyfwbA3DBzJrFxLquWVmrBqgJEtN-ZyMTu7oDQV4sCuhr/s320/IMG_0111.jpg" /></a> </div><div class="separator" style="clear: both; text-align: center;">High Power LED and Proximity Sensor in the Box</div><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiX1to7s_57q7SxpVkxRfSsqFOVV14S1my9100IO7DZ4rk4_5vB0nwBkGxZuDoBq_n2790oZvVsJ8OjRYSIuMbDn7tD2fXbd8oahARj60agVBxWVrR7TjHJcoqdLzpGfdCV3z3PRY3IYm96/s1600/IMG_0100.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiX1to7s_57q7SxpVkxRfSsqFOVV14S1my9100IO7DZ4rk4_5vB0nwBkGxZuDoBq_n2790oZvVsJ8OjRYSIuMbDn7tD2fXbd8oahARj60agVBxWVrR7TjHJcoqdLzpGfdCV3z3PRY3IYm96/s320/IMG_0100.jpg" /></a><br />
Light is blue, something is close to the sensor<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHIQCWXpL4TCetLHAbffecVPFGczbBjyxhh10VE1p5doh9rTfDgZjhyphenhyphen5aL52mhzWNnV_EphZmJeT7pqBikpfZEQGewQq5t8IGO0aR2-rnl4jrnUztRV0UOJO5fbbCbN7Ysxi1C6liIVW9X/s1600/IMG_0105.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHIQCWXpL4TCetLHAbffecVPFGczbBjyxhh10VE1p5doh9rTfDgZjhyphenhyphen5aL52mhzWNnV_EphZmJeT7pqBikpfZEQGewQq5t8IGO0aR2-rnl4jrnUztRV0UOJO5fbbCbN7Ysxi1C6liIVW9X/s320/IMG_0105.jpg" /></a><br />
Light is pink, something is nearby, but not as close<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRUj6k6JCqGQIQ97FRoej25y5xofrIFO-XSzvZeb7qfDytueyOnubKPExX-CNJTPuShR0_TghzLZHuSvAJ8AvCf3I50mdPpMHGGqz4-1PrmXVal_gT-Z3ZrCInGXWFpIxomQyx_4G8eUA6/s1600/IMG_0109.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRUj6k6JCqGQIQ97FRoej25y5xofrIFO-XSzvZeb7qfDytueyOnubKPExX-CNJTPuShR0_TghzLZHuSvAJ8AvCf3I50mdPpMHGGqz4-1PrmXVal_gT-Z3ZrCInGXWFpIxomQyx_4G8eUA6/s320/IMG_0109.jpg" /></a><br />
The arduino wired up<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhn82PiaQIWBm8HeNWWy0cU0k64B1k9FGx5U-FWDdTQ7le3PAMiagSI9-5x_YzcPyWLGAfP9usWetWqDQ2CzziCyHu3sLFghVnN0vTSpZKrmIyQBkH3iu2vJb7a_QO6rUO_LrJR6qF_WXNk/s1600/IMG_0099.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhn82PiaQIWBm8HeNWWy0cU0k64B1k9FGx5U-FWDdTQ7le3PAMiagSI9-5x_YzcPyWLGAfP9usWetWqDQ2CzziCyHu3sLFghVnN0vTSpZKrmIyQBkH3iu2vJb7a_QO6rUO_LrJR6qF_WXNk/s320/IMG_0099.jpg" /></a><br />
Close up of the sensor<br />
<br />
Here is the code being used<br />
<pre>
<span style="color: #CC6600;">int</span> proxypin1 = 4;
<span style="color: #CC6600;">int</span> common_anode = 8;
<span style="color: #CC6600;">int</span> red_pin = 9;
<span style="color: #CC6600;">int</span> blue_pin = 11;
<span style="color: #CC6600;">int</span> green_pin = 10;
<span style="color: #CC6600;">int</span> red_min = 0;
<span style="color: #CC6600;">int</span> red_max = 255;
<span style="color: #CC6600;">int</span> blue_min = 0;
<span style="color: #CC6600;">int</span> blue_max = 180;
<span style="color: #CC6600;">int</span> green_min = 0;
<span style="color: #CC6600;">int</span> green_max = 180;
<span style="color: #CC6600;">void</span> hsv_to_rgb(<span style="color: #CC6600;">float</span> h, <span style="color: #CC6600;">float</span> s, <span style="color: #CC6600;">float</span> v, <span style="color: #CC6600;">unsigned</span> <span style="color: #CC6600;">char</span> *rc, <span style="color: #CC6600;">unsigned</span> <span style="color: #CC6600;">char</span> *gc, <span style="color: #CC6600;">unsigned</span> <span style="color: #CC6600;">char</span> *bc) {
<span style="color: #CC6600;">int</span> h_i = ((<span style="color: #CC6600;">int</span>)(h/60)) % 6;
<span style="color: #CC6600;">float</span> f = (h/60) - (<span style="color: #CC6600;">int</span>)(h/60);
<span style="color: #CC6600;">float</span> r,g,b;
<span style="color: #CC6600;">float</span> p = v * (1.0 - s);
<span style="color: #CC6600;">float</span> q = v * (1.0 - f*s);
<span style="color: #CC6600;">float</span> t = (1.0 - (1.0 - f)*s);
<span style="color: #CC6600;">switch</span>(h_i) {
<span style="color: #CC6600;">case</span> 0: r = v; g = t; b = p; <span style="color: #CC6600;">break</span>;
<span style="color: #CC6600;">case</span> 1: r = q; g = v; b = p; <span style="color: #CC6600;">break</span>;
<span style="color: #CC6600;">case</span> 2: r = p; g = v; b = t; <span style="color: #CC6600;">break</span>;
<span style="color: #CC6600;">case</span> 3: r = p; g = q; b = v; <span style="color: #CC6600;">break</span>;
<span style="color: #CC6600;">case</span> 4: r = t; g = p; b = v; <span style="color: #CC6600;">break</span>;
<span style="color: #CC6600;">case</span> 5: r = v; g = p; b = q; <span style="color: #CC6600;">break</span>;
}
*rc = red_max - (<span style="color: #CC6600;">char</span>)((red_max - red_min)*r);
*gc = green_max - (<span style="color: #CC6600;">char</span>)((green_max - green_min)*g);
*bc = blue_max - (<span style="color: #CC6600;">char</span>)((blue_max - blue_min)*b);
}
<span style="color: #CC6600;">void</span> <span style="color: #CC6600;"><b>setup</b></span>() {
<span style="color: #CC6600;">pinMode</span>(common_anode, <span style="color: #006699;">OUTPUT</span>);
<span style="color: #CC6600;">digitalWrite</span>(common_anode, <span style="color: #006699;">HIGH</span>);
<span style="color: #CC6600;">pinMode</span>(red_pin, <span style="color: #006699;">OUTPUT</span>);
<span style="color: #CC6600;">digitalWrite</span>(red_pin, <span style="color: #006699;">HIGH</span>);
<span style="color: #CC6600;">pinMode</span>(green_pin, <span style="color: #006699;">OUTPUT</span>);
<span style="color: #CC6600;">digitalWrite</span>(green_pin, <span style="color: #006699;">HIGH</span>);
<span style="color: #CC6600;">pinMode</span>(blue_pin, <span style="color: #006699;">OUTPUT</span>);
<span style="color: #CC6600;">digitalWrite</span>(blue_pin, <span style="color: #006699;">HIGH</span>);
<span style="color: #CC6600;">pinMode</span>(proxypin1, <span style="color: #006699;">INPUT</span>);
<span style="color: #CC6600;"><b>Serial</b></span>.<span style="color: #CC6600;">begin</span>(9600);
}
<span style="color: #CC6600;">float</span> h = 0.0;
<span style="color: #CC6600;">float</span> s = 1.0;
<span style="color: #CC6600;">float</span> v = 0.8;
<span style="color: #CC6600;">int</span> pulse;
<span style="color: #CC6600;">int</span> distance1;
<span style="color: #CC6600;">byte</span> maxdistance = 250;
<span style="color: #CC6600;">void</span> <span style="color: #CC6600;"><b>loop</b></span>() {
<span style="color: #CC6600;">unsigned</span> <span style="color: #CC6600;">char</span> r,g,b;
<span style="color: #CC6600;">for</span>(<span style="color: #CC6600;">int</span> i=0;i<2;i++){
pulse = <span style="color: #CC6600;">pulseIn</span>(proxypin1, <span style="color: #006699;">HIGH</span>);
distance1 += pulse/147;
}
distance1 /= 2;
<span style="color: #CC6600;"><b>Serial</b></span>.<span style="color: #CC6600;">print</span>(distance1,<span style="color: #006699;">DEC</span>);
<span style="color: #CC6600;"><b>Serial</b></span>.<span style="color: #CC6600;">print</span>(10,<span style="color: #006699;">BYTE</span>);
hsv_to_rgb(<span style="color: #CC6600;">map</span>(<span style="color: #CC6600;">constrain</span>(distance1,6,maxdistance),6,maxdistance,0,359),s,v, &r,&g,&b);
distance1 = 0;
<span style="color: #7E7E7E;">//analogWrite(red_pin, 0);</span>
<span style="color: #CC6600;">analogWrite</span>(red_pin, r);
<span style="color: #CC6600;">analogWrite</span>(green_pin, g);
<span style="color: #7E7E7E;">//analogWrite(green_pin, 0);</span>
<span style="color: #CC6600;">analogWrite</span>(blue_pin, b);
<span style="color: #7E7E7E;">//analogWrite(blue_pin, 255);</span>
<span style="color: #CC6600;">delay</span>(100);
}
</pre><br />
Matthewhttp://www.blogger.com/profile/05818659732501156825noreply@blogger.com0tag:blogger.com,1999:blog-1517502174619044894.post-7944817565857277902010-06-15T04:25:00.000-07:002010-07-22T04:43:15.161-07:00Light Snake FailureBefore I succeeded I had several failures. My first attempt at creating a light project involved stripping a coaxial cable to its individual parts.<br /><br /><a href="http://www.flickr.com/photos/52257338@N06/4818082222/" title="Coaxial-Cable by DBAPOZER, on Flickr"><img src="http://farm5.static.flickr.com/4075/4818082222_da2fe69759.jpg" width="400" height="300" alt="Coaxial-Cable" /></a><br /><br />I then dissected the internal cable into segements to use as a power wire .<br /><br /><a href="http://www.flickr.com/photos/52257338@N06/4813820331/" title="Light Snake by DBAPOZER, on Flickr"><img src="http://farm5.static.flickr.com/4078/4813820331_97db616782.jpg" width="375" height="500" alt="Light Snake" /></a><br /><br />The next step was to solder an led to each segment and encase it in hot glue while leaving the ground exposed<br /><br /><a href="http://www.flickr.com/photos/52257338@N06/4813820367/" title="Light Snake1 by DBAPOZER, on Flickr"><img src="http://farm5.static.flickr.com/4119/4813820367_089b98ea3c.jpg" width="375" height="500" alt="Light Snake1" /></a><br /><br />I attempted to use the wire mesh as a ground casing, but failed. It couldn't carry the current well enough.<br /><br /><a href="http://www.flickr.com/photos/52257338@N06/4814442158/" title="Light Snake2 by DBAPOZER, on Flickr"><img src="http://farm5.static.flickr.com/4122/4814442158_196b846bd6.jpg" width="375" height="500" alt="Light Snake2" /></a><br /><br />I cut off the mesh and tried to wrap a braided copper wire (stolen from a lamp by the dumpster) to use as the ground instead. It worked!<br /><br /><a href="http://www.flickr.com/photos/52257338@N06/4813820501/" title="Light Snake4 by DBAPOZER, on Flickr"><img src="http://farm5.static.flickr.com/4140/4813820501_08e719ceb5.jpg" width="375" height="500" alt="Light Snake4" /></a><br /><br />I wasn't happy with the brightness of the led's, so I gave them <span style="font-weight: bold;">nine</span> volts. "<span style="font-style: italic;">crackle pop pip zap"</span> dead.....time to try againMEACHAMhttp://www.blogger.com/profile/12770196583094702925noreply@blogger.com0tag:blogger.com,1999:blog-1517502174619044894.post-32822361032149733482010-06-14T19:40:00.000-07:002010-06-14T19:44:12.661-07:00FrustratedGrrrr! this is frustrating.... I fried my first attempt at an interactive light project,(gave it too much power and shorted out the leds). Now my servo wont work right. It sounds like it wants to turn but then doesn't, it just growns. This was fun now I'm frustrated.MEACHAMhttp://www.blogger.com/profile/12770196583094702925noreply@blogger.com2tag:blogger.com,1999:blog-1517502174619044894.post-48667410766619255922010-06-09T20:15:00.000-07:002010-06-09T23:11:39.248-07:00First ProjectMy first project I've been working on is playing with a RFID Card Reader. I hope to build a device that can unlock a door when a valid card is read.<br />
<br />
Here is the Code I'm using<br />
<br />
<pre><span style="color: #7e7e7e;">/**</span>
<span style="color: #7e7e7e;">* RFID Access Control Single</span>
<span style="color: #7e7e7e;">*</span>
<span style="color: #7e7e7e;">* This project implements a single stand-alone RFID access control</span>
<span style="color: #7e7e7e;">* system that can operate independently of a host computer or any</span>
<span style="color: #7e7e7e;">* other device. It uses either an ID-12 RFID reader module from ID</span>
<span style="color: #7e7e7e;">* Innovations or an RDM630 RFID reader module from Seeed Studio to</span>
<span style="color: #7e7e7e;">* scan for 125KHz RFID tags, and when a recognised tag is identified</span>
<span style="color: #7e7e7e;">* it toggles an output for a configurable duration, typically 2</span>
<span style="color: #7e7e7e;">* seconds. The output can then be used to control a relay to trip an</span>
<span style="color: #7e7e7e;">* electric striker plate to release a door lock.</span>
<span style="color: #7e7e7e;">*</span>
<span style="color: #7e7e7e;">* Because this project is intended to provide a minimal working system</span>
<span style="color: #7e7e7e;">* it does not have any provision for database updates to be managed</span>
<span style="color: #7e7e7e;">* externally from a host, so updates to the accepted cards must be</span>
<span style="color: #7e7e7e;">* made by changing the values in the code, recompiling the program,</span>
<span style="color: #7e7e7e;">* and re-uploading it to the Arduino. It does however report card</span>
<span style="color: #7e7e7e;">* readings (both successful and unsuccessful) via the serial</span>
<span style="color: #7e7e7e;">* connection so you can monitor the system using a connected computer.</span>
<span style="color: #7e7e7e;">*</span>
<span style="color: #7e7e7e;">* Some of this code was inspired by Tom Igoe's excellent RFID tutorial</span>
<span style="color: #7e7e7e;">* which is detailed on his blog at:</span>
<span style="color: #7e7e7e;">* http://www.tigoe.net/pcomp/code/category/PHP/347</span>
<span style="color: #7e7e7e;">* And also from the ID-12 example code on the Arduino Playground at:</span>
<span style="color: #7e7e7e;">* http://www.arduino.cc/playground/Code/ID12</span>
<span style="color: #7e7e7e;">*</span>
<span style="color: #7e7e7e;">* Copyright Jonathan Oxer <jon@oxer.com.au></jon@oxer.com.au></span>
<span style="color: #7e7e7e;">* http://www.practicalarduino.com/projects/medium/rfid-access-control</span>
<span style="color: #7e7e7e;">* Code From http://github.com/practicalarduino/RFIDAccessControlSingle/blob/1d6c42ae53e199269acb0234ad6c3dc784c51f41/RFIDAccessControlSingle.pde</span>
<span style="color: #7e7e7e;">*/</span>
<span style="color: #7e7e7e;">// Set up the serial connection to the RFID reader module. The module's</span>
<span style="color: #7e7e7e;">// TX pin needs to be connected to RX (pin 4) on the Arduino. Module</span>
<span style="color: #7e7e7e;">// RX doesn't need to be connected to anything since we won't send</span>
<span style="color: #7e7e7e;">// commands to it, but SoftwareSerial requires us to define a pin for</span>
<span style="color: #7e7e7e;">// TX anyway so you can either connect module RX to Arduino TX or just</span>
<span style="color: #7e7e7e;">// leave them disconnected.</span>
#include <<span style="color: #cc6600;">SoftwareSerial</span>.h>
#define rxPin 4
#define txPin 5
<span style="color: #7e7e7e;">// Create a software serial object for the connection to the RFID module</span>
<span style="color: #cc6600;">SoftwareSerial</span> rfid = <span style="color: #cc6600;">SoftwareSerial</span>( rxPin, txPin );
<span style="color: #7e7e7e;">// Set up outputs</span>
#define strikePlate 12 <span style="color: #7e7e7e;">// Output pin connected to door lock</span>
#define ledPin 13 <span style="color: #7e7e7e;">// LED status output</span>
#define unlockSeconds 2 <span style="color: #7e7e7e;">// Seconds to hold door lock open</span>
<span style="color: #7e7e7e;">// The tag database consists of two parts. The first part is an array of</span>
<span style="color: #7e7e7e;">// tag values with each tag taking up 5 bytes. The second is a list of</span>
<span style="color: #7e7e7e;">// names with one name for each tag (ie: group of 5 bytes).</span>
<span style="color: #cc6600;">char</span>* allowedTags[] = {
<span style="color: #006699;">"460071B072"</span>, <span style="color: #7e7e7e;">// Tag 1</span>
<span style="color: #006699;">"04146E8BDD"</span>, <span style="color: #7e7e7e;">// Tag 2</span>
<span style="color: #006699;">"0413BBBF23"</span>, <span style="color: #7e7e7e;">// Tag 3</span>
};
<span style="color: #7e7e7e;">// List of names to associate with the matching tag IDs</span>
<span style="color: #cc6600;">char</span>* tagName[] = {
<span style="color: #006699;">"Matthew Doll"</span>, <span style="color: #7e7e7e;">// Tag 1</span>
<span style="color: #006699;">"Hugh Blemings"</span>, <span style="color: #7e7e7e;">// Tag 2</span>
<span style="color: #006699;">"Dexter D Dog"</span>, <span style="color: #7e7e7e;">// Tag 3</span>
};
#define redPin 9
#define greenPin 10
#define bluePin 11
#include <<span style="color: #cc6600;">Servo</span>.h>
<span style="color: #cc6600;">Servo</span> doorLock;
<span style="color: #7e7e7e;">// Check the number of tags defined</span>
<span style="color: #cc6600;">int</span> numberOfTags = sizeof(allowedTags)/sizeof(allowedTags[0]);
<span style="color: #cc6600;">int</span> incomingByte = 0; <span style="color: #7e7e7e;">// To store incoming serial data</span>
<span style="color: #7e7e7e;">/**</span>
<span style="color: #7e7e7e;">* Setup</span>
<span style="color: #7e7e7e;">*/</span>
<span style="color: #cc6600;">void</span> <span style="color: #cc6600;"><b>setup</b></span>() {
<span style="color: #cc6600;">pinMode</span>(redPin, <span style="color: #006699;">OUTPUT</span>);
<span style="color: #cc6600;">pinMode</span>(greenPin, <span style="color: #006699;">OUTPUT</span>);
<span style="color: #cc6600;">pinMode</span>(bluePin, <span style="color: #006699;">OUTPUT</span>);
<span style="color: #cc6600;">digitalWrite</span>(redPin, <span style="color: #006699;">LOW</span>);
<span style="color: #cc6600;">digitalWrite</span>(greenPin, <span style="color: #006699;">HIGH</span>);
<span style="color: #cc6600;">digitalWrite</span>(bluePin, <span style="color: #006699;">HIGH</span>);
<span style="color: #cc6600;"><b>Serial</b></span>.<span style="color: #cc6600;">begin</span>(38400); <span style="color: #7e7e7e;">// Serial port for connection to host</span>
rfid.<span style="color: #cc6600;">begin</span>(9600); <span style="color: #7e7e7e;">// Serial port for connection to RFID module</span>
doorLock.<span style="color: #cc6600;">attach</span>(2);
<span style="color: #cc6600;"><b>Serial</b></span>.<span style="color: #cc6600;">println</span>(<span style="color: #006699;">"RFID reader starting up"</span>);
}
<span style="color: #7e7e7e;">/**</span>
<span style="color: #7e7e7e;">* Loop</span>
<span style="color: #7e7e7e;">*/</span>
<span style="color: #cc6600;">void</span> <span style="color: #cc6600;"><b>loop</b></span>() {
<span style="color: #cc6600;">byte</span> i = 0;
<span style="color: #cc6600;">byte</span> val = 0;
<span style="color: #cc6600;">byte</span> checksum = 0;
<span style="color: #cc6600;">byte</span> bytesRead = 0;
<span style="color: #cc6600;">byte</span> tempByte = 0;
<span style="color: #cc6600;">byte</span> tagBytes[6]; <span style="color: #7e7e7e;">// "Unique" tags are only 5 bytes but we need an extra byte for the checksum</span>
<span style="color: #cc6600;">char</span> tagValue[10];
<span style="color: #7e7e7e;">// Read from the RFID module. Because this connection uses SoftwareSerial</span>
<span style="color: #7e7e7e;">// there is no equivalent to the Serial.available() function, so at this</span>
<span style="color: #7e7e7e;">// point the program blocks while waiting for a value from the module</span>
<span style="color: #cc6600;">if</span>((val = rfid.<span style="color: #cc6600;">read</span>()) == 2) { <span style="color: #7e7e7e;">// Check for header</span>
bytesRead = 0;
<span style="color: #cc6600;">while</span> (bytesRead < 12) { <span style="color: #7e7e7e;">// Read 10 digit code + 2 digit checksum</span>
val = rfid.<span style="color: #cc6600;">read</span>();
<span style="color: #7e7e7e;">// Append the first 10 bytes (0 to 9) to the raw tag value</span>
<span style="color: #cc6600;">if</span> (bytesRead < 10)
{
tagValue[bytesRead] = val;
}
<span style="color: #7e7e7e;">// Check if this is a header or stop byte before the 10 digit reading is complete</span>
<span style="color: #cc6600;">if</span>((val == 0x0D)||(val == 0x0A)||(val == 0x03)||(val == 0x02)) {
<span style="color: #cc6600;">break</span>; <span style="color: #7e7e7e;">// Stop reading</span>
}
<span style="color: #7e7e7e;">// Ascii/Hex conversion:</span>
<span style="color: #cc6600;">if</span> ((val >= <span style="color: #006699;">'0'</span>) && (val <= <span style="color: #006699;">'9'</span>)) {
val = val - <span style="color: #006699;">'0'</span>;
}
<span style="color: #cc6600;">else</span> <span style="color: #cc6600;">if</span> ((val >= <span style="color: #006699;">'A'</span>) && (val <= <span style="color: #006699;">'F'</span>)) {
val = 10 + val - <span style="color: #006699;">'A'</span>;
}
<span style="color: #7e7e7e;">// Every two hex-digits, add a byte to the code:</span>
<span style="color: #cc6600;">if</span> (bytesRead & 1 == 1) {
<span style="color: #7e7e7e;">// Make space for this hex-digit by shifting the previous digit 4 bits to the left</span>
tagBytes[bytesRead >> 1] = (val | (tempByte << 4));
<span style="color: #cc6600;">if</span> (bytesRead >> 1 != 5) { <span style="color: #7e7e7e;">// If we're at the checksum byte,</span>
checksum ^= tagBytes[bytesRead >> 1]; <span style="color: #7e7e7e;">// Calculate the checksum... (XOR)</span>
};
} <span style="color: #cc6600;">else</span> {
tempByte = val; <span style="color: #7e7e7e;">// Store the first hex digit first</span>
};
bytesRead++; <span style="color: #7e7e7e;">// Ready to read next digit</span>
}
<span style="color: #7e7e7e;">// Send the result to the host connected via USB</span>
<span style="color: #cc6600;">if</span> (bytesRead == 12) { <span style="color: #7e7e7e;">// 12 digit read is complete</span>
tagValue[10] = <span style="color: #006699;">'\0'</span>; <span style="color: #7e7e7e;">// Null-terminate the string</span>
<span style="color: #cc6600;"><b>Serial</b></span>.<span style="color: #cc6600;">print</span>(<span style="color: #006699;">"Tag read: "</span>);
<span style="color: #cc6600;">for</span> (i=0; i<5; i++) {
<span style="color: #7e7e7e;">// Add a leading 0 to pad out values below 16</span>
<span style="color: #cc6600;">if</span> (tagBytes[i] < 16) {
<span style="color: #cc6600;"><b>Serial</b></span>.<span style="color: #cc6600;">print</span>(<span style="color: #006699;">"0"</span>);
}
<span style="color: #cc6600;"><b>Serial</b></span>.<span style="color: #cc6600;">print</span>(tagBytes[i], <span style="color: #006699;">HEX</span>);
}
<span style="color: #cc6600;"><b>Serial</b></span>.<span style="color: #cc6600;">println</span>();
<span style="color: #cc6600;"><b>Serial</b></span>.<span style="color: #cc6600;">print</span>(<span style="color: #006699;">"Checksum: "</span>);
<span style="color: #cc6600;"><b>Serial</b></span>.<span style="color: #cc6600;">print</span>(tagBytes[5], <span style="color: #006699;">HEX</span>);
<span style="color: #cc6600;">if</span>(tagBytes[5] != checksum){
<span style="color: #cc6600;"><b>Serial</b></span>.<span style="color: #cc6600;">println</span>( <span style="color: #006699;">" -- error."</span>);
<span style="color: #cc6600;">for</span>(i = 0;i < 10;i++) {
<span style="color: #cc6600;">digitalWrite</span>(greenPin, <span style="color: #006699;">LOW</span>);
<span style="color: #7e7e7e;">//digitalWrite(redPin, HIGH);</span>
<span style="color: #cc6600;">delay</span>(100);
<span style="color: #cc6600;">digitalWrite</span>(greenPin, <span style="color: #006699;">HIGH</span>);
<span style="color: #7e7e7e;">// digitalWrite(redPin, LOW);</span>
<span style="color: #cc6600;">delay</span>(100);
}
} <span style="color: #cc6600;">else</span> {
<span style="color: #cc6600;"><b>Serial</b></span>.<span style="color: #cc6600;">println</span>(<span style="color: #006699;">" -- passed."</span>);
<span style="color: #7e7e7e;">// Show the raw tag value</span>
<span style="color: #7e7e7e;">//Serial.print("VALUE: ");</span>
<span style="color: #7e7e7e;">//Serial.println(tagValue);</span>
<span style="color: #7e7e7e;">// Search the tag database for this particular tag</span>
<span style="color: #cc6600;">int</span> tagId = findTag( tagValue );
<span style="color: #7e7e7e;">// Only fire the strike plate if this tag was found in the database</span>
<span style="color: #7e7e7e;">/**</span>
<span style="color: #7e7e7e;"> color test</span>
<span style="color: #7e7e7e;"> */</span>
<span style="color: #cc6600;">if</span>(strcmp(tagValue, <span style="color: #006699;">"3B00329D9D"</span>) == 0) { <span style="color: #7e7e7e;">//blue</span>
<span style="color: #cc6600;">digitalWrite</span>(redPin, <span style="color: #006699;">HIGH</span>);
<span style="color: #cc6600;">digitalWrite</span>(greenPin, <span style="color: #006699;">HIGH</span>);
<span style="color: #cc6600;">digitalWrite</span>(bluePin, <span style="color: #006699;">LOW</span>);
<span style="color: #cc6600;">delay</span>(2000);
<span style="color: #cc6600;">digitalWrite</span>(redPin, <span style="color: #006699;">LOW</span>);
<span style="color: #cc6600;">digitalWrite</span>(greenPin, <span style="color: #006699;">HIGH</span>);
<span style="color: #cc6600;">digitalWrite</span>(bluePin, <span style="color: #006699;">HIGH</span>);
} <span style="color: #cc6600;">else</span> <span style="color: #cc6600;">if</span> (strcmp(tagValue, <span style="color: #006699;">"3B00113511"</span>) == 0) {
<span style="color: #cc6600;">digitalWrite</span>(redPin, <span style="color: #006699;">LOW</span>);
<span style="color: #cc6600;">digitalWrite</span>(greenPin, <span style="color: #006699;">LOW</span>);
<span style="color: #cc6600;">digitalWrite</span>(bluePin, <span style="color: #006699;">HIGH</span>);
<span style="color: #cc6600;">delay</span>(2000);
<span style="color: #cc6600;">digitalWrite</span>(redPin, <span style="color: #006699;">LOW</span>);
<span style="color: #cc6600;">digitalWrite</span>(greenPin, <span style="color: #006699;">HIGH</span>);
<span style="color: #cc6600;">digitalWrite</span>(bluePin, <span style="color: #006699;">HIGH</span>);
} <span style="color: #cc6600;">else</span> {
<span style="color: #cc6600;">int</span> tagId = findTag( tagValue );
<span style="color: #cc6600;">if</span>( tagId > 0 )
{
<span style="color: #cc6600;"><b>Serial</b></span>.<span style="color: #cc6600;">print</span>(<span style="color: #006699;">"Authorized tag ID "</span>);
<span style="color: #cc6600;"><b>Serial</b></span>.<span style="color: #cc6600;">print</span>(tagId);
<span style="color: #cc6600;"><b>Serial</b></span>.<span style="color: #cc6600;">print</span>(<span style="color: #006699;">": unlocking for "</span>);
<span style="color: #cc6600;"><b>Serial</b></span>.<span style="color: #cc6600;">println</span>(tagName[tagId - 1]); <span style="color: #7e7e7e;">// Get the name for this tag from the database</span>
unlock(); <span style="color: #7e7e7e;">// Fire the strike plate to open the lock</span>
} <span style="color: #cc6600;">else</span> {
<span style="color: #cc6600;"><b>Serial</b></span>.<span style="color: #cc6600;">println</span>(<span style="color: #006699;">"Tag not authorized"</span>);
<span style="color: #7e7e7e;">//blink red</span>
<span style="color: #cc6600;">for</span>(i = 0;i < 10;i++) {
<span style="color: #cc6600;">digitalWrite</span>(redPin, <span style="color: #006699;">HIGH</span>);
<span style="color: #cc6600;">delay</span>(100);
<span style="color: #cc6600;">digitalWrite</span>(redPin, <span style="color: #006699;">LOW</span>);
<span style="color: #cc6600;">delay</span>(100);
}
}
<span style="color: #cc6600;"><b>Serial</b></span>.<span style="color: #cc6600;">println</span>(); <span style="color: #7e7e7e;">// Blank separator line in output</span>
}
}
}
bytesRead = 0;
}
}
<span style="color: #7e7e7e;">/**</span>
<span style="color: #7e7e7e;">* Fire the relay to activate the strike plate for the configured</span>
<span style="color: #7e7e7e;">* number of seconds.</span>
<span style="color: #7e7e7e;">*/</span>
<span style="color: #cc6600;">void</span> unlock() {
doorLock.<span style="color: #cc6600;">write</span>(0);
<span style="color: #cc6600;">digitalWrite</span>(redPin, <span style="color: #006699;">HIGH</span>);
<span style="color: #cc6600;">digitalWrite</span>(greenPin, <span style="color: #006699;">LOW</span>);
<span style="color: #cc6600;">digitalWrite</span>(bluePin, <span style="color: #006699;">HIGH</span>);
<span style="color: #cc6600;">delay</span>(unlockSeconds * 1000);
doorLock.<span style="color: #cc6600;">write</span>(120);
<span style="color: #cc6600;">digitalWrite</span>(redPin, <span style="color: #006699;">LOW</span>);
<span style="color: #cc6600;">digitalWrite</span>(greenPin, <span style="color: #006699;">HIGH</span>);
<span style="color: #cc6600;">digitalWrite</span>(bluePin, <span style="color: #006699;">HIGH</span>);
}
<span style="color: #7e7e7e;">/**</span>
<span style="color: #7e7e7e;">* Search for a specific tag in the database</span>
<span style="color: #7e7e7e;">*/</span>
<span style="color: #cc6600;">int</span> findTag( <span style="color: #cc6600;">char</span> tagValue[10] ) {
<span style="color: #cc6600;">for</span> (<span style="color: #cc6600;">int</span> thisCard = 0; thisCard < numberOfTags; thisCard++) {
<span style="color: #7e7e7e;">// Check if the tag value matches this row in the tag database</span>
<span style="color: #cc6600;">if</span>(strcmp(tagValue, allowedTags[thisCard]) == 0)
{
<span style="color: #7e7e7e;">// The row in the database starts at 0, so add 1 to the result so</span>
<span style="color: #7e7e7e;">// that the card ID starts from 1 instead (0 represents "no match")</span>
<span style="color: #cc6600;">return</span>(thisCard + 1);
}
}
<span style="color: #7e7e7e;">// If we don't find the tag return a tag ID of 0 to show there was no match</span>
<span style="color: #cc6600;">return</span>(0);
}
</pre>Matthewhttp://www.blogger.com/profile/05818659732501156825noreply@blogger.com1tag:blogger.com,1999:blog-1517502174619044894.post-20746220017436974602010-05-27T09:01:00.001-07:002010-05-27T09:01:03.780-07:00hello worldHello this is our groups blog for Digital SeminarMatthewhttp://www.blogger.com/profile/05818659732501156825noreply@blogger.com0