<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3037762074085306740</id><updated>2024-11-06T08:24:58.760+05:30</updated><category term="Line Follower"/><category term="Microcontroller"/><category term="16X2 LCD"/><category term="7805"/><category term="ADC"/><category term="DDR"/><category term="IR Sensor"/><category term="LCD"/><category term="LED"/><category term="PIN"/><category term="PORT"/><category term="Projects"/><category term="Pull up"/><category term="Switch"/><category term="Voltage Regulator"/><category term="WinAVR"/><category term="line sensor"/><category term="pull down"/><title type='text'>Techila</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://techtechila.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3037762074085306740/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://techtechila.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Ashish</name><uri>http://www.blogger.com/profile/11572695506758516927</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>18</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3037762074085306740.post-8725744282067899523</id><published>2011-10-27T13:13:00.002+05:30</published><updated>2015-12-09T11:00:34.250+05:30</updated><title type='text'>Persistence of Vision</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Our eyes have a property of persistence of vision. It means that an after-image persists even after the original image no longer exists. This after-image persists for&amp;nbsp;approximately&amp;nbsp;1/25 th of a second.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;So let&#39;s say, there are some red LED. The LED blink one after another with a gap of, say, 1 second. In this case I will be able to notice a change in the state of the LED, that is whether it is ON or OFF, as shown in the video below:&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;object class=&quot;BLOGGER-youtube-video&quot; classid=&quot;clsid:D27CDB6E-AE6D-11cf-96B8-444553540000&quot; codebase=&quot;http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0&quot; data-thumbnail-src=&quot;http://i.ytimg.com/vi/3Qhxjcr_W-E/0.jpg&quot; height=&quot;266&quot; width=&quot;320&quot;&gt;&lt;param name=&quot;movie&quot; value=&quot;http://www.youtube.com/v/3Qhxjcr_W-E?version=3&amp;f=user_uploads&amp;c=google-webdrive-0&amp;app=youtube_gdata&quot; /&gt;
&lt;param name=&quot;bgcolor&quot; value=&quot;#FFFFFF&quot; /&gt;
&lt;embed width=&quot;320&quot; height=&quot;266&quot;  src=&quot;http://www.youtube.com/v/3Qhxjcr_W-E?version=3&amp;f=user_uploads&amp;c=google-webdrive-0&amp;app=youtube_gdata&quot; type=&quot;application/x-shockwave-flash&quot;&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Now, say I reduce this time gap to about 500 milliseconds. This is what will happen:&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;iframe allowfullscreen=&#39;allowfullscreen&#39; webkitallowfullscreen=&#39;webkitallowfullscreen&#39; mozallowfullscreen=&#39;mozallowfullscreen&#39; width=&#39;320&#39; height=&#39;266&#39; src=&#39;https://www.youtube.com/embed/9RKwrQkgYWE?feature=player_embedded&#39; frameborder=&#39;0&#39;&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;If I further reduce the time gap, this is what it will look like:&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;iframe allowfullscreen=&#39;allowfullscreen&#39; webkitallowfullscreen=&#39;webkitallowfullscreen&#39; mozallowfullscreen=&#39;mozallowfullscreen&#39; width=&#39;320&#39; height=&#39;266&#39; src=&#39;https://www.youtube.com/embed/eqrKWEguupg?feature=player_embedded&#39; frameborder=&#39;0&#39;&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;In the next video the time gap is of the order of micro-seconds.&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;iframe allowfullscreen=&#39;allowfullscreen&#39; webkitallowfullscreen=&#39;webkitallowfullscreen&#39; mozallowfullscreen=&#39;mozallowfullscreen&#39; width=&#39;320&#39; height=&#39;266&#39; src=&#39;https://www.youtube.com/embed/FLDaVdP2WxE?feature=player_embedded&#39; frameborder=&#39;0&#39;&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;So, you see, in each of the above cases, I was turning ON only one LED at a time, but as the time delay between turning ON and turning OFF reduced, all the LED seemed to be ON at a time, forming the smiley figure in the last video.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;This method is used in all LED displays you might have seen, on the buses, or the railway station..etc.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Instead of the 8x8 LED matrix used above, we could also use a row of LED.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;--&amp;gt; For a single row of LED&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Look at the diagram below.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;t1, t2..t7 have units of time. So, at each t1,t2 etc, the state of the LED will change.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCStudd-adQVZ5yYiou2fhyphenhyphenxAnJ80lhUBH7ghvJDqoiaUjsvkZLh2TUqQ2cNAv1PpYNSuwB3nJx1yLSu2Q9yJ8AivGuPubXtW-cotWShFyJG1crJHyql115dZFrMNy8jwGcPhtDcdmoV4/s1600/POV.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCStudd-adQVZ5yYiou2fhyphenhyphenxAnJ80lhUBH7ghvJDqoiaUjsvkZLh2TUqQ2cNAv1PpYNSuwB3nJx1yLSu2Q9yJ8AivGuPubXtW-cotWShFyJG1crJHyql115dZFrMNy8jwGcPhtDcdmoV4/s1600/POV.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Now, to display a smiley face:&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhP1nBMtZDiS1RqZ3ppVLqYLaLaIRBA5KLHCc1zCQS703WT9-xvtPNwSX2LxyvGVhVW9gp-Kk-v1QHTZDKXP4HENsIJ6bQM5dOtTI7LFRwYsoHX-1gRhBlFsRZYbrTpCy2g2UiRyjmwZrk/s1600/POV1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhP1nBMtZDiS1RqZ3ppVLqYLaLaIRBA5KLHCc1zCQS703WT9-xvtPNwSX2LxyvGVhVW9gp-Kk-v1QHTZDKXP4HENsIJ6bQM5dOtTI7LFRwYsoHX-1gRhBlFsRZYbrTpCy2g2UiRyjmwZrk/s1600/POV1.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Thus, at time t1, display nothing. Then at t2,t3,t4,t5,t6 display as shown in the picture.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;For example, the code for the smiley face will be:&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;#include&amp;lt;avr/io.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;#include&amp;lt;util/delay.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;void main()&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;{ &amp;nbsp;DDRC=0xff; &amp;nbsp; // making PortC as output port&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp;while(1)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; { &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;PORTC=0x00; &amp;nbsp; // at t1;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; _delay_us(10);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; PORTC=0b00001000; &amp;nbsp;// at t2 &amp;nbsp;, note that the last row in PC7 and the first row in PC0&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; _delay_us(10);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;PORTC=0b00010010; &amp;nbsp;// at t3&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp;_delay_us(10);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;PORTC=0b00010000; &amp;nbsp;// at t4&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp;_delay_us(10);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;PORTC=0b00010010; &amp;nbsp;// at t5&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp;_delay_us(10);&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;PORTC=0b00001000; &amp;nbsp;// at t6&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; _delay_us(10);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; PORTC=0x00; &amp;nbsp; // at t7&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; _delay_us(10);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;// we can ignore t8 here as it is not required. t7 was included to&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;//make sure that there was sufficient space between smileys.&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Now, all we need to do is move it at a high speed. Since, I couldn&#39;t find a cheap enough high rpm motor. I stuck the circuit up on my fan, the result was this :&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDj0RaJzmcwiF5IQBn4tbis7sWah4677oz1LjPuf2ur6a2aGIxyqdSxN-hdT0y5AwHVtuVjfV0wzqocB7niuPTEMbxjr_v-8xoy8lhrWpGBQi5T6uxvdSCrJn8g7GYwQvL_nP2ybIt-lQ/s1600/DSC02346.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDj0RaJzmcwiF5IQBn4tbis7sWah4677oz1LjPuf2ur6a2aGIxyqdSxN-hdT0y5AwHVtuVjfV0wzqocB7niuPTEMbxjr_v-8xoy8lhrWpGBQi5T6uxvdSCrJn8g7GYwQvL_nP2ybIt-lQ/s320/DSC02346.JPG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Circuit board on the fan&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRQxvYi-VhyphenhyphenXVD2Pv5phe9UXQJ9BbdC6mYA794e57wU1WGdgbQXaA0UgbOFSj1PXZGMOlXZosae3zRA8wviMo7qNjyTdR66zbstEW8yR0CuJqBKr1ZgUl54i3RbUIx_huk5tPLTcGKrtI/s1600/DSC02358.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRQxvYi-VhyphenhyphenXVD2Pv5phe9UXQJ9BbdC6mYA794e57wU1WGdgbQXaA0UgbOFSj1PXZGMOlXZosae3zRA8wviMo7qNjyTdR66zbstEW8yR0CuJqBKr1ZgUl54i3RbUIx_huk5tPLTcGKrtI/s320/DSC02358.JPG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Smile!!&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Yeah, I know, the characters look a little stretched. To correct that you&#39;ll have to adjust the delay period.&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;times new roman&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;One more pic:&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcVur1JPNvOxfys_DixY0t1IiXBSEl7bWSLWEg-sqyqXmFoRajO87LlvQ1-wP0uladgNChv6yKAN19A_5w9FDmvrnxDHCDMbOceD5lpun_BRcAKZXDoVntonOZwG7g9iLVn2Nz252wxqk/s1600/DSC02344.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;476&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcVur1JPNvOxfys_DixY0t1IiXBSEl7bWSLWEg-sqyqXmFoRajO87LlvQ1-wP0uladgNChv6yKAN19A_5w9FDmvrnxDHCDMbOceD5lpun_BRcAKZXDoVntonOZwG7g9iLVn2Nz252wxqk/s640/DSC02344.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;The characters appear to be reversed because I did not take into account the direction of rotation of the fan.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Follow &lt;a href=&quot;http://www.facebook.com/techtechila&quot;&gt;Techila &lt;/a&gt;on &lt;a href=&quot;http://www.facebook.com/techtechila&quot;&gt;facebook&lt;/a&gt;.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;So, until next time..&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #777777; line-height: 19px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Sayōnara!&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://techtechila.blogspot.com/feeds/8725744282067899523/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://techtechila.blogspot.com/2011/10/persistence-of-vision.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3037762074085306740/posts/default/8725744282067899523'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3037762074085306740/posts/default/8725744282067899523'/><link rel='alternate' type='text/html' href='http://techtechila.blogspot.com/2011/10/persistence-of-vision.html' title='Persistence of Vision'/><author><name>Ashish</name><uri>http://www.blogger.com/profile/11572695506758516927</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCStudd-adQVZ5yYiou2fhyphenhyphenxAnJ80lhUBH7ghvJDqoiaUjsvkZLh2TUqQ2cNAv1PpYNSuwB3nJx1yLSu2Q9yJ8AivGuPubXtW-cotWShFyJG1crJHyql115dZFrMNy8jwGcPhtDcdmoV4/s72-c/POV.jpg" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3037762074085306740.post-7055715731992134425</id><published>2011-10-19T16:11:00.000+05:30</published><updated>2015-12-09T11:00:53.368+05:30</updated><title type='text'>A Robotic Arm</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;I wrote just the code for controlling this robot. The mechanical structure isn&#39;t mine. It had 3 degrees of motion. The robot was already assembled. The controlling chip was an ATMega16. A Potentiometre was used to sense the movement of the arm, potentiometers were used. One was used to indicate movement of the finger, other for sensing the movement of the wrist and the last one to check for the movement of the elbow.&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;In this video we are simply rotating the potentiometer to control the arm. Watch how it almost falls over.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;iframe allowfullscreen=&#39;allowfullscreen&#39; webkitallowfullscreen=&#39;webkitallowfullscreen&#39; mozallowfullscreen=&#39;mozallowfullscreen&#39; width=&#39;320&#39; height=&#39;266&#39; src=&#39;https://www.youtube.com/embed/NHR7r6Dt7pw?feature=player_embedded&#39; frameborder=&#39;0&#39;&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Visit us on &lt;a href=&quot;https://www.facebook.com/techtechila&quot;&gt;Facebook&lt;/a&gt;.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Bbye! :)&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://techtechila.blogspot.com/feeds/7055715731992134425/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://techtechila.blogspot.com/2011/10/robotic-arm.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3037762074085306740/posts/default/7055715731992134425'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3037762074085306740/posts/default/7055715731992134425'/><link rel='alternate' type='text/html' href='http://techtechila.blogspot.com/2011/10/robotic-arm.html' title='A Robotic Arm'/><author><name>Ashish</name><uri>http://www.blogger.com/profile/11572695506758516927</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3037762074085306740.post-417739968781496827</id><published>2011-10-08T20:38:00.000+05:30</published><updated>2015-12-09T11:01:12.154+05:30</updated><title type='text'>Making a Microcontroller Circuit on a Veroboard</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Most competitions do not allow use of development boards. In these cases you need to make your own circuit on a veraboard or a breadboard. A veraboard is a much suitable option.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;In this post we will be making a basic circuit for an AVR Micro-controller without any peripherals.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Items you will need:&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;1) Veroboard&lt;/span&gt;&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhObhfa3UTLwQ4UdZBo3n5PeRiEHxvuDp_VjLcbEm3mJSj1cQG1rnlMVzySrJdj4DDcmYFarlYeldleE81tY7nWN2VHyPQswRCqHdUXc0gCQPP6uhE-cHjmaMbvStudIiGjuGCNaixlLq0/s1600/veroboard.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhObhfa3UTLwQ4UdZBo3n5PeRiEHxvuDp_VjLcbEm3mJSj1cQG1rnlMVzySrJdj4DDcmYFarlYeldleE81tY7nWN2VHyPQswRCqHdUXc0gCQPP6uhE-cHjmaMbvStudIiGjuGCNaixlLq0/s1600/veroboard.jpg&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Top side of the Veroboard. Soldering is done on the bottom side.&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;2) IC Holder&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWyxWYK9hFfNR0AN6hZXD2LrTH8k7OjF9fcFFtaPpsM2lENrF3I1ZhCDLHql8M5ZQNRNyQkFTdIcziz6JVSsL7Du2PUHm6SXcbvOXUF-zhaFN7_AYnk-y4GBJJa5l5QS-wc4-vQNB1DsQ/s1600/40pinICbase.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWyxWYK9hFfNR0AN6hZXD2LrTH8k7OjF9fcFFtaPpsM2lENrF3I1ZhCDLHql8M5ZQNRNyQkFTdIcziz6JVSsL7Du2PUHm6SXcbvOXUF-zhaFN7_AYnk-y4GBJJa5l5QS-wc4-vQNB1DsQ/s1600/40pinICbase.jpg&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;40 Pin IC Base for ATMega16&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;3) 2 Capacitors- 22pF each&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEht4HxBZUMD0RWY9TPEoHQeNeUzrtYQa6_t0AXTC01ujLetvjR82eCFHHGTkNdmwTvRKDPlB2qapmXY0uzjX2U48pTych5UZz0e44S0o5QVEaC_cWJD476jtHP5Yc5Dgo0MM2Qn-MetOMA/s1600/22pfcapacitor.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEht4HxBZUMD0RWY9TPEoHQeNeUzrtYQa6_t0AXTC01ujLetvjR82eCFHHGTkNdmwTvRKDPlB2qapmXY0uzjX2U48pTych5UZz0e44S0o5QVEaC_cWJD476jtHP5Yc5Dgo0MM2Qn-MetOMA/s1600/22pfcapacitor.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;4) 1 Capacitor- 100nF&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTZByYWjXn-4I03ZMl_BKpgbFmtbEXFM0Gd6wfdhxZRDK2oVfflVlWYopkI-UXMX8smy67_BYjfergDWwDIAShA2v0j04zd79qRLOC-BPP-xi6qw9FHRsB04DzzRAhFra2HKPDRibxsvk/s1600/100nF+capacitor.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTZByYWjXn-4I03ZMl_BKpgbFmtbEXFM0Gd6wfdhxZRDK2oVfflVlWYopkI-UXMX8smy67_BYjfergDWwDIAShA2v0j04zd79qRLOC-BPP-xi6qw9FHRsB04DzzRAhFra2HKPDRibxsvk/s1600/100nF+capacitor.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;5) A crystal to function as an external clock. Several are available, I used a 16&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; MegaHz crystal.&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7bG9QfZcnXeg_AWs7vkGfCu_VXv-iAsV0ddS7jQ9lLF_FDv6bMlZGHs4BTigVhNqgGSyb1puTxffgV7uWxssYukaIdKi6cUkoqOghc2yWWB5STOEqN-of6V_jQ9P60w3TmKDNllCcr88/s1600/CRYSTAL-OSCILLATOR-16MHZ-type1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;200&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7bG9QfZcnXeg_AWs7vkGfCu_VXv-iAsV0ddS7jQ9lLF_FDv6bMlZGHs4BTigVhNqgGSyb1puTxffgV7uWxssYukaIdKi6cUkoqOghc2yWWB5STOEqN-of6V_jQ9P60w3TmKDNllCcr88/s200/CRYSTAL-OSCILLATOR-16MHZ-type1.jpg&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMhRRY4HxiGdpwReZf82qlXPIvhuNfcpInFO4M7pk3pHijP5o7OIuhk7Nv3jkXDJiCbxP-hUKUbhWWbQ587bz8z-NDS6lF0F2vEdjQzpnGS0bNGwvGDKrlfhtZPDOmNBmR4ey7vGs5-zc/s1600/16MHZtypep-2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;200&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMhRRY4HxiGdpwReZf82qlXPIvhuNfcpInFO4M7pk3pHijP5o7OIuhk7Nv3jkXDJiCbxP-hUKUbhWWbQ587bz8z-NDS6lF0F2vEdjQzpnGS0bNGwvGDKrlfhtZPDOmNBmR4ey7vGs5-zc/s200/16MHZtypep-2.jpg&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;6) A voltage regulator IC 7805&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtHcugzgyj1m0ULHb-mIfZzqM7zMuUdNTtVw4j4JZq9ertWOr2wvwcQ66ORVrfI4D1aBkGtTJ7cFcVQ1y1FcLoJe5cLushqA-NfewcS389Cx5W3UU272lTDTTqYHGoU5EwIV9ABa4rI_A/s1600/LM7805-Pinout.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;188&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtHcugzgyj1m0ULHb-mIfZzqM7zMuUdNTtVw4j4JZq9ertWOr2wvwcQ66ORVrfI4D1aBkGtTJ7cFcVQ1y1FcLoJe5cLushqA-NfewcS389Cx5W3UU272lTDTTqYHGoU5EwIV9ABa4rI_A/s200/LM7805-Pinout.jpg&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;7) The most important of them all, a Microcontroller (ATMega16 used here)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfY0-yH9SY2b9Wt8VR0IserSbNCESc4PdBQNpT6NGifBbs5Vn-xvCTHx2blRI0Phfb6iFsWaodiAOH096ZMfMk2aaUODb-nIhpsWXpNZ-XHgiQM-jPf2F8YtyyNUgljU58Y-LeBdpfcJo/s1600/ATMEGA16-16PI.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfY0-yH9SY2b9Wt8VR0IserSbNCESc4PdBQNpT6NGifBbs5Vn-xvCTHx2blRI0Phfb6iFsWaodiAOH096ZMfMk2aaUODb-nIhpsWXpNZ-XHgiQM-jPf2F8YtyyNUgljU58Y-LeBdpfcJo/s1600/ATMEGA16-16PI.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Now, pins like XTAL1, XTAL2, AREF, AVCC, GND, VCC, RESET are common to all microcontrollers. They may be present with a slightly different name in some, but are present in all.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Consider the pin diagram of an ATMega16&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCUKI2A98wRUDxkcE8jnxqx_UXUK2OUPZ-VOAFRts1wFuffD5rfi37tSrc4VAc_BZgCBD9827qruLGZch3yJcinnfdSny-gTyui6piXgRPCtzDADrRNwuPUFjw2tH8GQaWKhHorydPY1Y/s1600/pindiagramatmega16.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCUKI2A98wRUDxkcE8jnxqx_UXUK2OUPZ-VOAFRts1wFuffD5rfi37tSrc4VAc_BZgCBD9827qruLGZch3yJcinnfdSny-gTyui6piXgRPCtzDADrRNwuPUFjw2tH8GQaWKhHorydPY1Y/s1600/pindiagramatmega16.JPG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;The crystal is connected at Pin number 12 and 13, i.e XTAL2 and XTAL13. Connect one end (any) of the crystal at Pin 12 and the other at Pin 13&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Pin number 32 (AREF) is connected to a 100nF capacitor which is then connected to ground.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Pin 10 (VCC) and pin 30 (AVCC) are shorted. Pin 10 (VCC) is connected to a 5 Volt supply.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Pin 31 (GND) and Pin 11 (GND) are shorted and connected to ground.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;A Voltage Regulator IC LM7805 is used. The positive terminal of the battery is connected to input of 7805, the negative is connected to middle pin of 7805 and the 3rd pin gives regulated output of 5 V for input voltage greater that 7.5 Volt.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;times new roman&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtHcugzgyj1m0ULHb-mIfZzqM7zMuUdNTtVw4j4JZq9ertWOr2wvwcQ66ORVrfI4D1aBkGtTJ7cFcVQ1y1FcLoJe5cLushqA-NfewcS389Cx5W3UU272lTDTTqYHGoU5EwIV9ABa4rI_A/s1600/LM7805-Pinout.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;188&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtHcugzgyj1m0ULHb-mIfZzqM7zMuUdNTtVw4j4JZq9ertWOr2wvwcQ66ORVrfI4D1aBkGtTJ7cFcVQ1y1FcLoJe5cLushqA-NfewcS389Cx5W3UU272lTDTTqYHGoU5EwIV9ABa4rI_A/s200/LM7805-Pinout.jpg&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Now, get the Veroboard out. The side shown in the picture in the beginning is the top side. No soldering is done on this side. Soldering is done below it.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;First, on a rough sheet make a plan of the circuit you want to make.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Next, place the IC base at an appropriate position. If you are connecting some other components like IR LED, buzzer etc. on both sides of the Microcontroller, it is best to place the IC base in the middle. If, let&#39;s say the peripheral components are to be connected only on the right side, place your IC base on the extreme left of the veroboard, giving just enough space to place and connect a capacitor.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Once the IC base position has been decided, short (connect) Pin 10 (VCC) and Pin 30 (AVCC).&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Then, short (connect) Pin 11 (GND) and Pin 31 (GND).&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Make sure that the VCC and GND pins do not come in contact with each other!&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Next, place the crystal and connect one of it&#39;s legs to XTAL2 and the other to XTAL1.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Then, to each leg of the crystal connect a 22pF capacitor and ground the other end of the capacitor.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Place the LM7805 IC on the veroboard.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Note: With the flat side facing away from you, it&#39;s I-G-O, i.e Input-Ground-Output&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtHcugzgyj1m0ULHb-mIfZzqM7zMuUdNTtVw4j4JZq9ertWOr2wvwcQ66ORVrfI4D1aBkGtTJ7cFcVQ1y1FcLoJe5cLushqA-NfewcS389Cx5W3UU272lTDTTqYHGoU5EwIV9ABa4rI_A/s1600/LM7805-Pinout.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtHcugzgyj1m0ULHb-mIfZzqM7zMuUdNTtVw4j4JZq9ertWOr2wvwcQ66ORVrfI4D1aBkGtTJ7cFcVQ1y1FcLoJe5cLushqA-NfewcS389Cx5W3UU272lTDTTqYHGoU5EwIV9ABa4rI_A/s1600/LM7805-Pinout.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Connect the +ve terminal of the battery or the power-supply to Input pin of LM7805.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Connect the GND pin of LM7805 to the GND of the battery or the power-source.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;This GND is also connected to Pin 31 and Pin 11 of the Microcontroller.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Also note, all the GND points on the circuit should be linked to each other which is finally connected to the GND (or the -ve) of the power-supply.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Connect the output pin of LM7805 to Pin 10 and Pin 30. This pin gives the 5V output supply.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;The circuit will finally look like this:&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPYehwNjL-nZXqepE_hQxghwxZLgN3PI8DB2aXIVB8bodjGmF96zQssE2yWwkg2rbEWwoU3lRY6HQr8_PI6yRaLxZLcq4luZUw_v__126R5Pl9mi_YPfBkvb9JojGR7v5EzmohTcJ37wE/s1600/IMAG0434.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;266&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPYehwNjL-nZXqepE_hQxghwxZLgN3PI8DB2aXIVB8bodjGmF96zQssE2yWwkg2rbEWwoU3lRY6HQr8_PI6yRaLxZLcq4luZUw_v__126R5Pl9mi_YPfBkvb9JojGR7v5EzmohTcJ37wE/s400/IMAG0434.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Adios until next time! :)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;times new roman&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://techtechila.blogspot.com/feeds/417739968781496827/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://techtechila.blogspot.com/2011/10/making-microcontroller-circuit-on.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3037762074085306740/posts/default/417739968781496827'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3037762074085306740/posts/default/417739968781496827'/><link rel='alternate' type='text/html' href='http://techtechila.blogspot.com/2011/10/making-microcontroller-circuit-on.html' title='Making a Microcontroller Circuit on a Veroboard'/><author><name>Ashish</name><uri>http://www.blogger.com/profile/11572695506758516927</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhObhfa3UTLwQ4UdZBo3n5PeRiEHxvuDp_VjLcbEm3mJSj1cQG1rnlMVzySrJdj4DDcmYFarlYeldleE81tY7nWN2VHyPQswRCqHdUXc0gCQPP6uhE-cHjmaMbvStudIiGjuGCNaixlLq0/s72-c/veroboard.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3037762074085306740.post-6664286042973917884</id><published>2011-10-04T23:16:00.001+05:30</published><updated>2015-12-09T11:01:26.226+05:30</updated><title type='text'>Image Processing (Acquisition)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp;In this post we will talk about Image Acquisition and processing using Matlab.&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;A digital image is composed of &#39;pixels&#39;&amp;nbsp;which can be thought of as small dots on the screen.&amp;nbsp;A typical size of an image is 512-by-512 pixels. Later on in the course you will see that it is convenient to let the dimensions of the image to be a power of 2. For example, 2&lt;sup&gt;9&lt;/sup&gt;=512. In the general case we say that an image is of size&amp;nbsp;&lt;i&gt;m&lt;/i&gt;-by-&lt;i&gt;n&lt;/i&gt;&amp;nbsp;if it is composed of&amp;nbsp;&lt;i&gt;m&lt;/i&gt;&amp;nbsp;pixels in the vertical direction and&amp;nbsp;&lt;i&gt;n&lt;/i&gt;&amp;nbsp;pixels in the horizontal direction.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Matlab has an Image Acquisition Tool Box which can be used for acquiring&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;images.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;To open the toolbox, click on start --&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirtkTvjG1eaJb1WyqvIKv9QZU4o00YSnXb7GScih_VSTFPJhwkfLYRIfoI-7UwxUyJmkjperCmlPnjHipA1Y_kxDw5q8gpmkkSgymmFMkVBSVzBSwzZWGTRt43mdyWrtppVSwsiDMfdF0/s1600/matlab1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;382&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirtkTvjG1eaJb1WyqvIKv9QZU4o00YSnXb7GScih_VSTFPJhwkfLYRIfoI-7UwxUyJmkjperCmlPnjHipA1Y_kxDw5q8gpmkkSgymmFMkVBSVzBSwzZWGTRt43mdyWrtppVSwsiDMfdF0/s640/matlab1.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Toolboxes ---&amp;gt; Image Acquisition ---&amp;gt; Image Acquisition Tool (imaqtool)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuHcAzKf7z_kN46lO3DDjuvNhuLHej-2pvQz4gerCWLlSf6CpK2eWSC9waCOv24JZiaRMyY7amL80dpeTzEp8UWiW90VJGPxtDetwhphdc8ZhF0bz_-Jrcz2ylLpQlHt6JkbKEPbianY0/s1600/Imaqtool.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;383&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuHcAzKf7z_kN46lO3DDjuvNhuLHej-2pvQz4gerCWLlSf6CpK2eWSC9waCOv24JZiaRMyY7amL80dpeTzEp8UWiW90VJGPxtDetwhphdc8ZhF0bz_-Jrcz2ylLpQlHt6JkbKEPbianY0/s640/Imaqtool.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Once the Image Acquisition ToolBox is open, you could start preview, view the type of camera you are using etc.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;You could also do all this using MATLAB commands.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Plug in a camera to your laptop.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;In the Workspace, type:&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;imaqhwinfo&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;and hit enter.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;You will get an output something like this:&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;gt;&amp;gt; imaqhwinfo&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;ans =&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; InstalledAdaptors: {&#39;coreco&#39; &amp;nbsp;&#39;winvideo&#39;}&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; MATLABVersion: &#39;7.6 (R2008a)&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ToolboxName: &#39;Image Acquisition Toolbox&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ToolboxVersion: &#39;3.1 (R2008a)&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Thus by using this command we can know the adapters installed.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Now, we want to capture the video, right?&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;There is a command in MATLAB called &#39;videoinput&#39;. It helps you to create video input objects.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Syntax:&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;OBJ = VIDEOINPUT(ADAPTORNAME)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;OBJ = VIDEOINPUT(ADAPTORNAME,DEVICEID)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;OBJ = VIDEOINPUT(ADAPTORNAME,DEVICEID,FORMAT)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;OBJ = VIDEOINPUT(ADAPTORNAME,DEVICEID,FORMAT,P1,V1,...)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;We already got the adapter name by using the imaqhwinfo command. Winvideo and Coreco are the name of the installed adapters. Any one of them can be used.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;For format, open the Image Acquisition Toolbox, it will be mentioned on the left side of the toolbox. The camera I was using was a&amp;nbsp;&#39;YUY2_352x288&#39;.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;In the workspace again type imaqhwinfo(write name of your adapter here) and hit enter, this will give you the device id.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;gt;&amp;gt; imaqhwinfo(&#39;winvideo&#39;)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;ans =&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;AdaptorDllName: &#39;C:\Program Files\MATLAB\R2008a\toolbox\imaq\imaqadaptors\win32\mwwinvideoimaq.dll&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; AdaptorDllVersion: &#39;3.1 (R2008a)&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AdaptorName: &#39;winvideo&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DeviceIDs: {1x0 cell}&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DeviceInfo: [1x0 struct]&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Thus, the device id is 1.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;So, my videoinput statement becomes something like this:&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;obj=videoinput(&#39;winvideo&#39;,1,&#39;YUY2_352x288&#39;);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Next --&amp;gt; triggerconfig&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;This command is used to configure the trigger settings of the video input object. i.e it defines how you want the camera to trigger, whether it should be &amp;nbsp;manual or auto.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;We define it manual because we want it to start only when we need it.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;remember&amp;nbsp;that &#39;obj&#39; is the video input object we have defined.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;thus, my command statement looks like this:&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;triggerconfig(obj,&#39;manual&#39;);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Now, we need to set the number of frames we want the camera to capture every time it&#39;s triggered. For my use i set it to 1. Also, the&amp;nbsp;triggering&amp;nbsp;should happen continuously, thus it should also be set to infinity.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;set(obj,&#39;FramesPerTrigger&#39;,1);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;set(obj,&#39;TriggerRepeat&#39;,inf);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;after that start(obj)&amp;nbsp;initializes&amp;nbsp;&#39;obj&#39; which is the object defined for videoinpout.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;If you want to preview the video during run-time, give the command preview(obj) after start(obj).&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Thus our code in MATLAB till now is:&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;obj=videoinput(&#39;winvideo&#39;,1,&#39;YUY2_352x288&#39;);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;triggerconfig(obj,&#39;manual&#39;);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;set(obj,&#39;FramesPerTrigger&#39;,1);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;set(obj,&#39;TriggerRepeat&#39;,inf);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;start(obj);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;preview(obj);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;To trigger the camera the command: trigger(obj), is used.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;use the getdata command to get data and store it in a variable&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;im=getdata(obj,1);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Thus, now we have one image stored in im.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;I recently took part in a competition in which I had to follow a red line by using a web-cam to see the line.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;In such a case, the image that was obtained contained a red line on a white background. The preview window (which you get by using the preview(obj) command) looks like this :&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidhIH8RUM8FY30S2U2fN73Zzzt2GD-Gr8m8y3yTZgQXUc2FfE1FbYWhzSMVvCc1bB6R21id6jQnFcfmBpaJ72hd_fms0vs9JAsiuKGI77eUJeqZirRUWPY27argu2c3wyQ8Lx9UtOQz0E/s1600/preview.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidhIH8RUM8FY30S2U2fN73Zzzt2GD-Gr8m8y3yTZgQXUc2FfE1FbYWhzSMVvCc1bB6R21id6jQnFcfmBpaJ72hd_fms0vs9JAsiuKGI77eUJeqZirRUWPY27argu2c3wyQ8Lx9UtOQz0E/s1600/preview.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;This image needs to be converted into grayscale image first.&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;A grayscale image represents an image as a matrix where every element has a value corresponding to how bright/dark the pixel at the corresponding position should be colored.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;the command rgb2gray is used to conver the image to grayscale.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;The camptured image is stored in im.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;thus,&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;b=rgb2gray(im);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Now, b stores the grayscale image.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Below are shown two grayscale images with index intensity values for the RED portion and the WHITE area.&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCpKs0Uz2HE-dKaRApyTmWlWcDrI4ECI83xNYTXndHPXd2GaS2ryat7AHM1lxTCKawopTk4ISZrjCnfaqGWeggsOOXHA618rLUzKZY5BNTWuEmtNFdO42Ii_V_M1rtB1A4WqU-SpFY9QY/s1600/red+intensity.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCpKs0Uz2HE-dKaRApyTmWlWcDrI4ECI83xNYTXndHPXd2GaS2ryat7AHM1lxTCKawopTk4ISZrjCnfaqGWeggsOOXHA618rLUzKZY5BNTWuEmtNFdO42Ii_V_M1rtB1A4WqU-SpFY9QY/s1600/red+intensity.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjp97dSRZZPvDoCDYRO2L8wB-IpGCcO8urf4LzwMeGjBkEerjPeB1v2336uEmQec-0ww6pz2rR0LaLW0GXsVHcOPhzVCJ8uG4L6EPS6PU3eCvpqsl3ZQb8csJhTPFRpa63F7j0ZPY5Qg1Y/s1600/white+intensity.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjp97dSRZZPvDoCDYRO2L8wB-IpGCcO8urf4LzwMeGjBkEerjPeB1v2336uEmQec-0ww6pz2rR0LaLW0GXsVHcOPhzVCJ8uG4L6EPS6PU3eCvpqsl3ZQb8csJhTPFRpa63F7j0ZPY5Qg1Y/s1600/white+intensity.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Thus we see that there is a difference between the index values of WHITE and RED.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;A function roicolor() can be used to definitely separate red and white by specifying a range of threshold index value. All values within that range will show as white and values outside that range will show as black.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;a=roicolor(b,[100,115]);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3FwdhaTjRQbkua-URwKFNpVBNIG2vu08pBe-d8K774aoRa45Xid5Y5y5q4tgGnJdFrED_82YMDZsuFrB8uZZpNAxgEPig7KJuypDE7YmsGl8YUwFlfZby3FgrsH6d9AfaTtbw0IRVvi4/s1600/roic.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3FwdhaTjRQbkua-URwKFNpVBNIG2vu08pBe-d8K774aoRa45Xid5Y5y5q4tgGnJdFrED_82YMDZsuFrB8uZZpNAxgEPig7KJuypDE7YmsGl8YUwFlfZby3FgrsH6d9AfaTtbw0IRVvi4/s1600/roic.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp;The black portion in between the white strip where the red tape was is because of there was a high intensity reflection of the room light (see in preview image above)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Now we invert the image, i.e make the black region white and white region black, so that the region of interest shows up more clearly.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJoHz-KzdwNnaliNy5m1tUpYEVl7iH-C-u-gPqL-CWXLCD5V76bUjhxFhwrNXAHvWD431wia6d_liFjVl_TGyVzszIB66mqUb1h105vwsWCIy0DWLcWParWqX7DNk9j3gOmpnBtbn2yaM/s1600/roic.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJoHz-KzdwNnaliNy5m1tUpYEVl7iH-C-u-gPqL-CWXLCD5V76bUjhxFhwrNXAHvWD431wia6d_liFjVl_TGyVzszIB66mqUb1h105vwsWCIy0DWLcWParWqX7DNk9j3gOmpnBtbn2yaM/s1600/roic.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Now that we have this image, we calculate the centre of gravity of the black portion of the image. If the centre of gravity lies near the centre of the image, we send instruction to our robot to keep moving forward, else the centre of gravity lies somewhere on the right side, the bot should move right and similarly for moving left side. The range of centre of gravity needs to be decided by us. For my use, I specified that if the x coordinate of the centre of gravity was between 140 and 180 the robot should move straight, if it was above that the robot should move right else left.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;The instructions were sent to the microcontroller using UART communication.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;The serial port can be configured in MATLAB using these commands:&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;ser= serial(&#39;COM42&#39;,&#39;BaudRate&#39;,9600,&#39;DataBits&#39;,8);&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;fopen(ser);&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;The command fwrite(ser,&#39;character&#39;) can be used to transmit data using UART.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;At the end of the code, the serial port has to be closed and the videoinput object closed. My final code looked like this:&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;clc;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;clear all;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;close all;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;obj=videoinput(&#39;winvideo&#39;,1,&#39;YUY2_352x288&#39;);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;triggerconfig(obj,&#39;manual&#39;);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;set(obj,&#39;FramesPerTrigger&#39;,1);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;set(obj,&#39;TriggerRepeat&#39;,inf);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;start(obj);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;ser= serial(&#39;COM42&#39;,&#39;BaudRate&#39;,9600,&#39;DataBits&#39;,8);&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;fopen(ser);&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;while(1) &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;% infinite loop&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; trigger(obj);&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; im=getdata(obj,1); &amp;nbsp; %get the image&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; trigger(obj);&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; im1=getdata(obj,1); &amp;nbsp;% the first time triggering occurs the image is just&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; % noise. Thus the 2nd image is used.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; b=rgb2gray(im1); &amp;nbsp; &amp;nbsp; &amp;nbsp;% convert to grayscale&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; a=roicolor(b,[100:118]); &amp;nbsp;%define a region of interest&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; a=~a;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; c=center(a);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; % use disp(c) to see the values, while testing&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; if (c(2)&amp;gt;190)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; fwrite(ser,&#39;r&#39;); &amp;nbsp;% send move right&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; elseif (c(2)&amp;lt;170 &amp;amp;&amp;amp; c(2)&amp;gt;10)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; fwrite(ser,&#39;l&#39;);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; elseif c(2)&amp;lt;170&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; fwrite(ser,&#39;l&#39;); % stop&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp;end&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp;end&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp;fclose(ser);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;stop(obj),delete(obj),clear obj; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;-------&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;The function center(a) that I have used is not an inbuilt function. I would suggest you attempt to write it on your own.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;This is the video of the robot following the red line.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;iframe allowfullscreen=&#39;allowfullscreen&#39; webkitallowfullscreen=&#39;webkitallowfullscreen&#39; mozallowfullscreen=&#39;mozallowfullscreen&#39; width=&#39;320&#39; height=&#39;266&#39; src=&#39;https://www.youtube.com/embed/Ylte6Hbev4o?feature=player_embedded&#39; frameborder=&#39;0&#39;&gt;&lt;/iframe&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://techtechila.blogspot.com/feeds/6664286042973917884/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://techtechila.blogspot.com/2011/10/image-processing-acquisition.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3037762074085306740/posts/default/6664286042973917884'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3037762074085306740/posts/default/6664286042973917884'/><link rel='alternate' type='text/html' href='http://techtechila.blogspot.com/2011/10/image-processing-acquisition.html' title='Image Processing (Acquisition)'/><author><name>Ashish</name><uri>http://www.blogger.com/profile/11572695506758516927</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirtkTvjG1eaJb1WyqvIKv9QZU4o00YSnXb7GScih_VSTFPJhwkfLYRIfoI-7UwxUyJmkjperCmlPnjHipA1Y_kxDw5q8gpmkkSgymmFMkVBSVzBSwzZWGTRt43mdyWrtppVSwsiDMfdF0/s72-c/matlab1.jpg" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3037762074085306740.post-4952076617122626898</id><published>2011-06-08T13:16:00.004+05:30</published><updated>2015-12-09T11:01:47.535+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="ADC"/><category scheme="http://www.blogger.com/atom/ns#" term="IR Sensor"/><category scheme="http://www.blogger.com/atom/ns#" term="Line Follower"/><category scheme="http://www.blogger.com/atom/ns#" term="line sensor"/><category scheme="http://www.blogger.com/atom/ns#" term="Microcontroller"/><title type='text'>Analog to Digital Converter (ADC)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;(Circuit for IR Sensor for a Line Follower given at the end of the post)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Q1) &amp;nbsp;What is an analog signal?&lt;/span&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-iR-ehFBPMQ144RXO87L2UtSgGekHR6n-lliK6m6BjZiRgRwdxm6yzH5F2E9rUDgOVQqFaYblDCZgxpI2bZr19gLvjpUHOHBIPbVXAZ7Mtk2UEqmdFOLii1MRPkuXcpGlATpJF1rivog/s1600/analog+signal.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-iR-ehFBPMQ144RXO87L2UtSgGekHR6n-lliK6m6BjZiRgRwdxm6yzH5F2E9rUDgOVQqFaYblDCZgxpI2bZr19gLvjpUHOHBIPbVXAZ7Mtk2UEqmdFOLii1MRPkuXcpGlATpJF1rivog/s1600/analog+signal.jpg&quot; /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;In simple words, Any signal that looks like this &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;is called an analog signal.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;For example, if we were to plot the amplitude variation of a song with time, it would be an analog signal.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;(The picture on the right is a part of amplitude variation of an actual song)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Q2) What is a digital signal?&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkyjVdYsUX2RrLv8VaqPE05uo17sQL2QAAc8hpS7DJ7RtilMnSnPHV_rJtzCWMt99YEDlnk3SJ2jVJn8FKhaSQoxhykMY2_FRIRdSMjSu-4HxnWpEQ74Rk0S8lXQ3sN5TTGedjkgfEaYY/s1600/digital+signal.gif&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;104&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkyjVdYsUX2RrLv8VaqPE05uo17sQL2QAAc8hpS7DJ7RtilMnSnPHV_rJtzCWMt99YEDlnk3SJ2jVJn8FKhaSQoxhykMY2_FRIRdSMjSu-4HxnWpEQ74Rk0S8lXQ3sN5TTGedjkgfEaYY/s320/digital+signal.gif&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Any signal that would look like this&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;is called a digital signal. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;The main difference between an analog signal and digital signal is that a digital signal will keep fluctuating between two fixed values i.e it will take no other value, whereas an analog signal has no such conditions.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;The &#39;high&#39; part of the digital signal is usually represented with a 1 and the low part with a 0.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;The high part can be anything, but it must be fixed throughout. Generally, the high part should be at 5 Volts and the low part is at 0 Volt.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;The process of converting an analog signal to a digital signal is called an analog to digital conversion.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;It is recommended that you have the datasheet open in front of you before reading further.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Datasheets for&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;1)&amp;nbsp;&lt;a href=&quot;http://www.2shared.com/document/-Y3fnkoJ/ATmega16.html&quot;&gt;ATMega16&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;2) &lt;a href=&quot;http://www.2shared.com/document/liyItsLK/ATmega32.html&quot;&gt;ATMega32&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;img src=&quot;http://a2.sphotos.ak.fbcdn.net/hphotos-ak-snc4/hs716.snc4/63647_185162351497433_122819407731728_695846_1347630_n.jpg&quot; /&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Now, the MEGA series of AVR Microcontrollers (like ATMega16, ATMega32 etc) have an inbuilt ADC.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;ATMega16 and ATMega32 have 8 ADC channels on PortA with PA0 being the first ADC channel and PA7 being the 8th ADC channel&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;The analog signal should be given at one of these channels. The analog signal is a simply varying analog signal, which can also be produced by simply making a voltage divider circuit. The circuit is shown at the end of the blog post.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Now, in the datasheet open the section for Analog to Digital Converter. Keep scrolling down till you come to ADC Multiplexer Register (ADMUX)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;The register configuraton for ADMUX is as given below:&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiym-F_ToAV0W2C5MRzYiClP_JlanhXJxPvH9fAO-Wr43vvBQZs9wzCflJHEY2S2uKLwvjUTlMhw3DPpStMMBDlgnaZcoPkGGPgT72Syf7TtImWzvgeh6Px6v1UWi78dSozjt9JHRMmDVE/s1600/ADMUX.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiym-F_ToAV0W2C5MRzYiClP_JlanhXJxPvH9fAO-Wr43vvBQZs9wzCflJHEY2S2uKLwvjUTlMhw3DPpStMMBDlgnaZcoPkGGPgT72Syf7TtImWzvgeh6Px6v1UWi78dSozjt9JHRMmDVE/s1600/ADMUX.JPG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;REFS1, REFS0 :&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Now, bit 7 and bit 6 are the Reference Selection bits. The configuration of these bits is based on these conditions:&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4DsnkKZibH65WTg9KGlTSL0zNbndafTWEPniLfmwnYG6ZFVsqV6vh7tgDxfPWsRcoSBRtqIG9WgZEHUbWuj3NHl0hyphenhyphensp03QKr7sYkkUf5Nv-VHAUm7Tp104uLUHyYFq94Xd__RMzNqm0/s1600/refs0.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4DsnkKZibH65WTg9KGlTSL0zNbndafTWEPniLfmwnYG6ZFVsqV6vh7tgDxfPWsRcoSBRtqIG9WgZEHUbWuj3NHl0hyphenhyphensp03QKr7sYkkUf5Nv-VHAUm7Tp104uLUHyYFq94Xd__RMzNqm0/s1600/refs0.JPG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Note: AREF pin is pin number 32 in both ATMega16 and ATMega32&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Let&#39;s assume that AREF is connected through a capacitor to ground.&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhs7oNn7ECtTvDmeoeLFwQlIqAx2eLBKio52sbGPQCivPwHGXKCvCbqGE0TSFbTGZ61VPXXXmdpmBSiOx2lUA82wIcaC_uWTERQsyLvwZ3w4-jVJDpSQIFUawflZGEwp3-b5RQ6qSp6RZU/s1600/AREF.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhs7oNn7ECtTvDmeoeLFwQlIqAx2eLBKio52sbGPQCivPwHGXKCvCbqGE0TSFbTGZ61VPXXXmdpmBSiOx2lUA82wIcaC_uWTERQsyLvwZ3w4-jVJDpSQIFUawflZGEwp3-b5RQ6qSp6RZU/s1600/AREF.JPG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Now, ATMega16/32 has a 10-bit ADC. This means that the maximum value that we can get &amp;nbsp;is :&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;calibri&amp;quot; , sans-serif; font-size: 15px; line-height: 17px;&quot;&gt;2&lt;sup&gt;10&lt;/sup&gt;&lt;/span&gt;-1 = 1023&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;The microcontroller takes samples of the incoming analog signal at a specific frequency. The frequency is defined by us. We&#39;ll come to that a little later.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;These samples are then converted to a digital value and stored in a 16 bit register called &lt;b&gt;ADC Data Register&lt;/b&gt;. This register is made up of two 8-bit registers: ADCH (for storing the higher 8-bits) and ADCL ( for storing the lower 8-bits)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Since, it is a 10-bit ADC, by default, the lower 8 bits of the result is stored in ADCL and the most significant 2 bits are stored in ADCH.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;ADLAR&lt;/b&gt;: &amp;nbsp;ADC Left Adjust Result&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;If ADLAR=0, the result is stored in ADCH and ADCL &amp;nbsp;as explained above and shown diagrammatically below.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6OmfcKd1R2FFuQgWxKNKvJQq-LtpSIQW74vFafiZa9SymxP97-4k4XrXGgnR78cSRn6qmIGe0sQtMxYB-iMVFwSmrv_A8ev9dd3M2IQAuWtCUwdlfDWkxzcBySxzib-8ryFWqMdAU4b8/s1600/ADLAR0.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6OmfcKd1R2FFuQgWxKNKvJQq-LtpSIQW74vFafiZa9SymxP97-4k4XrXGgnR78cSRn6qmIGe0sQtMxYB-iMVFwSmrv_A8ev9dd3M2IQAuWtCUwdlfDWkxzcBySxzib-8ryFWqMdAU4b8/s1600/ADLAR0.JPG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;if ADLAR is set to 1, the result is left adjusted, that means, the result is shifted towards the left by 8 places. This is a configuration.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;It is shown below.&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYKJB4QkEDRgRin6UoUk2NwuWobLHgq6nEzulGovv2jy-Gsy9qWDtgGE-qVX_KToeQyzqEFBaYJMpvfgwmPbLnJsN4lST68uHgqPPJ77-1uAY-V6GvrVb-2b7OuLoCNnSVL4Vs2XshJwg/s1600/adlar1.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYKJB4QkEDRgRin6UoUk2NwuWobLHgq6nEzulGovv2jy-Gsy9qWDtgGE-qVX_KToeQyzqEFBaYJMpvfgwmPbLnJsN4lST68uHgqPPJ77-1uAY-V6GvrVb-2b7OuLoCNnSVL4Vs2XshJwg/s1600/adlar1.JPG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; Note this carefully, the ADC data register will be updated only after ADCH is read. Thus it is necessary to read the ADCH data register in the program.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Note: When we say read ADCH, it implies a C code statement like, k=ADCh, here k is some variable.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Thus, if we can manage with 8 bit precision (value till 255), we left adjust the result, and read only ADCH, it makes programming easier. Otherwise, ADCL must be read first and then ADCH.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Hence, by setting ADLAR=1, we get an 8 bit ADC instead of 10 bit ADC. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Thus, let ADLAR=1;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;The remaining bits are used to select which ADC channel we are using. for example if we are using PA0, the last 5 bits will have &amp;nbsp;( 00000), similarly, if we are using PA1, the last 5 bits will have &amp;nbsp;the value ( 00001 ). This is shown in the table below.&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpysNIkfRtgxZF_Qle0rM03jx7W6ELI59ya1_USIkNWo9GnundOivEvYcjfVBm15A9o9lIXkMd1ktF_NGV6ig05yYCHlTCxKXAxTcSSD279_kO9Lc-uiGqHpy53pm77WUv2PaKDCQ8vgs/s1600/mux.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpysNIkfRtgxZF_Qle0rM03jx7W6ELI59ya1_USIkNWo9GnundOivEvYcjfVBm15A9o9lIXkMd1ktF_NGV6ig05yYCHlTCxKXAxTcSSD279_kO9Lc-uiGqHpy53pm77WUv2PaKDCQ8vgs/s1600/mux.JPG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Thus, the ADMUX register can be defined as&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;ADMUX=0b01100000; &amp;nbsp; // if PA0 is the input&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Next register of importance is ADCSRA register.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;ADCSRA&lt;/b&gt; : ADC Control and Status Register&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIJpJ0Yh_8T2GR0MXp_CzVqsqtOqSVgVdONrVp_UkAE7C8crlsffzt8fOUarewR-hj6ZSzFCwQ7OiFCf3qpNZ7-B8HWWh6nVbCHOH4EqFuS8kvq4aSo8cITdBuHb0JxAQw7g3ygoCQGsI/s1600/ADCSRA.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIJpJ0Yh_8T2GR0MXp_CzVqsqtOqSVgVdONrVp_UkAE7C8crlsffzt8fOUarewR-hj6ZSzFCwQ7OiFCf3qpNZ7-B8HWWh6nVbCHOH4EqFuS8kvq4aSo8cITdBuHb0JxAQw7g3ygoCQGsI/s1600/ADCSRA.JPG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;ADEN : ADC Enable&lt;br /&gt;
Write this bit to 1 to enable ADC. If this bit is made 0 at any time, even when the conversion is going on, will turn off the ADC and terminate the conversion&lt;br /&gt;
&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;ADSC: ADC Start conversion&lt;br /&gt;
This bit is set to 1 to start conversion.&lt;br /&gt;
These bit values need to be set outside the infinite loop. And then again inside the infinite loop. When it is set outside the infinite loop, a conversion is performed, which initializes the ADC.&lt;br /&gt;
ADSC will read as 1 as long as conversion is progress. When the conversion is over it becomes 0.&lt;br /&gt;
No other operation should take place on the ADC while the conversion is in pogress. This, we write a code to wait till ADSC==1;&lt;br /&gt;
&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;ADATE: ADC Auto trigger enable&lt;br /&gt;
In Auto trigger mode, we need to provide a triggering signal. If ADATE bit is set to 1, the ADC will start a conversion on the positive edge of the selected trigger signal.&lt;br /&gt;
&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;ADIF: ADC Interrupt flag&lt;br /&gt;
When the conversion is complete, an interrupt occurs and this bit is set to 1. The user needs to clear this bit after the interrupt occurs. To use any interrupts it is essential that global interrupts are enabled using the command sei();&lt;br /&gt;
&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;ADIE: ADC Interrupt Enable.&lt;br /&gt;
This bet is set to 1 by the user to enable ADC Interrupt.&lt;br /&gt;
&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;ADPS2, ADPS1, ADPS0: Prescalar Bits.&lt;br /&gt;
Remember we were earlier talking about selecting the sampling frequency? Well, these are the bits that are used to select the sampling frequency.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Note&lt;/b&gt;: Nyquist criterion states the the sampling frequency must be twice the maximum frequency content of the signal. But, this is important mainly when the signal has to be reconstructed or some action needs to be performed&amp;nbsp;utilizing&amp;nbsp;the frequency of the incoming signal, e.g an Audio Signal. In cases like line follower sensors, there is no need to go by the Nyquist Criterion. Because we simply need to sample the incoming values&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;times new roman&amp;quot;;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEit9OwGf9uFz83Anon6h0KyvyYz3_XXoh0wlgy13g-G7MMfjbe5Cxdbfg-DM6rJ9LdPsdBgHpCDEdnQYNyyCwts-2SOXC8sYUbnXBu5mQePSSi86uBR_As4flAzwRmr2q5VdDiSgAKpECk/s1600/ADPS.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEit9OwGf9uFz83Anon6h0KyvyYz3_XXoh0wlgy13g-G7MMfjbe5Cxdbfg-DM6rJ9LdPsdBgHpCDEdnQYNyyCwts-2SOXC8sYUbnXBu5mQePSSi86uBR_As4flAzwRmr2q5VdDiSgAKpECk/s1600/ADPS.JPG&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
ADC Sampling frequency = (Clock Frequency of the Microcontroller/Division Factor)&lt;br /&gt;
&lt;br /&gt;
Set these bits to (000) outside the infinite loop. Set to (001 or above as required) inside the infinite loop or just set it to (001 or above) outside the infinite loop itself.&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Now, we write the sample code, assuming that I have only one input connected at PA0&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;#include&amp;lt;avr/io.h&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;#include&amp;lt;util/delay.h&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;unsigned char k;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;void main()&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;{ &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp;ADMUX=0b01100000; &amp;nbsp; &amp;nbsp;// setting ADLAR to 1&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp;ADCSRA=0b11000001;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; while(1)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; { &amp;nbsp; &amp;nbsp;ADCSRA|=(1&amp;lt;&amp;lt;ADSC); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// start conversion&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;while(ADCSRA&amp;amp;(1&amp;lt;&amp;lt;ADSC)); &amp;nbsp;// wait here till ADSC is 1&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;k=ADCH; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // conversion is complete, store the result in a variable.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;/* Once we have the ADC value stored, we can do whatever further is required, compare, display etc.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;*/&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Please note that at one instant of time only one ADC channel can be used.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Now, what if we have to use multiple ADC Channels??&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;In this case we will enable one channel, store the ADC value, then disable it and enable another channel.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Since, this process happens in a matter of micro-seconds, in &#39;human&#39; terms, all the channels are being sampled nearly&amp;nbsp;simultaneously.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Code to use multiple ADC Channels&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Assuming that one analog input is at PA0 and another at PA1.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;#include&amp;lt;avr/io.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;#include&amp;lt;util/delay.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;void main()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;{ &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp;ADMUX=0b01100000; &amp;nbsp; &amp;nbsp;// setting ADLAR to 1, initially selecting PA0&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp;ADCSRA=0b11000001;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp;while(1)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; { &amp;nbsp;ADMUX=0b01100000; &amp;nbsp; &amp;nbsp;// select PA0&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;ADCSRA|=(1&amp;lt;&amp;lt;ADSC); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// start conversion&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;while(ADCSRA&amp;amp;(1&amp;lt;&amp;lt;ADSC)); &amp;nbsp;// wait here till ADSC is 1&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;k=ADCH; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; ADMUX=0b01100001; &amp;nbsp; &amp;nbsp; // select PA1&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;ADCSRA|=(1&amp;lt;&amp;lt;ADSC); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// start conversion&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; while(ADCSRA&amp;amp;(1&amp;lt;&amp;lt;ADSC)); &amp;nbsp;// wait here till ADSC is 1&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;l=ADCH; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp;// Similarly repeat for as many (max. 8) channels required.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;You can build a simple Voltage divider circuit to learn ADC. &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5ZY9YsBYUd6ALvFEXuGUKW_hNO4zZfTPetfSIczYTit6Tgu1QJWpcJteiMBCAIcQo-gBz08I63mT-Idc5mdEhp-r6zc87Z8MIaQQIEVERpZJBkOY9hyphenhyphenS6cQmfEpqTrIW1fGh_EhNe1dI/s1600/ADC+Sensor.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5ZY9YsBYUd6ALvFEXuGUKW_hNO4zZfTPetfSIczYTit6Tgu1QJWpcJteiMBCAIcQo-gBz08I63mT-Idc5mdEhp-r6zc87Z8MIaQQIEVERpZJBkOY9hyphenhyphenS6cQmfEpqTrIW1fGh_EhNe1dI/s1600/ADC+Sensor.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;For a voltage divider circuit, the output voltage (Vout) when converted to decimal will give a result (d) which can be calculated using the formula: &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;((Vout)x(Vref)/(255) )=d&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Vref here is 5V.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;For 8 bit ADC the denominator is 255. For 10 bit ADC, the denominator is 1023, (&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;calibri&amp;quot; , sans-serif; font-size: 15px; line-height: 17px;&quot;&gt;2&lt;sup&gt;10&lt;/sup&gt;&lt;/span&gt;-1)&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Those of you trying to make a line follower, if you are going to use ADC, you can use the circuit for the line sensor shown below. The line marked output is given as input to one of the ADC channels of the microcontroller.&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhuLmoEfFimEX2KUEw1c58ZwJ8cN4AtOG6GQqaoU312aP314GHoULhHNLAnQEMoo5qdNBFDC8Cmgo4phiIVzV9rZ96l_vabPUNF2sqARss9TglqJGycvVnboiZP6_N16Mt96-DOwxah3Ws/s1600/IR+Sensor.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhuLmoEfFimEX2KUEw1c58ZwJ8cN4AtOG6GQqaoU312aP314GHoULhHNLAnQEMoo5qdNBFDC8Cmgo4phiIVzV9rZ96l_vabPUNF2sqARss9TglqJGycvVnboiZP6_N16Mt96-DOwxah3Ws/s1600/IR+Sensor.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;In case of any doubt, or if you need help in doing a project using ADC, please leave a comment below.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Follow &lt;a href=&quot;http://www.facebook.com/pages/Techila/205993926090673&quot;&gt;Techila &lt;/a&gt;on &lt;a href=&quot;http://www.facebook.com/pages/Techila/205993926090673&quot;&gt;Facebook&lt;/a&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://techtechila.blogspot.com/feeds/4952076617122626898/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://techtechila.blogspot.com/2011/06/analog-to-digital-converter-adc.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3037762074085306740/posts/default/4952076617122626898'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3037762074085306740/posts/default/4952076617122626898'/><link rel='alternate' type='text/html' href='http://techtechila.blogspot.com/2011/06/analog-to-digital-converter-adc.html' title='Analog to Digital Converter (ADC)'/><author><name>Ashish</name><uri>http://www.blogger.com/profile/11572695506758516927</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-iR-ehFBPMQ144RXO87L2UtSgGekHR6n-lliK6m6BjZiRgRwdxm6yzH5F2E9rUDgOVQqFaYblDCZgxpI2bZr19gLvjpUHOHBIPbVXAZ7Mtk2UEqmdFOLii1MRPkuXcpGlATpJF1rivog/s72-c/analog+signal.jpg" height="72" width="72"/><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3037762074085306740.post-989506184140012869</id><published>2011-04-29T09:26:00.001+05:30</published><updated>2011-06-03T21:11:50.417+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Line Follower"/><category scheme="http://www.blogger.com/atom/ns#" term="Projects"/><title type='text'>Projects: Line Follower</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Project: Line Follower&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Author: Gaurav Upreti&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;iframe allowfullscreen=&#39;allowfullscreen&#39; webkitallowfullscreen=&#39;webkitallowfullscreen&#39; mozallowfullscreen=&#39;mozallowfullscreen&#39; width=&#39;320&#39; height=&#39;266&#39; src=&#39;https://www.youtube.com/embed/3TWrgbOC7yg?feature=player_embedded&#39; frameborder=&#39;0&#39;&gt;&lt;/iframe&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;If you are making the same project and wish to contact the author for help, please send a mail to blogger_engg@gmail.com with the subject line: Line_follow@gaurav_upreti.&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techtechila.blogspot.com/feeds/989506184140012869/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://techtechila.blogspot.com/2011/04/projects-line-follower.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3037762074085306740/posts/default/989506184140012869'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3037762074085306740/posts/default/989506184140012869'/><link rel='alternate' type='text/html' href='http://techtechila.blogspot.com/2011/04/projects-line-follower.html' title='Projects: Line Follower'/><author><name>Ashish</name><uri>http://www.blogger.com/profile/11572695506758516927</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3037762074085306740.post-1376620730738201309</id><published>2011-04-28T15:10:00.003+05:30</published><updated>2011-08-22T22:50:07.606+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="16X2 LCD"/><category scheme="http://www.blogger.com/atom/ns#" term="LCD"/><category scheme="http://www.blogger.com/atom/ns#" term="Microcontroller"/><title type='text'>Interfacing LCD</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;LCD or Liquid Crystal Display is fast becoming a preferred choice for use as interface device for displaying over 7-Segment.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Every LCD needs a driver to interface between the microcontroller and LCD module. This driver is included on the LCD module.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1UAh-eY-tjOOJcceB0J2U20NSb3iercUtjNa1huTMXbXNEaewd1jMlDqDx8-grF7MFCGSeVAFCfpZI_ess-YbN64d7cSRUAujLTXjTKi7wW4F9HcPPG6AMCn7kZX9aEg5q_8clRlJYOg/s1600/28042011155.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;181&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1UAh-eY-tjOOJcceB0J2U20NSb3iercUtjNa1huTMXbXNEaewd1jMlDqDx8-grF7MFCGSeVAFCfpZI_ess-YbN64d7cSRUAujLTXjTKi7wW4F9HcPPG6AMCn7kZX9aEg5q_8clRlJYOg/s400/28042011155.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The LCD we are using here is a 16x2 LCD. That means it has 16 columns and 2 rows.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiS7lftiYsdOO3ZLy2LO7MjHyxbf9ReY7tWcWKUvQFlE9G_ljn9Y7hgpUozYiHD1mPSnF3O2qVsLB-0syD02QMqC908x7JcdYKXrTmYUTRI7TKodW54jQPkgEa05ihVeeMGDPzoyK4Oi6Y/s1600/lcd.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;307&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiS7lftiYsdOO3ZLy2LO7MjHyxbf9ReY7tWcWKUvQFlE9G_ljn9Y7hgpUozYiHD1mPSnF3O2qVsLB-0syD02QMqC908x7JcdYKXrTmYUTRI7TKodW54jQPkgEa05ihVeeMGDPzoyK4Oi6Y/s640/lcd.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Pin number 1 and 16 will be written behind the LCD.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The Pin Configuration of the LCD is given below&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLS1p_IlUdp3orPpn-j066wjTLWjY-OKjT_lodgnULiW8dTxIQmM4cf5qj7r0VZrGngfWU_lhLjL5WD_wAa6LOVPAy7LSHnDkjg9q8zEhYqTVHUHEtg7uqzCSnybemgnzrYL3nfq9EKEU/s1600/lcd+pin.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;339&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLS1p_IlUdp3orPpn-j066wjTLWjY-OKjT_lodgnULiW8dTxIQmM4cf5qj7r0VZrGngfWU_lhLjL5WD_wAa6LOVPAy7LSHnDkjg9q8zEhYqTVHUHEtg7uqzCSnybemgnzrYL3nfq9EKEU/s640/lcd+pin.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&amp;nbsp;(&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;open image in separate tab to expand)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The LCD uses three control lines, EN, RS and RW.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The &lt;b&gt;EN&lt;/b&gt; line is called &#39;Enable&#39;. This control line is used to tell the LCD that you are sending it data. To send the data to the LCD, your program should make sure this line is low (0) and then set the other two control lines and/or put data on the data bus. When the other lines are completely ready, bring EN high (1) and wait for the minimum amount of time required ( about 200ns), and end by bringing it low(0) again.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The &lt;b&gt;RS&lt;/b&gt; line is the &#39;Register Select&#39; line. When RS is low(0), the data is to be treated as a command or special instruction (such as clear screen, position cursor, etc.). When RS is high (1), the data being sent is text data which should be displayed on the screen. For example, to display the letter &#39;T&#39; on the screen you would set RS high(1).&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The &lt;b&gt;RW &lt;/b&gt;line is the &#39;Read/Write&#39; control line. When RW is low (0), the information on the data bus is being written to the LCD. When RW is high (1), the program is effectively querying (or reading) the LCD. All commands are write commands except for 1 (&#39;Get LCD status&#39;), which is a read command. Thus, RW will almost always be low.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;4 bit Mode / 8 Bit mode:&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The LCD can work in either 8 bit parallel mode, i.e, then entire 8 bit data can be sent at once, or it can be used in 4 bit mode. In 4 bit mode the 8 bit data is broken into packets of 4 bit data and sent (higher 4 bits first, then lower 4 bits). 4 bit mode simplifies the circuit.&lt;br /&gt;
Upon power on, the LCD is automatically in 8 bit mode.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Here, we are using the LCD in 4-bit mode.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;Initializing the LCD&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Before you may really use the LCD, you must initialize and configure it. This is&amp;nbsp;accomplished&amp;nbsp;by sending a number of initialization instructions to the LCD.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The first instruction we send must tell the LCD we&#39;ll be communicating with it with a 4-bit data bus (4-bit mode). We also need to select a 5x8 dot character font. These two options are selected by sending the command 20h ( &#39;h&#39; denotes hexadecimal format) to the LCD as a command.&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;We&#39;ve now sent the first byte of the initialization sequence. The second byte of the initialization sequence is the instruction 0Fh. This commmand is sent to instruct the the LCD to, &#39;Display on, Cursor Blinking&#39;.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Other commands are also available. Send higher nibble first, then lower nibble.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNySLTuDdufKUsaTkuy3t6d7IkWQnwPkiIrVUvBwAHw7tKV7pQaj3tYuJP4_PWlRItgDhvh0CjxZ3t6XfdxWnRyShLjneVy7BolAtFJsQi67XYg2vrjQU1oJHES8WP_rKEJGJAEn_icN0/s1600/Capture.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNySLTuDdufKUsaTkuy3t6d7IkWQnwPkiIrVUvBwAHw7tKV7pQaj3tYuJP4_PWlRItgDhvh0CjxZ3t6XfdxWnRyShLjneVy7BolAtFJsQi67XYg2vrjQU1oJHES8WP_rKEJGJAEn_icN0/s1600/Capture.JPG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;This circuit diagram can be used as a reference.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhoSPK6ARrW73gEoBBMRv3D3324bNm173qKvnnPR2RaqEv7iih3l8rE7SLybd1wI3elIkdFhyNMOveo2ZZEoTIoZGnI1ccjuBHcA_BczA6Act4bWDtDhq2cKizu9X04no94meqVdOiVvd0/s1600/uNiBoard_LCD.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;522&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhoSPK6ARrW73gEoBBMRv3D3324bNm173qKvnnPR2RaqEv7iih3l8rE7SLybd1wI3elIkdFhyNMOveo2ZZEoTIoZGnI1ccjuBHcA_BczA6Act4bWDtDhq2cKizu9X04no94meqVdOiVvd0/s640/uNiBoard_LCD.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;You can download a header file for your use from &lt;a href=&quot;http://www.2shared.com/file/8F0SDHix/LCD_mega16.html&quot;&gt;here&lt;/a&gt;. The pin connections are mentioned in the header file.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;For any further clarification please leave a comment below or mail us at blogger.engg@gmail.com&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techtechila.blogspot.com/feeds/1376620730738201309/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://techtechila.blogspot.com/2011/04/interfacing-lcd.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3037762074085306740/posts/default/1376620730738201309'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3037762074085306740/posts/default/1376620730738201309'/><link rel='alternate' type='text/html' href='http://techtechila.blogspot.com/2011/04/interfacing-lcd.html' title='Interfacing LCD'/><author><name>Ashish</name><uri>http://www.blogger.com/profile/11572695506758516927</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1UAh-eY-tjOOJcceB0J2U20NSb3iercUtjNa1huTMXbXNEaewd1jMlDqDx8-grF7MFCGSeVAFCfpZI_ess-YbN64d7cSRUAujLTXjTKi7wW4F9HcPPG6AMCn7kZX9aEg5q_8clRlJYOg/s72-c/28042011155.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3037762074085306740.post-7199852094569073552</id><published>2011-04-27T17:24:00.001+05:30</published><updated>2011-06-03T21:12:10.456+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="WinAVR"/><title type='text'>Starting WinAVR</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Setup of WinAVR can be downloaded from this &lt;a href=&quot;http://www.2shared.com/file/b4vySVZ6/WinAVR-20070525-install.html&quot;&gt;link&lt;/a&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Once you are done installing, open the start menu and search for Programmer&#39;s Notepad. Click on it to open.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;It should look something like this.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmW28pEBGrxYhLH9ipXuo9L9Z5gEUMQ9hJ1SXXNA3YI1O55cUZa44U4OqqdKL-_OTjdHCitQ3L3cEJTXS_P55IEcI8HoXdh5eOT5HVBvuN58eHqlWVpj_AFXA97eJ4Z4wyx-xD7TeeN-w/s1600/1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;382&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmW28pEBGrxYhLH9ipXuo9L9Z5gEUMQ9hJ1SXXNA3YI1O55cUZa44U4OqqdKL-_OTjdHCitQ3L3cEJTXS_P55IEcI8HoXdh5eOT5HVBvuN58eHqlWVpj_AFXA97eJ4Z4wyx-xD7TeeN-w/s640/1.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The bar on the left side may or may not be there.&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The program is written in the large white area ( &#39;notepad&#39; ).&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The window at the bottom is called the output window.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The language in which the program is being written can be selected as shown.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHsk1uoMEgI6Y5TnXS43XL-D8A3VT_WtwS89qpcafyp2MYSbo2afjmu3K-armC7nhZThXeSrJd9z3BYLB8MRzC5JsaU59m4aslX26YHNHy6UVEiVXmFlyQm56DY9oRBTsmP-sfxlKW8mU/s1600/2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;381&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHsk1uoMEgI6Y5TnXS43XL-D8A3VT_WtwS89qpcafyp2MYSbo2afjmu3K-armC7nhZThXeSrJd9z3BYLB8MRzC5JsaU59m4aslX26YHNHy6UVEiVXmFlyQm56DY9oRBTsmP-sfxlKW8mU/s640/2.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Once the language has been selected, the program should be written in the notepad.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZaD8NvZn-K5WN36th38SexTxySfnv-i5wQSEzIyX-9SxeZ-1pOrfmPqDrGvLr00ZvM_Fklh8-uextfRhK2zP6g-oKggLHBZKoSVEisNFKyfpzp8mU7TgG26jc6Wf36MWET8bmhbMPdLg/s1600/3.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;381&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZaD8NvZn-K5WN36th38SexTxySfnv-i5wQSEzIyX-9SxeZ-1pOrfmPqDrGvLr00ZvM_Fklh8-uextfRhK2zP6g-oKggLHBZKoSVEisNFKyfpzp8mU7TgG26jc6Wf36MWET8bmhbMPdLg/s640/3.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Once the program is written. Make a new folder and save this program with the extension .c. for example, main.c&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;For every program you write create a separate folder for it.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Once this is done, an mfile has to be created.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Search for &#39;mfile&#39; in the start menu.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;It&#39;ll look something like this.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWrj2a8HSx6su170eHBBjUvnzKM-arhbgmYu7Khv360pHDXEHiGJCG8Q62gsKJDpkViWbp0VbAJ8J_47zi5iQ59z3vuprkhP1pgfALI9Hu-EwYIyC-sfiJ4maPmNnfjuwfWTmzxqL1yMY/s1600/4.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;384&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWrj2a8HSx6su170eHBBjUvnzKM-arhbgmYu7Khv360pHDXEHiGJCG8Q62gsKJDpkViWbp0VbAJ8J_47zi5iQ59z3vuprkhP1pgfALI9Hu-EwYIyC-sfiJ4maPmNnfjuwfWTmzxqL1yMY/s640/4.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;After that, click on &#39;Makefile&#39; and select &#39;Main File Name&#39;.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_pp2-sb2zXS5r7a8eXyA8rGMNKDD2lWTXI7Our2injnoclL7Ke8Ep6ck4Vo99ktgbmrevpLbY5152CgiSh7Gl4euOWaIY3_mzLgtGRjkfwDs8to704qXNvk6n6Z-0Fs93KtFQb8u-fG8/s1600/5.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;387&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_pp2-sb2zXS5r7a8eXyA8rGMNKDD2lWTXI7Our2injnoclL7Ke8Ep6ck4Vo99ktgbmrevpLbY5152CgiSh7Gl4euOWaIY3_mzLgtGRjkfwDs8to704qXNvk6n6Z-0Fs93KtFQb8u-fG8/s640/5.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;A small window will open up. Write the name of the file you have saved. Don&#39;t write the extension of the file. For example, if the name of your file is main.c, write main in that window.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtsGWNibUxlgFJct3hC8hkTRDa9bdTDL7bl9OLfKq2s8-yGX7nJxSBr1duEOOkXwG8EjCn5G-tLdYsDKNjKjmab8Z2LXTLMa8Q6Pf_gqSK7AHXMf_TNN9zcm012GxsBq-zOCXkGIboKD0/s1600/6.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;383&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtsGWNibUxlgFJct3hC8hkTRDa9bdTDL7bl9OLfKq2s8-yGX7nJxSBr1duEOOkXwG8EjCn5G-tLdYsDKNjKjmab8Z2LXTLMa8Q6Pf_gqSK7AHXMf_TNN9zcm012GxsBq-zOCXkGIboKD0/s640/6.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;After that, in &#39;Makefile&#39; select &#39;MCU type&#39; and select the microcontroller you are using.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwKAJLWh9LKPZXIeype__14aDTS5ZsBPHHn0mhI0HiA0X9rC9fI5CsHT_8HJOxjQ53Z31qQgaT_H_yqKsRfVnb-lsvMZJ37bhz5acL7cFqmdQD0EUqdQcd09zQxVeZ2T2EytwqiE2uot0/s1600/7.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;399&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwKAJLWh9LKPZXIeype__14aDTS5ZsBPHHn0mhI0HiA0X9rC9fI5CsHT_8HJOxjQ53Z31qQgaT_H_yqKsRfVnb-lsvMZJ37bhz5acL7cFqmdQD0EUqdQcd09zQxVeZ2T2EytwqiE2uot0/s640/7.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Then in &#39;Makefile&#39; go to &#39;port&#39; and select the port that is being used for programming. This depends on whether the programmer you are using. It may use a USB programmer or COM port or others. If you are not sure, contact the person you bought it from. If it is still not clear, please contact us at blogger.engg@gmail.com, or post your doubt as a comment below and we&#39;ll contact you.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisl2MzfPD3qF4l7rIlunOFVYnGt03l5rEw6FbvBE82Sz-EctLhSs70dFPVAI15-op9XWl9pigHsyi_KS9rwh20M9Gv3OvmRzxEWfdgs7Pza3VmTHOUXP_DHr8CTicBnZNYfhrHr3UPMHc/s1600/8.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;383&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisl2MzfPD3qF4l7rIlunOFVYnGt03l5rEw6FbvBE82Sz-EctLhSs70dFPVAI15-op9XWl9pigHsyi_KS9rwh20M9Gv3OvmRzxEWfdgs7Pza3VmTHOUXP_DHr8CTicBnZNYfhrHr3UPMHc/s640/8.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;After that select the programmer you are using.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh79lLcAqzweg5iHr1SgajOpkgNb8uD78Gin4Rwh66CD6KJhqho1jITfT6Xm6chU4Thz2hawezGs6FOwjXNOoCPdluehTaLlejP_ohbyN2pQ_0SoMykDCCceeBHFaK102NooNjYXz0CJkg/s1600/9.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;398&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh79lLcAqzweg5iHr1SgajOpkgNb8uD78Gin4Rwh66CD6KJhqho1jITfT6Xm6chU4Thz2hawezGs6FOwjXNOoCPdluehTaLlejP_ohbyN2pQ_0SoMykDCCceeBHFaK102NooNjYXz0CJkg/s640/9.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Some programmer like USBASP are not mentioned in this. To select those programmers, select any programmer you want, then click on enable editing of makefile in &#39;Makefile&#39; and in place of the text highlighted in yellow write the programmer you are using, in small letters (e.g usbasp)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRvNdDnAQdGw9kWzTSn9lIjvAtRHaC1JuCfWCjHuvxDg0CJPEdm2cZCb3BWnR5eSr25ZgELsML2i2GWZzZPjKF4kOjZ7-_SGIv9zuT_a8OjW2bnBv0XyWYixObIYcsR9L4xhrfXGltZPY/s1600/10.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;385&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRvNdDnAQdGw9kWzTSn9lIjvAtRHaC1JuCfWCjHuvxDg0CJPEdm2cZCb3BWnR5eSr25ZgELsML2i2GWZzZPjKF4kOjZ7-_SGIv9zuT_a8OjW2bnBv0XyWYixObIYcsR9L4xhrfXGltZPY/s640/10.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Once you have selected enable editing of makefile, scroll up to find the text as shown in the picture below, and change the entry encircled below to the frequency of the crystal you are using.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsk9a5U-LOnTjb-fr4TNGxub4qgpVsHmiwrTr9-h0j2w46QXzA5vxvjpU7ySyTyigGR6nY3UqRDLXs6YiSeyAZU2hfad3M1oIG294jrFpFoZspPqzCPITXJHuPYNwMIcUFWoq3193vQGc/s1600/11.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsk9a5U-LOnTjb-fr4TNGxub4qgpVsHmiwrTr9-h0j2w46QXzA5vxvjpU7ySyTyigGR6nY3UqRDLXs6YiSeyAZU2hfad3M1oIG294jrFpFoZspPqzCPITXJHuPYNwMIcUFWoq3193vQGc/s640/11.jpg&quot; width=&quot;640&quot; /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;After this go to &#39;File&#39; in the mfile box only, and click &#39;Save As&#39;. This file should be saved in the same folder that your .c file has been saved with the name &#39;Makefile&#39;. If this name is already displayed, don&#39;t change it. This file should not be saved with&amp;nbsp;any other&amp;nbsp;name.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Go back to programmer&#39;s notepad, go to &#39;Tools&#39;, select &amp;nbsp;&#39;Make All&#39;. This creates the hex file ( this file will be present in the folder) which is required to program your microcontroller. Syntax or mfile related errors, if any, are shown in this step in the the output window.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Make sure that your programmer is connected, and then go to &#39;Tools&#39; and select &#39;Program&#39;.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;That&#39;s it. Your microcontroller is programmed!&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;If you are not sure how to use your programmer, contact the person you bought it from. If it is still not clear, or you have any doubts in the above steps please contact us at blogger.engg@gmail.com, or post your doubt as a comment below and we&#39;ll contact you.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techtechila.blogspot.com/feeds/7199852094569073552/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://techtechila.blogspot.com/2011/04/starting-winavr.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3037762074085306740/posts/default/7199852094569073552'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3037762074085306740/posts/default/7199852094569073552'/><link rel='alternate' type='text/html' href='http://techtechila.blogspot.com/2011/04/starting-winavr.html' title='Starting WinAVR'/><author><name>Ashish</name><uri>http://www.blogger.com/profile/11572695506758516927</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmW28pEBGrxYhLH9ipXuo9L9Z5gEUMQ9hJ1SXXNA3YI1O55cUZa44U4OqqdKL-_OTjdHCitQ3L3cEJTXS_P55IEcI8HoXdh5eOT5HVBvuN58eHqlWVpj_AFXA97eJ4Z4wyx-xD7TeeN-w/s72-c/1.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3037762074085306740.post-5354990415786241103</id><published>2011-04-25T13:12:00.002+05:30</published><updated>2011-06-03T21:13:02.150+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="pull down"/><category scheme="http://www.blogger.com/atom/ns#" term="Pull up"/><category scheme="http://www.blogger.com/atom/ns#" term="Switch"/><title type='text'>Using a switch with a Microcontroller</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;, w &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Suppose you want to use a switch with a microcontroller.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Please go through this article on &#39; &lt;a href=&quot;http://techtechila.blogspot.com/2011/02/pull-ups-and-pull-downs.html&quot;&gt;Pull Ups and Pull Downs&lt;/a&gt; &#39; before starting.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;We&#39;ll assume that the switch will give a 0 when it is pressed and that the switch is connected at PB.0 .&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkF73-BPvef8exI9CH9lchEK02i1fjtGh10N6BzsJDvkW_4t8vEWrxXG98OE2cIWqKrgS4GO2wkeP3M7rMT1D_iR__XszxH-lcv16hcy0bNm5_KNZrzd70V2urUtpeZ-wwZjZwjWGhvJE/s1600/Untitled1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkF73-BPvef8exI9CH9lchEK02i1fjtGh10N6BzsJDvkW_4t8vEWrxXG98OE2cIWqKrgS4GO2wkeP3M7rMT1D_iR__XszxH-lcv16hcy0bNm5_KNZrzd70V2urUtpeZ-wwZjZwjWGhvJE/s1600/Untitled1.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Thus, the pin of the Microcontroller at which the switch is connected will get a 0 when the switch is pressed.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;If that pin is already at 0, in this case the microcontroller will not be able to detect that a switch is pressed as there will be no change on the status of the pin.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;So, to positively detect a switch press at PB.0 we need to set it to 1, i.e pull-it-up.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Since, we have to check/detect/receive an input on PB.0, we need to make that as an input port, i.e&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;DDRB=0b00000000; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Since I am not using the other pins of PortB, it does not matter whether I write 1 or 0 to them. If the other pins are being used as output, then we should set PB.0 as input using the unary OR, denoted by &#39; | &#39;, operator.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;after DDRB, we need to give the PORT command,&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;PORTB=0b00000001; &amp;nbsp; // make PB.0 as 1.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The following picture shows, what happens when we give a 1 to a pin, declared as output, to which LED are connected. Notice the intensity of the LED.&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEignKCetXMVRmqGETn2eJfIL-kzJIFfkN91xYv-ULCUp8s1w8hoG9df4Snm8v3wHxH59abzHc76v7T2EYwo0u-dvD007skIpfMiRS2iApilGZI9dcpH7U9jUlnJqUFHv3jbJ_o46bB24DU/s1600/25042011147.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEignKCetXMVRmqGETn2eJfIL-kzJIFfkN91xYv-ULCUp8s1w8hoG9df4Snm8v3wHxH59abzHc76v7T2EYwo0u-dvD007skIpfMiRS2iApilGZI9dcpH7U9jUlnJqUFHv3jbJ_o46bB24DU/s320/25042011147.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;In the next picture we declared the pins connected to the LED as input and then set the pins to 1.&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoFuTQCgZGQMzOlBuWl1UF_KGEep5Kr9-XW7sJzWIxAjywM6HGujttZTaP1S5PNidpmuc7YIGgJ44_XOFyv_HNTtJVYnvVjWILe3_bMCKmXbFlULXXul7_6E4E2sWhKHSbzVs1B36vS_8/s1600/25042011149.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoFuTQCgZGQMzOlBuWl1UF_KGEep5Kr9-XW7sJzWIxAjywM6HGujttZTaP1S5PNidpmuc7YIGgJ44_XOFyv_HNTtJVYnvVjWILe3_bMCKmXbFlULXXul7_6E4E2sWhKHSbzVs1B36vS_8/s320/25042011149.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Notice the change in intensity?&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;In the case when the port is declared as input and we still try to give an output to it, a small amount of current is provided on those pins as compared to when the port has been declared as output.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Now, using the same logic in case of switches.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;We&#39;ll declare the pin to which the switch is connected as input and give an output on it, so that a small current is provided on it. Thus,&amp;nbsp;every time&amp;nbsp;the switch is pressed, the pin&amp;nbsp;receives&amp;nbsp;a definite 0.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;#include&amp;lt;avr/io.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;#include&amp;lt;util/delay.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;void main()&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;{&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp; DDRC=0b11111111; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// assuming that LED&#39;s are connected at PortC.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp; DDRB=0x00; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;// making PB.0 as input (here, other pins will also become input, but since we&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;// are not using them, it doesn&#39;t matter)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;PORTB=0b00000001; &amp;nbsp; // give a 1 on PB.0 to provide a small current on it.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;while(1)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;{ &amp;nbsp;if(PINB==0b00000000) &amp;nbsp; // &#39;PIN&#39; is used for checking input&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; { &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// when switch is pressed, entire port becomes 0&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PORTC=0xff; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // we could also have written if(PINB==0)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; } &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; else&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; PORTC=0x00;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;In the above program, LED glow only when the switch is pressed.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&#39;allowfullscreen&#39; webkitallowfullscreen=&#39;webkitallowfullscreen&#39; mozallowfullscreen=&#39;mozallowfullscreen&#39; width=&#39;320&#39; height=&#39;266&#39; src=&#39;https://www.youtube.com/embed/TdyspRIZZy4?feature=player_embedded&#39; frameborder=&#39;0&#39;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techtechila.blogspot.com/feeds/5354990415786241103/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://techtechila.blogspot.com/2011/04/using-switch-with-microcontroller.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3037762074085306740/posts/default/5354990415786241103'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3037762074085306740/posts/default/5354990415786241103'/><link rel='alternate' type='text/html' href='http://techtechila.blogspot.com/2011/04/using-switch-with-microcontroller.html' title='Using a switch with a Microcontroller'/><author><name>Ashish</name><uri>http://www.blogger.com/profile/11572695506758516927</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkF73-BPvef8exI9CH9lchEK02i1fjtGh10N6BzsJDvkW_4t8vEWrxXG98OE2cIWqKrgS4GO2wkeP3M7rMT1D_iR__XszxH-lcv16hcy0bNm5_KNZrzd70V2urUtpeZ-wwZjZwjWGhvJE/s72-c/Untitled1.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3037762074085306740.post-7084537293913391935</id><published>2011-04-24T18:47:00.003+05:30</published><updated>2011-06-03T21:12:25.928+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="LED"/><title type='text'>Playing with LED</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;.&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;In this post we&#39;ll make a scrolling pattern on the LED&#39;s (watch the video).&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Just like last time, we&#39;ll consider that we have 8 LED&#39;s connected to PortC.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Now, the LED have to be turned ON, only one at a time, and they should remain ON for some time (say, 500 milliseconds).&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;#include&amp;lt;avr/io.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;#include&amp;lt;util/delay.h&amp;gt; &amp;nbsp; // header file for generating delay&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;void main()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;{ DDRC=0b11111111; &amp;nbsp; &amp;nbsp;// Since, PortC is output, thus, all 8 bits are declared 1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;PORTC=0x00; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // initially all LED will be off.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;/*&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Note: If on your development board, the LED are connected in Active Low configuration, they will turn ON when a &#39;0&#39; is given. If the LED are active high, they will turn ON when &#39;1&#39; is given. If you are not sure whether your LED are active high or active low, just give 1 and see what happens.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Here, I am assuming that LED are active high.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;while(1) &amp;nbsp; // infinite loop so that the process inside is executed all the time.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;{ &amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp; PORTC=0b00000001;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp; _delay_ms(500);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp; PORTC=0b00000010;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp; _delay_ms(500);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp; PORTC=0b00000100;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp; _delay_ms(500);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp; PORTC=0b00001000;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp; _delay_ms(500);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp; PORTC=0b00010000;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp; _delay_ms(500);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp; PORTC=0b00100000;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp; _delay_ms(500);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;PORTC=0b01000000;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp; _delay_ms(500);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;PORTC=0b10000000;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp; _delay_ms(500);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;In the above program, we make only one LED on at a time, give a delay, and then turn on the next LED and switch off the other LED by writing 1 to the LED which we want to turn ON and the rest are 0.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The above program, though simple, is cumbersome to write.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;We&#39;ll write the above program in a different way&amp;nbsp;utilizing&amp;nbsp;the vast potential of C.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;#include&amp;lt;avr/io.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;#include&amp;lt;util/delay.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;volatile unsigned char x=0; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;void main()&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;DDRC=0b11111111; &amp;nbsp; // Declare entire PortC as output&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;PORTC=0b00000000; &amp;nbsp; // Make PortC initially 0.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;while(1)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;{ x=0;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;while(x&amp;lt;8) &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // execute this part till x is less than 8&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;{ PORTC=(1&amp;lt;&amp;lt;x); &amp;nbsp; &amp;nbsp;// shift 1 by &#39;x&#39; spaces.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;_delay_ms(500);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;x=x+1; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // increment x.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;}&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;We would like to point out one very important thing about Embedded C at this point.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Notice the &#39;volatile unsigned char x=0&#39; before the main() ?&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;In embedded C, all variables that are to be used should be defined and&amp;nbsp;initialized&amp;nbsp;before the main() starts.&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&#39;allowfullscreen&#39; webkitallowfullscreen=&#39;webkitallowfullscreen&#39; mozallowfullscreen=&#39;mozallowfullscreen&#39; width=&#39;320&#39; height=&#39;266&#39; src=&#39;https://www.youtube.com/embed/AkujKb2REOc?feature=player_embedded&#39; frameborder=&#39;0&#39;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techtechila.blogspot.com/feeds/7084537293913391935/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://techtechila.blogspot.com/2011/04/playing-with-leds.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3037762074085306740/posts/default/7084537293913391935'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3037762074085306740/posts/default/7084537293913391935'/><link rel='alternate' type='text/html' href='http://techtechila.blogspot.com/2011/04/playing-with-leds.html' title='Playing with LED'/><author><name>Ashish</name><uri>http://www.blogger.com/profile/11572695506758516927</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3037762074085306740.post-8154350363613004142</id><published>2011-04-03T11:07:00.007+05:30</published><updated>2011-04-24T10:27:27.887+05:30</updated><title type='text'>Our First Program</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Let&#39;s write a program to simply turn on LED&#39;s.&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;We will use the Programmer&#39;s Notepad of WinAVR.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;WinAVR can be downloaded from this &lt;a href=&quot;http://www.2shared.com/file/b4vySVZ6/WinAVR-20070525-install.html&quot;&gt;link&lt;/a&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Once WinAVR is installed, open Programmer&#39;s Notepad and start typing. Save the file with a .c extension. example, led.c .&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;We will assume that we have 8 LED&#39;s, connected to the 8 pins of Port C.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Step 1: Declare the Ports to be used as output or input (as required).&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;In this case the LED’s connected to Port&amp;nbsp; C have to be turned ON, i.e a current has to be supplied to the LED. Thus, Port C should be OUTPUT.&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;line-height: 115%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Thus, the Data Direction Register for Port C is&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;thus, we can write&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&amp;nbsp;DDRC=0b1111111;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;This statement makes the PortC output port. Since, we need only PortC in this particular case, we are not going to specify for other Ports.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Step 2: &amp;nbsp;Turn ON the LED &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Now, to turn on the LED&#39;s, we need to give a &#39;1&#39; to the Port.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;thus,&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;PORTC=0b11111111;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Thus, the program can be written like this:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;#include&amp;lt;avr/io.h&amp;gt; // standard library to be included when using WinAVR&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;void main()&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;{ &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp; DDRC=0b11111111; &amp;nbsp; // Declare PortC as output Port&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp; PORTC=0b11111111;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;This program will turn on the LED&#39;s connected to PortC.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Here we have considered 8 LED&#39;s. If, let&#39;s say 3 LED&#39;s were connected to PC0, PC1, PC2, then only these 3 pins need to be written &#39;1&#39;, the rest can be &#39;0&#39; or &#39;1&#39; (if they are not being used anywhere else)&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;thus,&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;DDRC=0b00000111;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;PORTC=0b00000111;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Once you have installed WinAVR, in the libraries folder, there will be a folder &#39;util&#39; which will contain a file &#39;delay.h&#39;. This file contains pre-defined functions to generate delays of the order of milli-seconds and micro-seconds.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Let&#39;s modify the program by turning the LED&#39;s ON and OFF with a delay of 500 milli-seconds.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;#include&amp;lt;avr/io.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;#include&amp;lt;util/delay.h&amp;gt; &amp;nbsp;// include this header file to use the functions defined&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// for generating a delay&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;void main()&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;{&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;DDRC=0b11111111; &amp;nbsp; &amp;nbsp;// Declare PortC as output Port&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;PORTC=0b11111111; &amp;nbsp;// Give a &#39;1&#39; to all the pins of PortC thus turning ON the LED&#39;s &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;while(1) &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// this is an infinite loop.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&amp;nbsp;{&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&amp;nbsp;PORTC=0b11111111; &amp;nbsp;// Give a &#39;1&#39; to all the pins of PortC thus turning ON the LED&#39;s&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;_delay_ms(500); &amp;nbsp; &amp;nbsp; &amp;nbsp; // hold the LED ON for 500 millisecond&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;PORTC=0b00000000; &amp;nbsp; // Turn OFF all the LED&#39;s&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;_delay_ms(500); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// hold the LED OFF for 500 millisecond&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;The function _delay_ms(x) generates a delay of x milli-seconds.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;The above program will blink the LED&#39;s.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;We used an infinite loop in the above program because we wanted the LED&#39;s to continue blinking forever. Had we not written the part for blinking the LED&#39;s inside the infinite loop, the LED&#39;s would have blinked just once. &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&#39;allowfullscreen&#39; webkitallowfullscreen=&#39;webkitallowfullscreen&#39; mozallowfullscreen=&#39;mozallowfullscreen&#39; width=&#39;320&#39; height=&#39;266&#39; src=&#39;https://www.youtube.com/embed/1-LkKAxi-Hg?feature=player_embedded&#39; frameborder=&#39;0&#39;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;In the video above, only 4 LED are blinking.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;In the next post we will again play around with the LED&#39;s, generating some new patterns and probably some &#39;disco LED&#39; &amp;nbsp;:D&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techtechila.blogspot.com/feeds/8154350363613004142/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://techtechila.blogspot.com/2011/04/our-first-program.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3037762074085306740/posts/default/8154350363613004142'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3037762074085306740/posts/default/8154350363613004142'/><link rel='alternate' type='text/html' href='http://techtechila.blogspot.com/2011/04/our-first-program.html' title='Our First Program'/><author><name>Ashish</name><uri>http://www.blogger.com/profile/11572695506758516927</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3037762074085306740.post-2747173806109164995</id><published>2011-02-19T20:33:00.001+05:30</published><updated>2011-05-07T16:07:46.268+05:30</updated><title type='text'>Pull Ups and Pull Downs</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 20px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h2 style=&quot;background-color: inherit; color: black; margin-bottom: 5px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif; font-size: small; font-weight: normal;&quot;&gt;Pull up and Pull Down. &lt;/span&gt;&lt;/h2&gt;&lt;h2 style=&quot;background-color: inherit; color: black; margin-bottom: 5px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif; font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif; font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;Pull up and Pull down is a very simple concept.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif; font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;Let&#39;s try to understand it through an example.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif; font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;entrytext&quot;&gt;&lt;div style=&quot;background-color: inherit; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Take the case of a simple NOT gate. It simply negates the input.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: inherit; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; style=&quot;background-color: inherit; color: #494949; font-size: 13px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;img height=&quot;158&quot; src=&quot;http://www.triindia.co.in/resources_images/PUPD/not%20gate%20logic.jpg&quot; style=&quot;background-color: inherit; color: inherit; display: inline;&quot; width=&quot;407&quot; /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: inherit; color: #494949; font-size: 13px; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;table align=&quot;center&quot; border=&quot;1&quot; style=&quot;color: #303030; font-size: 13px; width: 242px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td bgcolor=&quot;#cccccc&quot; width=&quot;108&quot;&gt;&lt;div align=&quot;center&quot;&gt;Input&lt;/div&gt;&lt;/td&gt;&lt;td bgcolor=&quot;#cccccc&quot; width=&quot;118&quot;&gt;&lt;div align=&quot;center&quot;&gt;Output&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;div align=&quot;center&quot;&gt;0&lt;/div&gt;&lt;/td&gt;&lt;td&gt;&lt;div align=&quot;center&quot;&gt;1&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;div align=&quot;center&quot;&gt;1&lt;/div&gt;&lt;/td&gt;&lt;td&gt;&lt;div align=&quot;center&quot;&gt;0&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;background-color: inherit; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: inherit; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;But, What would appear at the output if the input is left unconnected? Will it be a Logic 0 or a Logic 1?&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;You might say that since there is no connection at the input, the voltage at the input pin would be Logic 0 and hence the output of the NOT gate shall be high.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;But, have any of you ever observed an output from a not gate without any input?.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;When nothing is connected to the input pin, the pin isn’t at zero volts but its “floating”. (In electronics, an unconnected input pin is termed as floating) In the digital world, particularly TTL, any floating input is considered as Logic 1. But it’s never a good idea to leave the input pins unconnected. Why? Well, that’s because noise generated by adjacent electrical activity can induce a significant amount of voltage across the input which could result in errant behavior of the system.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: inherit; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; style=&quot;background-color: inherit; color: #494949; font-size: 13px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;img height=&quot;79&quot; src=&quot;http://www.triindia.co.in/resources_images/PUPD/not%20no%20input.jpg&quot; style=&quot;background-color: inherit; color: inherit; display: inline;&quot; width=&quot;201&quot; /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: inherit; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: inherit; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Hence, its always advisable to have a default value at the inputs. This can be achieved by connecting pull-up or pull-down resistors at the inputs.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: inherit; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; style=&quot;background-color: inherit; color: #494949; font-size: 13px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;img height=&quot;140&quot; src=&quot;http://www.triindia.co.in/resources_images/PUPD/not%20with%20pullup.jpg&quot; style=&quot;background-color: inherit; color: inherit; display: inline;&quot; width=&quot;479&quot; /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: inherit; color: #494949; font-size: 13px; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;background-color: inherit; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;The same logic applies while interfacing devices to the microcontroller. Most of the microcontrollers available have inbuilt pull-up resistors which can be enabled or disabled through software. These prove to be very handy while connecting external devices, say for example a switch. But, when internal pull-ups are not available, we need to connect external pull-ups. Pull-downs can also be connected, but we need to make sure that there are no internal pull-ups activated on that particular port.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: inherit; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; style=&quot;background-color: inherit; color: #494949; font-size: 13px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;img height=&quot;222&quot; src=&quot;http://www.triindia.co.in/resources_images/PUPD/swtch%20interface.jpg&quot; style=&quot;background-color: inherit; color: inherit; display: inline;&quot; width=&quot;187&quot; /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: inherit; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: inherit; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;In the figure above, the switch is connected in an active-low configuration. Which means whenever you press the switch, logic 0 appears at the input. Thus, the code will be written accordingly.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: inherit; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;eg:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: inherit; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;if (switch==0)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//switch pressed&lt;br /&gt;
}&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: inherit; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;else &amp;nbsp; //switch open&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: inherit; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: inherit; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;There are no specific values for such pull-ups or pull-downs; they could be anywhere between 1K and 47K.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;( source: ThinkLabs Technosolutions)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techtechila.blogspot.com/feeds/2747173806109164995/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://techtechila.blogspot.com/2011/02/pull-ups-and-pull-downs.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3037762074085306740/posts/default/2747173806109164995'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3037762074085306740/posts/default/2747173806109164995'/><link rel='alternate' type='text/html' href='http://techtechila.blogspot.com/2011/02/pull-ups-and-pull-downs.html' title='Pull Ups and Pull Downs'/><author><name>Ashish</name><uri>http://www.blogger.com/profile/11572695506758516927</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3037762074085306740.post-8521887978418167745</id><published>2011-02-13T20:46:00.000+05:30</published><updated>2011-02-18T21:40:23.267+05:30</updated><title type='text'>Set Operation</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Setting a bit in a Register:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;In Embedded C, binary numbers are represented with a &#39;0b&#39; prefix. To represent a hexadecimal number, put a &#39;0x&#39; instead of &#39;0b&#39;. Decimal numbers can be written directly, they don&#39;t need any prefixes.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Let us consider an 8 bit register, ADMUX. And our aim is to assign the 5th bit (the right most bit is the 1st bit) a value of logical 1. The syntax will be&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;ADMUX=0b00010000;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;When the above statement is processed, the 5th bit will be set to 1, and the rest set to logical 0.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Now, if we want to set the 1st bit also 1, without changing the status of the 5th bit,&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;ADMUX=0b00010001;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Suppose the above line is the 1st line of our program, if we want to change the value of the 3rd bit of this register ADMUX, without changing the value of any other bit, we will have to retrace it back through our code, which will be very cumbersome. Hence, we use &lt;b&gt;|&lt;/b&gt; (OR) bit wise operator. It performs bitwise OR.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Example: &amp;nbsp;0b11001101 | 0b00000010&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 1 0 0 1 1 0 1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; OR &amp;nbsp; 0 0 0 0 0 0 1 0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Result: &amp;nbsp;1 1 0 0 1 1 1 0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;As we can see, in the 2nd number only the 2nd bit from the right was set to 1. When bitwise OR operation was performed of this number with 11001101, the result obtained was same as the first number except for the 2nd bit, which had changed to 1. Thus, the bit had been SET.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Hence, for Setting a particular bit of a register, without disturbing the contents of the other bits, we perform bitwise OR operation ( | ) of the register with a binary number which has a 1 at the position of the bit we want to set in the register.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;e.g: &amp;nbsp;ADMUX= ADMUX | (0b00001000);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;This can also be written as&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;ADMUX|=(0b00001000);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;In practice, each bit has got a name according to the function it performs. Let&#39;s say the 5th bit has got a name ADEN &amp;nbsp;(ADC Enable), it is used to enable the ADC. When it is set to 1, the ADC function of the microcontroller is enabled. When it is 0 it is disabled.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 17px;&quot;&gt;If we employ the syntax explained above, we will have to check the datasheet all the time to verify the position of ADEN. The following syntax circumvents that,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 17px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 17px;&quot;&gt;ADEN|=(1&amp;lt;&amp;lt;ADEN);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 17px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 17px;&quot;&gt;The &lt;b&gt;&amp;lt;&amp;lt;&lt;/b&gt; is called the &lt;b&gt;left shift operator&lt;/b&gt;. It shifts the bits of the variable on its left hand side by the number of places specified by the number on its right hand side.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 17px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 17px;&quot;&gt;If we write.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 17px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;line-height: 17px; margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 5px; padding-right: 0px; padding-top: 5px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;b&gt;A&lt;/b&gt;=1&amp;lt;&amp;lt;4;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 17px; margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 5px; padding-right: 0px; padding-top: 5px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;then, 1, whose binary value is 00000001 is shifted 3 places to the left. The result is 00001000.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 17px; margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 5px; padding-right: 0px; padding-top: 5px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;So, if ADEN is the 5th bit,&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 17px; margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 5px; padding-right: 0px; padding-top: 5px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;ADMUX|=(1&amp;lt;&amp;lt;ADEN);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 17px; margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 5px; padding-right: 0px; padding-top: 5px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;will result in&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 17px; margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 5px; padding-right: 0px; padding-top: 5px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;ADMUX|=(1&amp;lt;&amp;lt;5);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 17px; margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 5px; padding-right: 0px; padding-top: 5px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;which will result in&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 17px; margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 5px; padding-right: 0px; padding-top: 5px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;ADMUX|=(0b00100000);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 17px; margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 5px; padding-right: 0px; padding-top: 5px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;What is this better? Why should I prefer this method?&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 17px; margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 5px; padding-right: 0px; padding-top: 5px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;This is why this method is much better:&lt;/span&gt;&lt;/div&gt;&lt;ol style=&quot;list-style-position: inside; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 15px; padding-right: 0px; padding-top: 2px; text-align: left;&quot;&gt;&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 17px;&quot;&gt;&lt;b&gt;Readability of code&lt;/b&gt;: ADMUX|=(1&amp;lt;&amp;lt;ADEN); tells you what bit is being set. It tells you that here the ADC is being enabled. ADEN=5 is already defined in the header file of that microcontroller.&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 17px;&quot;&gt;&lt;b&gt;Portable&lt;/b&gt;: Let&#39;s say that &amp;nbsp;you use this code is really useful and has been used several times in a very long program. You need this code to run on another microcontroller. This other microcontroller belongs to the same family as your old one, but the positions of the bits (bit scheme) is slightly different, i.e ADEN may be at bit 2 instead of 5. You&#39;ll have to find all occurences of ADMUX|=(0b00010000); and change them to ADMUX|=0b00000010; But, if you have used the other method you dont have to make any changes in your code as the position of ADEN would have been specified in the header file for that particular microcontroller.&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;/span&gt;&lt;/ol&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 17px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techtechila.blogspot.com/feeds/8521887978418167745/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://techtechila.blogspot.com/2011/02/set-operation.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3037762074085306740/posts/default/8521887978418167745'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3037762074085306740/posts/default/8521887978418167745'/><link rel='alternate' type='text/html' href='http://techtechila.blogspot.com/2011/02/set-operation.html' title='Set Operation'/><author><name>Ashish</name><uri>http://www.blogger.com/profile/11572695506758516927</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3037762074085306740.post-9137381477749544444</id><published>2011-02-13T00:24:00.000+05:30</published><updated>2011-02-13T00:24:33.522+05:30</updated><title type='text'>Binary Numbers</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;While programming Microcontrollers in C, most of the time we have to deal with registers. We may have to &#39;SET&#39; the bits of a register, &#39;CLEAR&#39; the bits of a register or &#39;CHECK&#39; the status of a particular bit of a register. Before we do all this, let us first take a look at binary numbers and conversion to decimal number system.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;A &lt;b&gt;register&lt;/b&gt; is simply a collection of some bits.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;When you pick up a microcontroller&#39;s datasheet, it&#39;ll say that, that particular microcontroller is a &#39;8 bit Microcontroller&#39; or &#39;4 bit microcontroller&#39; etc. It means that the register is 8 bits or 4 bits long respectively.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Now, each bit of this register can hold either a &#39;0&#39; (zero) or &#39;1&#39; (one).&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Let&#39;s consider a variable &#39;&lt;b&gt;A&lt;/b&gt;&#39; which has a binary value 1101 (read as, one one zero one).&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;To convert &lt;b&gt;A&lt;/b&gt; to decimal form, follow the following steps:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Assign precedence values 0,1,2,3..and so on, to each binary bit starting from the right most bit.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Thus in the case of &lt;b&gt;A&lt;/b&gt;:&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwAX3U-e5VVeNUeTphVWVE2n1XkItNkyCwqIT_eqlI7jBIE0ZGzEZwCROn4j_44O4t_ihKjZ5Z-YuJ5ewlvMocb0Ks6wapq3Bp0rOb38bF-QGfK4kgtO4gt-4KbW5NopCMb07HPp6cBLg/s1600/bits.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;40&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwAX3U-e5VVeNUeTphVWVE2n1XkItNkyCwqIT_eqlI7jBIE0ZGzEZwCROn4j_44O4t_ihKjZ5Z-YuJ5ewlvMocb0Ks6wapq3Bp0rOb38bF-QGfK4kgtO4gt-4KbW5NopCMb07HPp6cBLg/s640/bits.jpg&quot; width=&quot;640&quot; /&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&amp;nbsp;Now, multiply each bit with 2^precedence value. Then add up all the results.&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&amp;nbsp;Therefore,&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;b&gt;A&lt;/b&gt; (in decimal form) =&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;1x2&lt;sup&gt;3&lt;/sup&gt; + 1x2&lt;sup&gt;2&lt;/sup&gt; + 0x2&lt;sup&gt;1&lt;/sup&gt; + 1x2&lt;sup&gt;0&lt;/sup&gt; = 1x8 + 1x4 + 0x2 + 1x1 = 8+4+0+1=13&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Thus, decimal form of 1101 is 13.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Here, &lt;b&gt;A&lt;/b&gt; was a 4 bit register.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Now, consider &lt;b&gt;A&lt;/b&gt; to be an 8 bit register. The maximum binary value possible for &lt;b&gt;A&lt;/b&gt;=11111111.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Assigning precedence values to &lt;b&gt;A&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9N8QGMsOM71du9gTKix0LVcElpcqYAiWuqAJUo7BlUUiMGhjZZJ-3-Eryd7aIV40tn7ToTA8rePOquffa0fp_OZa3cU50a93chEKDHqYzNoY_AKUsPxYWqI3uKYA5x_CcfIji8NpNvV8/s1600/bits.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;50&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9N8QGMsOM71du9gTKix0LVcElpcqYAiWuqAJUo7BlUUiMGhjZZJ-3-Eryd7aIV40tn7ToTA8rePOquffa0fp_OZa3cU50a93chEKDHqYzNoY_AKUsPxYWqI3uKYA5x_CcfIji8NpNvV8/s640/bits.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Using the same method again, we get A (in decimal form)= 255. Thus, the maximum value of an 8 bit register is 255.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;b&gt;Binary Numbers in C:&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;When you write &lt;b&gt;A&lt;/b&gt;=101, in a C program, the compiler will interpret it as &lt;b&gt;one hundred and one&lt;/b&gt;, which is a &lt;b&gt;decimal&lt;/b&gt;&amp;nbsp;number. To specify that a number is binary, we need to prefix a &#39;&lt;b&gt;0b&lt;/b&gt;&#39; before that number.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;The statement,&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;b&gt;A&lt;/b&gt;=0b11001101;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;implies that &lt;b&gt;A&lt;/b&gt; stores a binary value 11001101 (one one zero zero one one zero one). The bit pattern 11001101 is assigned to &lt;b&gt;A&lt;/b&gt;. Here, &lt;b&gt;A&lt;/b&gt; is assumed to be a 8 but register. If &lt;b&gt;A&lt;/b&gt; were a 4 bit register, then only the first 4 bits, from the right would be stored and the rest would be neglected.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;sup&gt;&lt;br /&gt;
&lt;/sup&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techtechila.blogspot.com/feeds/9137381477749544444/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://techtechila.blogspot.com/2011/02/binary-numbers.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3037762074085306740/posts/default/9137381477749544444'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3037762074085306740/posts/default/9137381477749544444'/><link rel='alternate' type='text/html' href='http://techtechila.blogspot.com/2011/02/binary-numbers.html' title='Binary Numbers'/><author><name>Ashish</name><uri>http://www.blogger.com/profile/11572695506758516927</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwAX3U-e5VVeNUeTphVWVE2n1XkItNkyCwqIT_eqlI7jBIE0ZGzEZwCROn4j_44O4t_ihKjZ5Z-YuJ5ewlvMocb0Ks6wapq3Bp0rOb38bF-QGfK4kgtO4gt-4KbW5NopCMb07HPp6cBLg/s72-c/bits.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3037762074085306740.post-4523591512375983623</id><published>2011-02-01T07:29:00.002+05:30</published><updated>2011-06-03T21:13:14.562+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="DDR"/><category scheme="http://www.blogger.com/atom/ns#" term="PIN"/><category scheme="http://www.blogger.com/atom/ns#" term="PORT"/><title type='text'>DDR, PORT, PIN</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 16px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;The contents of DDR decide whether a particular pin of the microcontroller acts as an INPUT pin, that is, it’ll be used to get an input from the outside world, or as an output, that is, it’ll be used to give an output to the outside world.&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;For DDR register,&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&amp;nbsp;1 --&amp;gt; Output&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;0 --&amp;gt; Input&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;If I set a particular bit of the DDR register as 1, it means that the pin number, corresponding to that&amp;nbsp; bit number will work as an output pin. If a bit is made 0, the pin number corresponding to that particular bit will act as in input.&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;Please note that pin number and bit number count starts from 0. That means, PA0 is the 1st pin and PA7 is the 8th pin.&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;Let’s say we want the 3rd pin ( that means, PA2) of Port A to function as an output pin. This is what the DDRA register will look like&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;photo photo_none&quot; style=&quot;clear: both; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;div class=&quot;photo_img&quot; style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;img class=&quot;img&quot; height=&quot;151&quot; src=&quot;http://sphotos.ak.fbcdn.net/hphotos-ak-snc4/hs1238.snc4/157007_186831161330552_122819407731728_707978_6613184_n.jpg&quot; style=&quot;border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; width: 393px;&quot; width=&quot;640&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;Thus, while writing the program in WinAVR, we can simply write the statement as&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;DDRA=0x80;&amp;nbsp;&amp;nbsp; // this statement will make PA2 an output pin&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;Similarly, PORTA is used for assigning a HIGH (1) or a LOW (0) signal to an output pin.&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;When we want to check whether an input pin is receiving a HIGH (1) or a LOW (0) we use PIN.&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techtechila.blogspot.com/feeds/4523591512375983623/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://techtechila.blogspot.com/2011/01/ddr-port-pin.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3037762074085306740/posts/default/4523591512375983623'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3037762074085306740/posts/default/4523591512375983623'/><link rel='alternate' type='text/html' href='http://techtechila.blogspot.com/2011/01/ddr-port-pin.html' title='DDR, PORT, PIN'/><author><name>Ashish</name><uri>http://www.blogger.com/profile/11572695506758516927</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3037762074085306740.post-689716309635656612</id><published>2011-01-31T23:17:00.000+05:30</published><updated>2011-01-31T23:17:31.718+05:30</updated><title type='text'>Getting Used to AVR</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 16px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;Getting used to AVR&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;Datasheet. A datasheet is a document provided by the manufacturer of an IC that gives information about various Pins of those IC’s and their function.&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;To learn AVR Microcontrollers, it is necessary to have that particular Microcontroller’s Datasheet with you. The datasheets are available for free on the Internet.&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;Our programming platform shall be WinAVR, which is also a free software available on the internet.&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;The best way to learn using a microcontroller, for a newbie, is using a development board. You could either make one on your own or buy them online. It’s best to buy one, it reduces the errors that might arise out of incorrect hardware connections. So, if you are looking to buy a development board, you can buy them from robokits.co.in, thinklabs.in...there are many other websites too. There are different types of programmers available. Please make sure that you know which programmer is used to program your board. It may be different for different boards.&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;The 1st thing that you need to be familiar with is a microcontroller’s Inputs and Outputs.&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;We will be considering Atmega16 throughout the course of this series. The PIN DIAGRAM of Atmega16 and Atmega32 are identical.&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;photo photo_none&quot; style=&quot;clear: both; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;div class=&quot;photo_img&quot; style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;img class=&quot;img&quot; height=&quot;369&quot; src=&quot;http://a2.sphotos.ak.fbcdn.net/hphotos-ak-snc4/hs716.snc4/63647_185162351497433_122819407731728_695846_1347630_n.jpg&quot; style=&quot;border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; width: 393px;&quot; width=&quot;640&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;(click on the photo to enlarge it)&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;As can be seen the pins for both the IC’s are identical. The only major difference is that ATmega16 has 16K Bytes of In-System programmable flash memory while an ATmega32 has 32K Bytes of flash memory.&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;ATmega16 (and ATmega32) has a total of 40 pins, of which 32 can be used as Input or output. These pins are divided into 7 ports&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;PORTA- &amp;nbsp;8 pins ( PA0 to PA7)&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;PORTB- &amp;nbsp;8 pins ( PB0 to PB7)&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;PORTC- &amp;nbsp;8 pins ( PC0 to PC7)&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;PORTD- &amp;nbsp;8 pins ( PD0 to PD7)&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;Each of these ports is associated with 3 registers: DDRx, PORTx, PINx, where ‘x’ stands for the port name (A,B,C or D). e.g DDRA, PORTA, PINA etc.&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;NOTE: While programming, DDRx,PORTx,PINx are always written in capitals.&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;DDR stands for Data Direction Register. It decides whether a particular pin will act as input or output.&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;(please note that PIN refers to the register and pin refers to some pin of the microcontroller)&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;Since a Port has 8 pins, all the registers, DDR,PORT,PIN are 8 bit register. Each bit corresponds to a pin of that particular port. Consider the example of port A&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;photo photo_none&quot; style=&quot;clear: both; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;div class=&quot;photo_img&quot; style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;img class=&quot;img&quot; height=&quot;105&quot; src=&quot;http://sphotos.ak.fbcdn.net/hphotos-ak-snc4/hs1354.snc4/162630_185163691497299_122819407731728_695853_2434187_n.jpg&quot; style=&quot;border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; width: 393px;&quot; width=&quot;640&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;(click on the photo to enlarge it)&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;MSB stands for Most Significant Bit. LSB stands for Least Significant Bit.&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techtechila.blogspot.com/feeds/689716309635656612/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://techtechila.blogspot.com/2011/01/getting-used-to-avr.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3037762074085306740/posts/default/689716309635656612'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3037762074085306740/posts/default/689716309635656612'/><link rel='alternate' type='text/html' href='http://techtechila.blogspot.com/2011/01/getting-used-to-avr.html' title='Getting Used to AVR'/><author><name>Ashish</name><uri>http://www.blogger.com/profile/11572695506758516927</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3037762074085306740.post-1089112754006949794</id><published>2011-01-31T21:09:00.000+05:30</published><updated>2011-01-31T21:09:45.469+05:30</updated><title type='text'>Embedded Systems</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; line-height: 16px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 11px; line-height: 16px;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Embedded System. The term itself brings to mind some chip ‘embedded’ on a surface with complex wiring connections further connecting it to some even more complex ‘embedded’ systems.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Well, they are actually a lot simpler.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;In simple words and Embedded System is any electronic system that uses a ‘chip’.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Microcontrollers and Microprocessors are two of the most common and most used embedded systems.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;A microprocessor is a general purpose chip used in applications which require huge amount arithmetic, logical etc. operations. Our laptops use a microprocessor chip.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;A microcontroller on the other hand is designed for specific tasks. Unlike a microprocessor it cannot be designed for controlling several processes. A microcontroller is preferred in applications that do not require too many tasks to be performed. If you guys ever open up your washing machines, you might find a microcontroller chip inside it. All those functions that a washing machine performs, toggle, spin, dry.. are controlled by a microcontroller.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;A microcontroller is much cheaper than a microprocessor. It requires much less power. For this reason, they are the favoured option for most robotic applications.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Microcontrollers are, for us robo-tists, a godsend. They showed us how we can make interesting projects in the seemingly dull course structure. They give us the first glimpse of what it is like to be an engineer.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Microcontrollers are easily available in the market. They belong to different families aka companies.&lt;/span&gt;&lt;/div&gt;&lt;ol style=&quot;padding-bottom: 0px; padding-left: 25px; padding-right: 10px; padding-top: 0px;&quot;&gt;&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;8051:&amp;nbsp; the ‘8051 core’ was the de-facto standard in 8-bit (and 4-bit) microcontrollers. Developed by Intel in the 1980’s, it still seems to be the instruction set they love to teach you in college. They are based on VERY OLD, but field proven instruction set. Very old techs, in my humble opinion, but these IC’s have been significantly improved.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;PIC: This is the classic microcontroller from Microchip. Very simple, very proven, but it lacks some features that other manufacturer’s are building into their chips.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;AVR:&amp;nbsp; This is a direct competitor of PIC. Designed and named AVR for god knows what reason by Atmel, it is a direct competitor of PIC. It does everything a PIC does, only faster and cheaper. The AVR series of Microcontrollers are readily available in the market. Also, their platform for programming is not licensed, but freely available on the web.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;MSP: These microcontrollers by Texas Instruments are pretty good, but, they truly excel at low power applications. Imagine running a complete system on one AA battery for 5 years. This is the realm of nano-amp&amp;nbsp; current consumption.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;ARM: Dunno what ‘ARM’ stands for. But, these are VERY powerful, extremely low power consumption and very low cost. But, for a beginner they can get really intimidating if you haven’t played around with a Microcontroller before.&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The most popular microcontroller among robot-enthusiasts, for now, is Atmel’s AVR. In the coming weeks we shall be covering various topics on ‘How to Program a Microcontroller’.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;If you are interested in learning how to program and use a microcontroller, it’s best to buy a development board. Because, you see, it reduces the number of errors possible in the system. If you are using a development board, the only errors that will be present will be the ones you make in programming, which can be easily rectified. But, once you have mastered the skill of programming a microcontroller, go for designing the hardware of your Microcontroller system ( not the microcontroller, you can use the chip in your system :P ) on your own.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techtechila.blogspot.com/feeds/1089112754006949794/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://techtechila.blogspot.com/2011/01/embedded-systems.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3037762074085306740/posts/default/1089112754006949794'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3037762074085306740/posts/default/1089112754006949794'/><link rel='alternate' type='text/html' href='http://techtechila.blogspot.com/2011/01/embedded-systems.html' title='Embedded Systems'/><author><name>Ashish</name><uri>http://www.blogger.com/profile/11572695506758516927</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3037762074085306740.post-7490373262527715809</id><published>2011-01-31T20:03:00.001+05:30</published><updated>2011-06-03T21:10:42.842+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="7805"/><category scheme="http://www.blogger.com/atom/ns#" term="Voltage Regulator"/><title type='text'>Voltage Regulator IC 7805</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 11px; line-height: 16px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 11px; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;strong&gt;Voltage Regulator IC 7805&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;&lt;br /&gt;
&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;&lt;br /&gt;
&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;Let&#39;s say you want to play with your Microcontroller today.&amp;nbsp;&lt;/strong&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 11px; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 11px; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;With any IC, you need to power the thing.&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 11px; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;There are two power connections on basic micros : VCC and GND. What the heck is VCC? This is the label for the positive voltage. Don&#39;t worry, after a few days of this, seeing &#39;VCC&#39; will become very normal. GND is short for ground. All electrical current needs a way to flow back to ground. This can be called &#39;common&#39; but is often just labeled GND.&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 11px; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;There are thousands of different micros out there, but 5V (five volts) is the typical VCC. 3.3V is also typical but you&#39;ll also see 2.8V and 1.8V VCCs on more exotic micros. For now, just worry about 5V and GND.&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 11px; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 11px; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;strong&gt;Where do I find this 5V?&lt;/strong&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 11px; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 11px; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;You need to hook up 5V and GND to your micro.&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 11px; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 11px; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;strong&gt;Quick note:&lt;/strong&gt;&amp;nbsp;If you reverse the connection on your micro - bad things happen. Always make sure your 5V power supply is connected to the VCC pins and GND to GND. If you reverse this and connect 5V to GND on the micro and GND to VCC on the micro, things won&#39;t explode, probably no smoke, but things will probably heat up like crazy, and you&#39;ll probably damage your 250 bucks micro. You probably will. I did. Many times. Try not to do it.&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 11px; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;Ok! You need 5V. Time to build a simple voltage regulator circuit!&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 11px; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 11px; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;The most common regulator is called the LM7805. Why? I dunno. I&#39;ve never actually touched a component with LM7805 stamped on the outside. There&#39;s always other letters stamped on the outside like &#39;LM78X05&#39; or &#39;LV78X05&#39; or some such crazyiness. Just know that there are many many manufacturers out there and they are all producing the same basic part, with small tweaks to each one. What you need is one of these generic parts that is designated as a &#39;5V linear regulator&#39;.&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 11px; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 11px; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;photo photo_none&quot; style=&quot;clear: both; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;div class=&quot;photo_img&quot; style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;img class=&quot;img&quot; src=&quot;http://a3.sphotos.ak.fbcdn.net/hphotos-ak-ash2/hs002.ash2/33483_171977999482535_122819407731728_605299_7157544_n.jpg&quot; style=&quot;border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot; /&gt;&lt;/div&gt;&lt;div class=&quot;caption&quot; style=&quot;border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #666666; font-size: 11px; line-height: 12px; padding-bottom: 10px; padding-left: 0px; padding-right: 0px; padding-top: 2px; text-align: left;&quot;&gt;LM7805&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 11px; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 11px; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 11px; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;Here you can see the &#39;pin-out&#39; of the LM7805. Say &#39;IGO&#39; in your head and commit this to memory (input, ground, output). You&#39;ll probably hook up a lot of these. When in doubt, always check the datasheet before hooking up a new part - or else be close to the on/off switch! Input is the input voltage of anything greater than about 7V. GND is ground. Output is the 5V output pin.&amp;nbsp;All grounds need to be connected together for current to flow across the system. One more time - connect all grounds. This is the main reason why a novii can&#39;t get a system to work.&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 11px; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 11px; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;photo photo_none&quot; style=&quot;clear: both; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;div class=&quot;photo_img&quot; style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;img class=&quot;img&quot; src=&quot;http://sphotos.ak.fbcdn.net/hphotos-ak-ash2/hs473.ash2/74596_171978202815848_122819407731728_605300_5514678_n.jpg&quot; style=&quot;border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot; /&gt;&lt;/div&gt;&lt;div class=&quot;caption&quot; style=&quot;border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #666666; font-size: 11px; line-height: 12px; padding-bottom: 10px; padding-left: 0px; padding-right: 0px; padding-top: 2px; text-align: left;&quot;&gt;Schematic&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 11px; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 11px; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 11px; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;strong&gt;Schematic note:&lt;/strong&gt;&amp;nbsp;The two ground pins are not shown connected. We assume that nets (the green wires) of the same name are connected together. Schematics can get big and complex, so you won&#39;t see all the wires together, but in your breadboard you need to connect all the GND pins together. In this case it&#39;s the GND wire from your 9V battery (power source) connected to the GND pin on the regulator.&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 11px; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 11px; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;Now, just wire it all up on a breadboard.&lt;/div&gt;&lt;div style=&quot;font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 11px; line-height: 1.5em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;Congratulations! You&#39;ve built up your very first voltage regulator! Now leave this 5V power supply wired in your breadboard! You are going to use it many times...&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techtechila.blogspot.com/feeds/7490373262527715809/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://techtechila.blogspot.com/2011/01/lets-say-you-want-to-play-with-your.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3037762074085306740/posts/default/7490373262527715809'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3037762074085306740/posts/default/7490373262527715809'/><link rel='alternate' type='text/html' href='http://techtechila.blogspot.com/2011/01/lets-say-you-want-to-play-with-your.html' title='Voltage Regulator IC 7805'/><author><name>Ashish</name><uri>http://www.blogger.com/profile/11572695506758516927</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>