9. Outputs¶
For this week’s assignments, I was required to connect and program an output device to a board which I designed and produced. In addition, the group assignment was to measure the power consumption of an output device. We did this by using a multimeter. The documentation for the group project can be found here.
Designing Board in KiCAD¶
I began by designing a board in KiCAD which would be space efficient and have a bunch of pinouts so as to fully utilize the capacity of the ATTiny412 and to ensure that I did not run out of pins in the middle of a project and have to create a whole new board. Additionally, the board has a button and indicator LED as well as a capacitor. The board has 5 GND female pins, 5 VCC female pins, 4 input/output female pins, and 1 UPDI female pin, all within 1.05”x1.4”.
Milling, Soldering, and Powering Board¶
I then milled the board:
Soldered it, and plugged it in to make sure the LED indicator turned on:
Hooking up Board to Motor and Programming¶
I connected the board to a servo motor (a small motor which only turns about half a rotation) through female headers for ground, VCC, and a pin respectively. Finally, I uploaded a simple code made by Richard Shan to the servo, changing the pin number in the code so that it looked like this:
#include <Servo.h>
Servo servo;
void setup() {
servo.attach(2); // attaches the servo on pin 2 to the servo object
}
void loop() {
for (int pos = 0; pos <= 180; pos += 1) {
// goes from 0 degrees to 180 degrees in steps of 1 degree
servo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for (int pos = 180; pos >= 0; pos -= 1) {
// goes from 180 degrees to 0 degrees
servo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}
Week Reflection¶
This week I strengthened my ability to design and produce my own PCB board and expanded my knowledge of the connection between microcontrollers and varying output devices.
File Download¶
The files that I used in the week’s processes can be downloaded using this link.