Assignment 8
read a microcontroller data sheet
program your board to do something, with as many different programming languages
and programming environments as possible
extra credit: experiment with other architectures
After building the circuit board, we need to program it. I used an ATTINY 84 as the microcontroller for the board. Before I program my board, I learned how to program the Arduino/Genuino UNO.
Step 1: Program an Arduino
Before programming an Arduino is necessary to construct in the protoboard the circuit you want to program.
For example, if we want to make a LED BLINK.
1. We need to build a circuit that starts in VCC and ends in GND (ground). So we start connecting our Arduino with the VCC entrace with the one in the protoboard and the same thing with ground.
2. Every LED needs a resistor of about 230 OHMs. The idea is that the energy will come from VCC and before going into the LED will pass through the resistor. Therefore, one end of the resistor will go to the VCC and the other one to the LED. Finally the other side of the LED will go to the GND.
3. If we only make the connections as specified in (2) then the LED will always be turned-on. Therefore we need to connect the Arduino. When the Arduino connects to the circuit is the one who provides power. So instead of connecting VCC to some side of the resistor we connect the port of the Arduino with the resistor.
4. We program the board:
a. First you need to specify which ports are inputs and which are outputs. For making a LED blink we only have an output which is the port in which the LED is connected. So let's assume that the LED was connected to port 8. Then you have to define in void setup() that port 8 is an OUTPUT using the instruction pinMode.
b. After setting up the INPUTs and OUTPUTS we program that the LED which is in port 8 will light-up using the number 1 or the word HIGH. Then it will wait for 1 second which is delay (1000) and then it will turn-off, and then it will wait two seconds. The program is written below.
void setup() {
// put your setup code here, to run once:
pinMode(8,OUTPUT);
}
void loop()
{
// put your main code here, to run repeatedly:
digitalWrite(8,1);
delay(1000);
digitalWrite(8,0);
delay(2000);
}
For example: Adding a button to the LED, so after you click it, the LED will light-up and with another click the LED will turn off.
In this example, there are two important things: (1) The button needs a resistor and (2) the circuit goes from LOW to HIGH therefore, we need to add the port of the Arduino in the same line where the resistor and the button are together.
Programming the Microcontroller
El arduino lo vuelvo programador, lo conecto al ATTINY vía ISP.
Using the Arduino as a programmer
Identify which port corresponds to the LED in your board (pinMAP if I already know to which port it corresponds.