assignment 13
add an output device to a microcontroller board you've designed and program it to do something
For this assignment I design, print and program a board where you push a button once and one motor turns on and if you push the button twice then the second button turns on.
Step 1: The first thing I did was to design my circuit with a protoboard and the arduino.
1. Input --> Button.
Here I need a resistor of 220 ohms that will be connected to the button, in this same line/trace it will be connected to my attiny84/arduino. Since the system will go from not having energy to having energy we need to connect the attiny 84 in this position. The other side of the resistor will go connected to the ground, and the other leg of the button will go connected to the vcc in order to close the circuit.
2. Output --> DC Motor (first dc motor)
For this circuit I need to use a transistor that will allow to close the circuit whenever the arduino gives the signal. We need a resistor as well that will be the connection between the transistor and the arduino/Attiny84. As you can see in the picture below, in the diagram of the transistor in the right, this component has three legs. The leg on the left will be connected to the motor and will go in the same line as the VCC. The leg on the middle will be connected to the resistor and this resistor will be connected to the Arduino/Attiny84. The third leg of the resistor will be connected t the ground. The second motor will be connected in the same way as the first motor.
Step 2: Program
a. I created a variable that will take three values: 0, 1, 2, depending on the times the button has been clicked.
b. I created two conditions one two set the value of the variable depending on the number of clicks of the button and the second one to turn on the motor 1 or motor 2 depending on the value of the variable. Files at the end. Something important to take into account in my program is to define which ports I was going to be using.
Step 3: Define the final components that I will be using for the circuit and start the design in Eagle. I designed the traces directly from the board
1. VCC (entrance)
2. Resistors of 220 OHMs(3)
3. Button
4. Transistor (2)
5. DC Motors (2)
Step 4: Print the circuit in the Modela and solder the components
Step 5: Program the Attiny85 using my previous board and the Arduino.
As specified in a previous assignment, the arduino can become the programmer of an Attiny. We need to use the Example of Programmer then, upload the program in my Attiny85 using the previous board which has the ISP.
The traces will be connected as I defined in Step 1. However I need to connect the Attiny85 VCC with the trace of VCC and the Attiny85 Gnd with the trace of the circuit that holds the Gnd. Indeed I forgot this to add in my circuit and I had to make an external connection at the end.
It is important to make a mirror of the sketch of the board if you have superficial components.
Identifying which pinnes were connected to the button and the two motors.
I decided to connect my button to the 8th pin of the Attiny85 which corresponds to the 5th port.
I decided to connect my First Motor to the 6th pin of the Attiny85 which corresponds to the 7th port.
I decided to connect my Second Motor to the 7thn pin of the Attiny which corresponds to the 6th port.
There were some issues with one of the transistors and using the same line of connection between motor1 and motor2 is making motor1 always turning on every click., so I would need to make another board.
Files find at: https://www.dropbox.com/sh/cbef16t0ylm9nva/AAA4Da4xrqNG8ZKOnLbIaqyra?dl=0
Step 7: See if the board works. (Video below)