Commit 7eeb4a13 authored by Ismael Larrea Bravo's avatar Ismael Larrea Bravo
Browse files

Adding how to prgram the attiny45

parent 294007d6
Pipeline #221210 passed with stage
in 10 seconds
......@@ -241,7 +241,7 @@
<p>Also add:<br>
<li>4.7Ω resistance</li>
......@@ -411,10 +411,44 @@ digitalWrite(ledPin5, LOW);
<a href="Original Files/BlinkWithoutDelay_Serial.ino"> <li>Arduino - Blink without delay serial - Code</li> </a>
<h4>Using the Arduino IDE</h4>
<p>To program the ATtiny45 chip with the Arduino IDE is important to install the ATtinyCORE, you can follow <a href="" target="_blank" rel="noopener noreferrer">this tutorial page</a> to install it. After that you should set the settings as shown on the next image.</p>
<img src="./img/w8/ss-arduino-tools-att45.png" alt="Setting use on the arduino IDE to program the ATtiny45" />
<p>Using this environment to develop is pretty straight forward. The main things are to set the appropriate board and clock settings from the <samp>tools>board</samp> menu, and then <samp>tools>chip</samp>, is also important to enable the LTO that makes the complied program smaller <samp>tools>LTO>enable</samp></p>
<p>Then you write your program as any other Arduino program, be aware that some functions will not work and also you have less flash and RAM memory to work with.</p>
<p>Compile your program and set your programmer inside the <samp>tools>programmer>USBtinyISP</samp> menu, make sure your programmer and board are connected, and finally upload your sketch to your microcontroller.</p>
<h4>Programming with PlatformIO</h4>
<img src="./img/w8/ss-plataformio-home.jpg" alt="Screenshot of the PlatformIO extension for VS code" />
<p><a href="" target="_blank" rel="noopener noreferrer">PlatformIO</a> can be installed via a VS code extension, then you can enjoy the benefits of using PlatformIO while having the power of VS code</p>
<p>Also, as VS code is more powerful you will get intellisense and code auto completion. Which is always nice and handy, to install it you must go to the extension tab and search for PlatformIO click on install.</p>
<p>You will have now an icon for the PlatformIO home, where you can create new project or import form the Arduino IDE. When creating the project you should select which chip you will be targeting and a root folder. In this case the ATtiny45.</p>
<p>On the project a file named main.cpp will be created, there you should put your code. You can write normal Arduino Code and C code. To compile and upload you can use the buttons that will be added to the bottom bar or the following commands:</p>
<li><kbd>ctrl+alt+b</kbd> / <kbd>cmd-shift-b</kbd> Build Project</li>
<li><kbd>ctrl+alt+u</kbd> Upload Firmware</li>
<li><kbd>ctrl+alt+s</kbd> Open Serial Port Monitor</li>
<p>Make sure your programmer is connected to the computer and the board</p>
<h4>Using C files</h4>
<p>You can use plain C to program you AVR chip, then use the <a href="" target="_blank" rel="noopener noreferrer">AVR Toolchain</a> to compile it and generate a .hex file. That you finally upload using <a href="" target="_blank" rel="noopener noreferrer">avrdude</a>. To edit the code I use VS code, but you can use any editor.</p>
<h4>Using Makefiles!</h4>
<p>With this type of files used with the <a href="" target="_blank" rel="noopener noreferrer">GNU make</a> program you can automate a lot of the compile and uploading tasks of your project. I found this <a href="" target="_blank" rel="noopener noreferrer">great tutorial</a> that makes a step by step breakdown of the Makefile and how it works.</p>
<pre><code>target: prerequisites
<p>The example above is a basic format for a make rule, you can chain this based on how to make the prerequisites.</p>
>PROJECT=main.lightsensor <br />
<p>You can also declare variables, on the previous example the project variable is used to name a file .hex with the variable value.</p>
<p>Is also a good practice to make a <samp>clean:</samp> recipe that will delete all the generated files and leave the directory clean</p>
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