week9

parent ae30d6b4
#include <avr/io.h>
#include <util/delay.h>
int main (void)
{
//Set the Led Pin.
DDRA = (1 << PA7);
//While(1) allows the program to loop
while (1)
{
//Set the Led as "ON"
PORTA = (1 << PA7);
//Wait for 1 second
_delay_ms(3000);
//Set the Led as "OFF"
PORTA = (0 << PA7);
//Wait for 1 second"
_delay_ms(2000);
}
return 1;//keep returning 1 so that the program will loop endlessly
}
......@@ -141,9 +141,92 @@ void loop() {
}
}</pre></code>
<h4>Configuration and Upload</h4>
Working.
In order to upload our first code, which will be the blink, we must configure the IDE tools with the following data:
<div class="table-wrapper">
<table class="alt">
<tbody>
<tr>
<td>Board</td>
<td>Attiny24/44/84</td>
</tr>
<tr>
<td>Processor</td>
<td>Attiny44</td>
</tr>
<tr>
<td>Clock</td>
<td>External 20 Mhz</td>
</tr>
<tr>
<td>Programmer</td>
<td>USBtinyISP</td>
</tr>
</tbody>
</table>
</div>
<a title="Configuration"><img class="image center" src="images/week9/config.jpg"></a>
Now we will need our ISP and an FTDI. The function of the ISP is to burn the bootloader, which prepares the microcontroller to receive the code, while the function of the FTDI is to send the code to the microcontroller with the data transmission pins: Tx and Rx.
Below is an picture of the necessary connection.
<a title="Conection"><img class="image center" src="images/week9/conection.jpg"></a>
Having the ISP, the FTDI and the connected HelloWorld proceed to carry out the programming following the following steps:
<div class="row">
<ol>
<li>Compile the program.</li>
<li>The bootloader is burned.</li>
<li>Upload the code.</li>
</ol>
</div>
Below is a video of the steps to follow.
<br><iframe width="560" height="315" src="https://www.youtube.com/embed/u2K_HD18W5M" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<br>This video is from button code
<br><iframe width="560" height="315" src="https://www.youtube.com/embed/pvFqlSebB20" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<br>And this one is the test button code
<br><iframe width="560" height="315" src="https://www.youtube.com/embed/2Wu3wTJPAh4" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<br><h2>Another programs and languages</h2>
<br><h3>C++</h3>
To program in C ++, I reviewed this<a href="(https://www.cprogramming.com/tutorial/c-tutorial.html"> tutorial to be able to understand the code used by a co-worker who made the Fabacademy last year,<a href="http://archive.fabacademy.org/2018/labs/fablabutec/students/carloseduardo-herbozovidal/index.html"> Carlos Herbozo.</a>
Using the<a href="http://archive.fabacademy.org/2018/labs/fablabutec/students/carloseduardo-herbozovidal/Week9.html"> code he has</a> I charge the code and check that if the code works.
<pre><code>#include <avr/io.h>
#include <util/delay.h>
int main (void)
{
//Set the Led Pin.
DDRA = (1 << PA7);
//While(1) allows the program to loop
while (1)
{
//Set the Led as "ON"
PORTA = (1 << PA7);
//Wait for 1 second
_delay_ms(3000);
//Set the Led as "OFF"
PORTA = (0 << PA7);
//Wait for 1 second"
_delay_ms(2000);
}
return 1;//keep returning 1 so that the program will loop endlessly
}</pre></code>
<a title="Blink test in C++"><img class="image center" src="images/week9/blinkc.jpg"></a>
<br><h3>Atom</h3>
Investigating about ways of programming, I have seen that if an Arduino board can be programmed by the Atom.
I found<a href="https://docs.platformio.org/en/latest/ide/atom.html#smart-code-linter-is-disabled-for-arduino-files"> this tutorial</a> that explains in detail how to prepare the atom for programming.
Below is an picture in which I have prepared the Atom for programming, as well as some codes already made.
<a title="Atom IDE"><img class="image center" src="images/week9/atomide.jpg"></a>
My first test was with an Arduino Uno, first I create a new project like the picture:
<a title="New project"><img class="image center" src="images/week9/newatom.jpg"></a>
Edit the main file from src folder with the same code:
<a title="Main"><img class="image center" src="images/week9/mainblink.jpg"></a>
Finally I upload the code in an Arduino board, but I can not do it with my ISP and my hello world board, I read all the tutorial but I can not do it.
I even modified the platformio.ini file with the communication protocol, but I did not have the expected results.
<a title="PlatformIO"><img class="image center" src="images/week9/platformio.jpg"></a>
</p>
<p>
<h2>Download files</h2>
You can donwload this files Here: <br>
......@@ -151,7 +234,9 @@ void loop() {
<a href="images/week9/blink.ino" download>Blink</a><br>
<a href="images/week9/button.ino" download>Button </a><br>
<a href="images/week9/testbutton.ino" download>Test Button</a><br>
C++<br>
<a href="images/week9/blinkC.ino" download>Blink C++</a><br>
</p>
<p><ul class="actions">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment