tag:blogger.com,1999:blog-31268311199271865122024-03-13T08:23:11.357+05:30Arduino AddictionDigital InfoTechhttp://www.blogger.com/profile/02320814587435318604noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-3126831119927186512.post-34415049864305819122016-04-08T02:01:00.001+05:302016-10-12T14:06:19.186+05:30Charge your cell phone with 9v Battery<div dir="ltr" style="text-align: left;" trbidi="on">
Hello friends,<br />
<br />
<div style="text-align: justify;">
In this post, I will show you how to charge your cell phone with 9v battery. This is very useful when you are in emergency-like situation. It is small & handy, you can even carry it in your pocket.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
So, let's build it.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Things you will need :</div>
<div style="text-align: justify;">
( Click on it to buy from <a href="https://www.amazon.in//ref=as_li_ss_tl?ie=UTF8&linkCode=ll2&tag=7847-21&linkId=40663bdebc8b00e6514424bb479bc23a" target="_blank">Amazon</a> )</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
</div>
<ol>
<li>A 9v battery</li>
<li>A 9v battery cap</li>
<li>AMS1117 IC</li>
<li>Soldering Iron</li>
<li>Solder Wire</li>
</ol>
<div>
<br /></div>
</div>
Digital InfoTechhttp://www.blogger.com/profile/02320814587435318604noreply@blogger.com2tag:blogger.com,1999:blog-3126831119927186512.post-39640528262565749012016-03-27T13:00:00.001+05:302016-03-27T13:00:38.068+05:30Generating power from HDD stepper motor.<iframe allowfullscreen="" frameborder="0" height="270" src="https://www.youtube.com/embed/z-YL2e5udNY" width="480"></iframe>Digital InfoTechhttp://www.blogger.com/profile/02320814587435318604noreply@blogger.com0tag:blogger.com,1999:blog-3126831119927186512.post-58382890091246392952016-02-29T02:39:00.002+05:302016-03-01T00:07:21.607+05:30Controlling blinking speed of an LED with Arduino & potentiometer<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
</div>
<div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Hello friends,</div>
<div style="text-align: justify;">
In this tutorial, I will show you how to control blinking speed of an LED using Arduino Nano & a variable resistor or a potentiometer aka the pot (short form of potentiometer).</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
This tutorial is similar to an LED blink code but, we added a pot to it, you may think that what is pot, basically pot is a type of resistor which value can be changed. It has three legs, 1 leg on each side which are rigid and are connected to each other with the small layer of conductor & 1 is in center which is movable means we can rotate it & it has a small pin which floats on this thin layer. For example, we connect GND to one leg & 5V to another leg, Now when we rotate the center pin to GND leg, the voltage passing through center will decrease & when we rotate it to 5V, the voltage passing through center pin will increase & if we rotate it to center the voltage will be half of the 5V, means 2.5V. understand !!</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Now get back to our tutorial,</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Things we will need :</div>
<ol style="text-align: left;">
<li>A Arduino board ( I took Nano).</li>
<li>A LED</li>
<li>A resister ( 150 ohm )</li>
<li>A potentiometer ( yes, pot )</li>
</ol>
</div>
<h3 style="text-align: left;">
<span style="font-weight: normal;">Step 1 : Wiring</span></h3>
<h3 style="text-align: left;">
<span style="font-weight: normal;"> </span></h3>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMjlrIHrdwEg53WRIQRXjGmrymf1z8iRo9aDU8Um6Mhisf4YjuNaLEPSoo5einERVLrQZmaTaOMj0EeV_HvBcbGYlTMJ6KAIUnwwMQE9t6VVZFMsAaPKf48yXg5GSa0nUsA9eLW0_0VY7N/s1600/Screenshot_48.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="272" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMjlrIHrdwEg53WRIQRXjGmrymf1z8iRo9aDU8Um6Mhisf4YjuNaLEPSoo5einERVLrQZmaTaOMj0EeV_HvBcbGYlTMJ6KAIUnwwMQE9t6VVZFMsAaPKf48yXg5GSa0nUsA9eLW0_0VY7N/s320/Screenshot_48.png" width="320" /></a></div>
<br />
Firstly, place the Nano, an LED & resistor on the bread board.<br />
<ol style="text-align: left;">
<li>Now, connect the Nano's 5V & GND to breadboard's power lines. </li>
<li>Connect one end of resistor to Nano's D13 pin & other end to an LED's anode pin or say long leg.</li>
<li>connect cathode or short leg to the GND.</li>
</ol>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhc69Qz_bWPYxlumadkauDo6DcWZ3Vdhc_4mJUdhqT2PuP4VOcnMCYYQTI4nIl2otf2ZXRIIPYPiPYlu-qsFQMV65LKiBTr-xb0lgWKIqMk90JZ0WboG8ODXr3sSAI7vVhq2dboY7hLNoZm/s1600/Screenshot_49.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="276" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhc69Qz_bWPYxlumadkauDo6DcWZ3Vdhc_4mJUdhqT2PuP4VOcnMCYYQTI4nIl2otf2ZXRIIPYPiPYlu-qsFQMV65LKiBTr-xb0lgWKIqMk90JZ0WboG8ODXr3sSAI7vVhq2dboY7hLNoZm/s400/Screenshot_49.png" width="400" /></a></div>
</div>
<br />
<div>
<div style="text-align: left;">
<span style="font-weight: normal;"></span><span style="font-weight: normal;"></span>Now place the pot on breadboard.</div>
<ol style="text-align: left;">
<li>First leg of pot to GND.</li>
<li>second to Nano's analog pin A0 &</li>
<li>third to 5V.</li>
</ol>
</div>
<div style="text-align: left;">
Our wiring is now let's move to coding part.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<h3 style="text-align: left;">
<span style="font-weight: normal;">Step 2 : Coding</span></h3>
<h3 style="text-align: left;">
<span style="font-weight: normal;"> </span></h3>
<div style="text-align: left;">
<span style="font-weight: normal;">Connect Nona to PC through the USB cable & open Arduino IDE.</span></div>
<div style="text-align: left;">
<span style="font-weight: normal;">Now go to <b>File</b> > <b>Examples</b> > <b>Analog</b> > <b>AnalogInput</b>. A sketch will open, upload it to the Nano.</span></div>
<h4 style="text-align: left;">
<span style="font-weight: normal;">when uploading is done, you can change the blinking speed of an LED with the pot.</span></h4>
<h4 style="text-align: left;">
<span style="font-weight: normal;"> </span></h4>
<h3 style="text-align: left;">
<span style="font-weight: normal;">Video tutorial : </span></h3>
<h3 style="text-align: left;">
<span style="font-weight: normal;"> </span></h3>
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen="" class="YOUTUBE-iframe-video" data-thumbnail-src="https://i.ytimg.com/vi/97P5_RYJkNs/0.jpg" frameborder="0" height="266" src="https://www.youtube.com/embed/97P5_RYJkNs?feature=player_embedded" width="320"></iframe></div>
<h3 style="text-align: left;">
<span style="font-weight: normal;"><br /></span></h3>
<h4 style="text-align: left;">
<span style="font-weight: normal;"> </span></h4>
<h3 style="text-align: left;">
<span style="font-weight: normal;">How the code works.</span></h3>
<h3 style="text-align: left;">
<span style="font-weight: normal;"> </span></h3>
<div style="text-align: justify;">
<span style="font-weight: normal;">You may remember, in an LED code, we took 1000 ms as delay between HIGH & LOW, means an LED remains 1 second HIGH & 1 second LOW. In this example, Arduino takes the voltage form the center leg of pot & converts it to digital form (0 - 5 to 0 - 1023). So, when we rotate the nob of the pot to 0V, we are actually decrease the time between HIGH & LOW & </span><span style="font-weight: normal;">when we rotate the nob of the pot to 5V, we are actually increase the time between HIGH & LOW. Simple but effective way to control blinking speed of an LED.</span></div>
<h4 style="text-align: left;">
<span style="font-weight: normal;"><br /></span></h4>
<h3 style="text-align: left;">
</h3>
</div>
</div>
Digital InfoTechhttp://www.blogger.com/profile/02320814587435318604noreply@blogger.com1tag:blogger.com,1999:blog-3126831119927186512.post-91810373654807711622016-02-28T22:39:00.004+05:302021-12-09T12:16:58.991+05:30Blinking LED with Arduino Nano<div class="step-body" itemprop="articleBody"><div style="text-align: justify;">Hello friends,</div><div style="text-align: justify;">Seeing a blinking LED is so much fun, but when you make one like that by yourself then the fun is even more. ^_^</div><div style="text-align: justify;"><br />So, let the fun begin,</div><div style="text-align: justify;"><br />In this tutorial, I have shown below how to blink an LED with Arduino Nano.</div><div style="text-align: justify;"><br />Note: <b>Using an LED without a resistor will blow led</b>.</div><div style="text-align: justify;"><b>Things you will need.</b></div><ol style="text-align: justify;"><li>Arduino Nano</li><li>A breadboard</li><li>A LED ( I used 3V at 20mA led)</li><li>A resistor 100 ohm</li></ol><h2 class="step-title" id="step1"><span style="font-weight: normal;">Step 1: Wiring.</span></h2><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgdqbOFpBFuuN9TNly-nI6rRCdasEMyn6W7E4k5HwzZsZJqfqJMPDhyphenhyphenPzCeXJs2j0XwrGTAyxskUDX7yjr68GJ02nnibF_XgJdT0jKfcUC3VqPSsnjwGKB4d89c3Y09mRii_RzL3jHwKhb/s1600/Screenshot_22.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="271" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgdqbOFpBFuuN9TNly-nI6rRCdasEMyn6W7E4k5HwzZsZJqfqJMPDhyphenhyphenPzCeXJs2j0XwrGTAyxskUDX7yjr68GJ02nnibF_XgJdT0jKfcUC3VqPSsnjwGKB4d89c3Y09mRii_RzL3jHwKhb/s400/Screenshot_22.png" width="400" /></a></div><h2 class="step-title" id="step1"> </h2><div style="text-align: justify;">You have to attach the LED to the Nano just done in the above image.</div><div style="text-align: justify;"><br /></div><div style="text-align: justify;"><ul><li>Connect LED's positive end to the one end of the resistor</li><li>Another end to Nano's digital pin 13</li><li>Negative end to Nano's ground.</li></ul></div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">To power the Nano board, you can use a USB cable or you can also connect an external power supply by connecting the positive pin to VIN and negative to the ground.</div></div><div class="gpt-ad" id="gpt-ad-native-middle" style="text-align: justify;"></div><h2 class="step-title" id="step1" style="text-align: center;"><br /></h2><h2 class="step-title" id="step1" style="text-align: center;">Step 2 : Coding</h2><div><br /></div><h2 class="step-title" id="step1" style="text-align: justify;"></h2><div class="photoset" data-item-id="S7YZXJRIKPSAALB" data-item-url="http://www.instructables.com/id/Blinking-LED-With-Arduino-Nano/step1/The-coding-part/" id="photoset-S7YZXJRIKPSAALB" style="text-align: justify;"><div class="photoset-row cols-1" style="margin-bottom: 5px;"><div class="photoset-cell image-cell"><div class="photoset-item photoset-image"><pre><div style="text-align: center;"><span style="color: #434f54;">// the setup function runs once when you press reset or power the board</span></div><span style="color: #00979c;">void</span> <span style="color: #5e6d03;">setup</span><span style="color: black;">(</span><span style="color: black;">)</span> <span style="color: black;">{</span>
<span style="color: #434f54;">// initialize digital pin 13 as an output.</span>
<span style="color: #d35400;">pinMode</span><span style="color: black;">(</span><span style="color: black;">13</span><span style="color: #434f54;">,</span> <span style="color: #00979c;">OUTPUT</span><span style="color: black;">)</span><span style="color: black;">;</span>
<span style="color: black;">}</span>
<span style="color: #434f54;">// the loop function runs over and over again forever</span>
<span style="color: #00979c;">void</span> <span style="color: #5e6d03;">loop</span><span style="color: black;">(</span><span style="color: black;">)</span> <span style="color: black;">{</span>
<span style="color: #d35400;">digitalWrite</span><span style="color: black;">(</span><span style="color: black;">13</span><span style="color: #434f54;">,</span> <span style="color: #00979c;">HIGH</span><span style="color: black;">)</span><span style="color: black;">;</span> <span style="color: #434f54;">// turn the LED on (HIGH is the voltage level)</span>
<span style="color: #d35400;">delay</span><span style="color: black;">(</span><span style="color: black;">1000</span><span style="color: black;">)</span><span style="color: black;">;</span> <span style="color: #434f54;">// wait for a second</span>
<span style="color: #d35400;">digitalWrite</span><span style="color: black;">(</span><span style="color: black;">13</span><span style="color: #434f54;">,</span> <span style="color: #00979c;">LOW</span><span style="color: black;">)</span><span style="color: black;">;</span> <span style="color: #434f54;">// turn the LED off by making the voltage LOW</span>
<span style="color: #d35400;">delay</span><span style="color: black;">(</span><span style="color: black;">1000</span><span style="color: black;">)</span><span style="color: black;">;</span> <span style="color: #434f54;">// wait for a second</span>
<span style="color: black;">}</span> </pre><pre> </pre><pre> Coding for blinking LED is so simple.</pre><div class="step-body"><ul><li>Just connect Nano to PC.</li></ul><ul><li>Open Arduino IDE software.</li></ul><ul><li>Go to <b>File</b> > <b>Examples</b> > <b>Basics</b> > <b>Blink</b>.</li></ul><ul><li>And upload it to the Nano board.</li></ul><ul><li>In no time, the LED should be Blink. </li></ul><ul><li><b>1 second On, 1 second OFF</b>.</li></ul></div></div></div></div></div><p><span style="text-align: justify;">If you have any questions you can ask me in the comment section below. ^_^</span> </p>Digital InfoTechhttp://www.blogger.com/profile/02320814587435318604noreply@blogger.com1tag:blogger.com,1999:blog-3126831119927186512.post-64332536492371093082016-02-28T17:05:00.010+05:302021-12-09T11:29:49.284+05:30Program Arduino Nano via Uno with ICSP<p><br /></p><div dir="ltr" trbidi="on"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtCI13thIFHrQ2JweCyKDcNOU3h18b4imsgFof7_mNho24vR1O2x3UZ-SSXX8ReZ8nFghVexVdhRG8gAWyTFRza9owb83PsFpipkWlHP_kp2ZBsZnPk20Hggfy0vyvVe7rl-oi6_Vcre_B/s1600/WP_20160224_23_54_33_Pro%25281%2529.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="266" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtCI13thIFHrQ2JweCyKDcNOU3h18b4imsgFof7_mNho24vR1O2x3UZ-SSXX8ReZ8nFghVexVdhRG8gAWyTFRza9owb83PsFpipkWlHP_kp2ZBsZnPk20Hggfy0vyvVe7rl-oi6_Vcre_B/s400/WP_20160224_23_54_33_Pro%25281%2529.jpg" width="400" /></a></div><br /><div class="separator" style="clear: both; text-align: center;"></div><div style="text-align: justify;"><br /></div><div class="step-body" itemprop="articleBody"><div style="text-align: justify;">Hello Friends,</div><p style="text-align: justify;"><span> </span><span> </span><span> </span>In this tutorial, I have shown that how can you program Nano via Uno. As you can see in the above image, my Arduino Nano's USB female pin is broken. So I have to find a way to upload the sketch to it some way. One day I was Google-ing, I have read somewhere that an Arduino board can also be programmed via another Arduino board. </p><div style="text-align: justify;"><br /></div><h2 style="text-align: justify;"><span style="font-family: inherit;"><b>Tools you will Need</b> :</span></h2><ol><li>Arduino Uno ( which will act as a programmer ).</li><li>Arduino Nano ( to be programmed ).</li><li>Jumper Cables ( Some male-male, male to female )</li><li>Breadboard</li></ol><div><br /></div><div class="separator" style="clear: both; text-align: center;"><span style="text-align: left;"><br /></span></div><h1 style="clear: both; text-align: center;"><span style="text-align: left;">Step 1: Preparing programmer</span></h1></div><script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><script>
(adsbygoogle = window.adsbygoogle || []).push({
google_ad_client: "ca-pub-1645648533608760",
enable_page_level_ads: true
});
</script><div class="step-body" itemprop="articleBody"><p style="text-align: left;"><span style="font-weight: normal;"> <span> </span><span> </span><span> </span></span>Attach your Arduino Uno to PC. & go to<b style="text-align: justify;"> </b><b style="text-align: justify;">File > Examples > ArduinoISP</b><span style="text-align: justify;"> </span><span style="text-align: justify;">></span><span style="text-align: justify;"> </span><b style="text-align: justify;">ArduinoISP</b><span style="text-align: justify;">. </span></p><div style="text-align: justify;">A sketch will open, upload it on Uno. When uploading is done. unplug it from the PC. Now, Attach Uno & the board you want to program with jumper cables just like the image below.</div><div class="step-body"><div style="text-align: justify;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjI7aG1dEuT749ztV0ZcUHDkox7z_eMywlMPK-TI8De17L_QlLNwTXGuiv2-3mu3XlmYGrzHwiBO7vbHhg1I7zzhhKBF2PVIV0gwLvuymThCGkea9hG_5MbO94ZyMwwoKH4mPuGFDZEbCYT/s1600/Screenshot_38.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="290" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjI7aG1dEuT749ztV0ZcUHDkox7z_eMywlMPK-TI8De17L_QlLNwTXGuiv2-3mu3XlmYGrzHwiBO7vbHhg1I7zzhhKBF2PVIV0gwLvuymThCGkea9hG_5MbO94ZyMwwoKH4mPuGFDZEbCYT/s400/Screenshot_38.png" width="400" /></a></div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">In the above image, you can see a small (1) or (*) or (.) is marked near the ICSP headers, that is the 1st pin of ICSP headers.</div><div style="text-align: justify;"><br /></div><h4 class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtzCH0oh005b4ankIOs-ImCCt_3ycrcg8HqfKbv7K9NI-qhKPlEQWq1PQryxDrV7niimtaGDjlkrAlvkErOpTOLaOFS7SefzY9CDoUTtZam8-SfsTKh8mbtMDY39LX1dVh8kQN8I_1kU-s/s1600/Screenshot_39.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="80" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtzCH0oh005b4ankIOs-ImCCt_3ycrcg8HqfKbv7K9NI-qhKPlEQWq1PQryxDrV7niimtaGDjlkrAlvkErOpTOLaOFS7SefzY9CDoUTtZam8-SfsTKh8mbtMDY39LX1dVh8kQN8I_1kU-s/s400/Screenshot_39.png" width="400" /></a></h4><ul><li>D13 to SCK, </li><li>D12 to MISO, </li><li>D11 to MOSI, </li><li>D10 to RST, </li><li>5V to VIN</li><li>GND to GND<b><br /></b></li></ul><h4 style="margin-left: 20px; text-align: justify;">Note: If your board's operating voltage is 3.3V then use 3.3V instead of 5V.</h4><div><br /></div><h1 style="margin-left: 20px; text-align: center;"><span style="text-align: left;">Step 2: Preparing Arduino IDE</span></h1><div class="step-title" id="step2"></div><div class="step-body"><div style="text-align: justify;"><span> </span><span> </span><span> </span><span> </span></div><div style="text-align: justify;"><span> </span><span> </span><span> </span>All wiring is done. now we have to do some settings in IDE.</div><div style="text-align: justify;"><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYKvEM61iIb0sZVmVNM4XNImOz3W0z4nNjvTmq6c4ZVYJvKnwCONhIizAvD8YZJi7MmKZo8FH5trgEskJDszl7Lnn7L2m7RC_bcmnZKYVWGkjCoTs6gDCCbbETscM0TIS9Jr8D86pc1hqY/s1600/Screenshot_40.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="151" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYKvEM61iIb0sZVmVNM4XNImOz3W0z4nNjvTmq6c4ZVYJvKnwCONhIizAvD8YZJi7MmKZo8FH5trgEskJDszl7Lnn7L2m7RC_bcmnZKYVWGkjCoTs6gDCCbbETscM0TIS9Jr8D86pc1hqY/s400/Screenshot_40.png" width="400" /></a></div></div><ul style="text-align: justify;"><li>Go to <b>Tools</b> > <b>Board</b> & select <b>Arduino Nano</b>.</li></ul><ul style="text-align: justify;"><li>In <b>Processor, </b>select<b> ATmega328.</b></li></ul><ul style="text-align: justify;"><li>& In Programmer, select <b>Arduino as ISP</b>. ("Arduino as ISP" not "ArduinoISP")</li></ul><div style="text-align: justify;">The settings is done.</div><ul style="text-align: justify;"><li>Now, open up the sketch you want to upload on your Nano,</li><li>In <b>Menu</b>, go to <b>Sketch</b> & click on "<b>Upload using Programmer"</b></li></ul><div style="text-align: justify;">IDE will compile the sketch & upload it to your Nano. The RX TX LEDs will blink rapidly on both boards, & you will see <b>done uploading</b>.</div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">If not, then recheck all the wiring & settings.</div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">If you get any problems or you want to give me suggestions, you can write in the comment section below.</div><div style="text-align: justify;">Happy Programming ^_^<br /><br /><br />Thank You.</div><div><br /></div></div></div></div></div>Digital InfoTechhttp://www.blogger.com/profile/02320814587435318604noreply@blogger.com17tag:blogger.com,1999:blog-3126831119927186512.post-29034613769907213562016-02-25T17:47:00.000+05:302016-02-26T18:20:58.215+05:30Program Arduino Uno in C Language<div dir="ltr" style="text-align: left;" trbidi="on">
<h1 class="title" itemprop="name">
</h1>
<h1 class="title" itemprop="name">
<span style="font-size: x-large;"> </span></h1>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHb-yQs7Deyl7zxhXVbdjoH3JXJauKxTmkqURPuTDCW3-PkBfKX72OsPLqVQH4ZJGguaGtD4TOoWfWo33IfoYi6koTnpp7irEewUHLbsGGHWkvXUnMFyXLFZbHUlAyeftOkzlr_sbyEjOT/s1600/Screenshot_32.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="305" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHb-yQs7Deyl7zxhXVbdjoH3JXJauKxTmkqURPuTDCW3-PkBfKX72OsPLqVQH4ZJGguaGtD4TOoWfWo33IfoYi6koTnpp7irEewUHLbsGGHWkvXUnMFyXLFZbHUlAyeftOkzlr_sbyEjOT/s400/Screenshot_32.png" width="400" /></a></div>
<h1 class="title" itemprop="name">
<span style="font-size: x-large;"> </span></h1>
<div style="text-align: justify;">
Hello friends,</div>
<div style="text-align: justify;">
In this tutorial, i have shown how to program Arduino Uno in C language. Arduino uses its own language to program Arduino boards, because it is easy to code & understand. But Arduino boards can also be programmed in C language.<br />
This tutorial is for beginners who are just thinking to program Arduino Uno in C language. (I am a beginner too ;P )</div>
<br />
<b>So let's get started.</b><br />
<br />
<h2 class="step-title" id="step1">
Step 1: Setting up things..</h2>
<div style="text-align: justify;">
<br />
To write code in C, we need a software, you can use AVR studio & any other coding software. Here we will use <b>code blocks</b>.</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghCKVzxoIWlLFZeqmYEcNv_cEmmN_MECxKHNW9gyR6NYq-cgR3ce2c2AQ5fMygP6tlAvlvffqjfhu_XVr7pHd5N4ncN-pUuA-eDCyYcwGinS9sFWVk8RqRQ7NsgnV5kcv8j21SdXhDRzS7/s1600/Cb_splash.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="108" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghCKVzxoIWlLFZeqmYEcNv_cEmmN_MECxKHNW9gyR6NYq-cgR3ce2c2AQ5fMygP6tlAvlvffqjfhu_XVr7pHd5N4ncN-pUuA-eDCyYcwGinS9sFWVk8RqRQ7NsgnV5kcv8j21SdXhDRzS7/s320/Cb_splash.png" width="320" /></a></div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
<br />
It is light weight, easy to use & it has a built in software to <b>directly upload code to your Arduino</b>. you can download it <a href="http://filehippo.com/download_codeblocks_arduino_ide/download/28a547905c0b7bc4af466281efc71bf1/" target="_blank">here.</a> </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
When download is done, open it & select new project.</div>
<div style="text-align: justify;">
A dialogue box will open.</div>
<ul style="text-align: justify;">
<li>Select <b>AVR project</b>, (Yes, there is a Arduino project too, because code blocks also support Arduino programming language too. )</li>
<li>Click <b>Go</b>, </li>
<li>Click <b>Next</b></li>
<li>Give the name of the project, (you can also change the destination folder for saving this project.)</li>
<li>Click <b>Next</b>. </li>
<li>It will ask for the compiler, default compiler is already selected, </li>
<li>Click <b>Next</b></li>
<li>Here you have to select chip of your Arduino, ( i am using Uno, so i will select Atmega328p.)</li>
<li>Click <b>finish</b>.</li>
<li>A blank screen open. On the left side. There is <b>work space</b></li>
<li>Double click on <b>sources</b> & select <b>main.c</b>.</li>
</ul>
<br />
<div>
<ul style="text-align: justify;">
</ul>
<h2 class="step-title" id="step2">
Step 2: Writing code.</h2>
<br />
<div style="text-align: justify;">
<span style="font-size: large;"><span style="font-size: small;">Copy or type this code there. ( you should prefer type, so you can improve your typing and coding skills.</span> </span></div>
<br />
<pre><span style="color: #5e6d03;">#include</span> <span style="color: #434f54;"><</span><span style="color: black;">avr</span><span style="color: #434f54;">/</span><span style="color: black;">io</span><span style="color: #434f54;">.</span><span style="color: black;">h</span><span style="color: #434f54;">></span> <span style="color: #434f54;">// header file file for input output pins</span>
<span style="color: #5e6d03;">#include</span> <span style="color: #434f54;"><</span><span style="color: black;">util</span><span style="color: #434f54;">/</span><span style="color: #d35400;">delay</span><span style="color: #434f54;">.</span><span style="color: black;">h</span><span style="color: #434f54;">></span> <span style="color: #434f54;">// header file for delay.</span>
<span style="color: #00979c;">int</span> <span style="color: black;">main</span> <span style="color: black;">(</span><span style="color: #00979c;">void</span><span style="color: black;">)</span>
<span style="color: black;">{</span>
<span style="color: #95a5a6;">/* set pin 5 of PORTB for output*/</span>
<span style="color: black;">DDRB</span> <span style="color: #434f54;">|=</span> <span style="color: black;">_BV</span><span style="color: black;">(</span><span style="color: black;">DDB5</span><span style="color: black;">)</span><span style="color: black;">;</span>
<span style="color: #5e6d03;">while</span><span style="color: black;">(</span><span style="color: black;">1</span><span style="color: black;">)</span>
<span style="color: black;">{</span>
<span style="color: #95a5a6;">/* set pin 5 high to turn led on */</span>
<span style="color: black;">PORTB</span> <span style="color: #434f54;">|=</span> <span style="color: black;">_BV</span><span style="color: black;">(</span><span style="color: black;">PORTB5</span><span style="color: black;">)</span><span style="color: black;">;</span>
<span style="color: black;">_delay_ms</span><span style="color: black;">(</span><span style="color: black;">1000</span><span style="color: black;">)</span><span style="color: black;">;</span> <span style="color: #434f54;">//delay 1 second</span>
<span style="color: #95a5a6;">/* set pin 5 low to turn led off */</span>
<span style="color: black;">PORTB</span> <span style="color: #434f54;">&=</span> <span style="color: #434f54;">~</span><span style="color: black;">_BV</span><span style="color: black;">(</span><span style="color: black;">PORTB5</span><span style="color: black;">)</span><span style="color: black;">;</span>
<span style="color: black;">_delay_ms</span><span style="color: black;">(</span><span style="color: black;">1000</span><span style="color: black;">)</span><span style="color: black;">;</span> <span style="color: #434f54;">//delay 1 second.</span>
<span style="color: black;">}</span>
<span style="color: black;">}</span> </pre>
<pre> </pre>
<pre><span style="font-family: "arial" , "helvetica" , sans-serif;"><span style="font-size: large;">Understanding of some code.</span></span></pre>
<ul style="text-align: left;">
<li><b><avr/io.h> </b>: To tell the chip where all the ports & pins are located.</li>
<li><b><util/delay.h></b> : To use built in delay features. for accurate delay.</li>
<li><b>DDRB </b>: Data direction register for port B.</li>
<li><b>PORTB5</b> : In Uno, PORTB5 is connected to digital pin 13.</li>
<li><b>BV</b> : Bit value.</li>
</ul>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiw8r13R9ibewz63wm4Gmu7PyX7o8ockAotFFUJLaCsbG-S8hyFQHd8T5a7iUwANhYGOBirixtOJK57untOM7uoRrv4Q9NqKjGV1a3o4vjCT67T6s5GCY5gLsJFZMs75Nc8CoqdJgjiIsQX/s1600/Screenshot_42.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="63" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiw8r13R9ibewz63wm4Gmu7PyX7o8ockAotFFUJLaCsbG-S8hyFQHd8T5a7iUwANhYGOBirixtOJK57untOM7uoRrv4Q9NqKjGV1a3o4vjCT67T6s5GCY5gLsJFZMs75Nc8CoqdJgjiIsQX/s400/Screenshot_42.png" width="400" /></a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Now Click on the <b>Gear</b> like icon located below the menu bar. it will compile & build all the necessary files. Now go to <b>Tools</b> in menu bar & Click on <b>Arduino Builder</b>.</div>
<div style="text-align: justify;">
<br /></div>
<h2 class="step-title" id="step3">
Step 3: Uploading Code to Arduino</h2>
<h2 class="step-title" id="step3">
</h2>
<h2 class="step-title" id="step3">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGCm001l75d8pvwJ4kYbBb1Fq_3mhf4ro0qwBEoOVL6NGq2jeQ9AlDlf4c7i0PLvn9DlXx2QnuSbE9S5gf-yx3gx_xufNxudYhUQLshPuMutgggg9dQVRfATp4cCgwd1zGXAoLNXIVerrb/s1600/Screenshot_30.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="180" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGCm001l75d8pvwJ4kYbBb1Fq_3mhf4ro0qwBEoOVL6NGq2jeQ9AlDlf4c7i0PLvn9DlXx2QnuSbE9S5gf-yx3gx_xufNxudYhUQLshPuMutgggg9dQVRfATp4cCgwd1zGXAoLNXIVerrb/s400/Screenshot_30.png" width="400" /></a></h2>
<div style="text-align: justify;">
<br /></div>
<div class="step-body">
<span style="font-size: small;">A Arduino Builder program will open. Now attach the Uno to PC.</span><br />
<ul style="text-align: justify;">
<li><span style="font-size: small;">Click on <b>Load sketch / hex file</b> & browse the hex file from where you had stored it. ( default is in C drive/file_name/bin/debug/ )</span></li>
<li><span style="font-size: small;">Select board type as Arduino Uno </span></li>
<li><span style="font-size: small;">Dont change Clock.</span></li>
<li><span style="font-size: small;">Select the COM port of Uno. </span></li>
<li><span style="font-size: small;">As soon as you click on COM port, the Arduino Builder will start to program it.</span></li>
<li><span style="font-size: small;">When programming is done, L led on Uno should blink.</span></li>
<li><span style="font-size: small;">If not, then do the step 3 again.</span></li>
</ul>
<div style="text-align: justify;">
<span style="font-size: small;">Note : I
have used Uno in this tutorial, but you can use any arduino, you just
have to know which pin of IC is connected to which digital or analog pin
of Arduino. </span></div>
<div style="text-align: justify;">
<br />
<b><span style="font-size: small;">If you any suggestions or you get any error, you can write me in comment section below.<br />happy programming ^_^</span></b></div>
</div>
<div class="step-body">
</div>
<div class="step-body">
<br />
<span style="font-size: small;"> </span></div>
</div>
</div>
Digital InfoTechhttp://www.blogger.com/profile/02320814587435318604noreply@blogger.com0