Skip to content

11. Output devices

This week I worked on creating the board I would use for my final project.

Group Work

Individual Work

The first thing I had to do was understand how a motor would work and what would be needed to be able to code my output device. Thanks to this helpful guide I was able to understand that I needed a motor driver in order to properly code my device. Luckily we had some on hand in addition to the Arduino Uno’s or in this case a substitute to an Arduino Uno. I started by setting up my Motor driver in accordance to the example above. image test image test image test image test image test image test

With that I opened up my Arduino App and started to program my board. I started utilising an example code on how to make a motor spin periodically:

I uploaded the code to my board and with a piece of tape to track the spin it worked in an unexpected manner not spinning consistantly but all I needed at this point was to get the motor to spin. image test With my motor working properly I would next work on a button bread board where if the button was pressed the motor would spin. In terms of my final project my lever would press the button when pulled. Here’s the code followed by my process of making my bread board.

#include <Stepper.h>

const int buttonPin = 8;     // the number of the pushbutton pin
const int stepsPerRevolution = 1000;  // change this to fit the number of steps per revolution
// for your motor
// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status


// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 1, 2, 3, 4);



void setup() {
  // set the speed at 60 rpm:
  myStepper.setSpeed(60);
  // initialize the serial port:
  Serial.begin(9600);
}

void loop() {
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed. If it is, the buttonState is HIGH:
  if (buttonState == HIGH) {
  // step one revolution  in one direction:
  myStepper.setSpeed(60);
  Serial.println("clockwise");
  myStepper.step(stepsPerRevolution);
  delay(1); }else {
myStepper.setSpeed(1);
  delay(0);
  }
}

The intial test of the bread board were incredibly successful aside from my button not always wanting to stay in place with continuous pressing. image test image test image test image test

The next step was to open up KiCad to create my board. The board itself was rather simple only requiring a button, capacitor, resitor, and the ports to program my board, attach my motor driver, and power source. I also used this pin example format to help distrubute my pin headers to the pins of my at-tiny board and my code.

The milling of this board was a bit arduous the mill didn’t want to properly cut my board but after a few attempts I got my board. Soldering my board was pretty simple there weren’t a lot of moving parts. image test image test image test The inital upload of my code stressed me out because it refused to work but after a bit of playing around with the outputs I realized I selected the wrong at-tiny board settings and it uploaded perfectly. image test The spinning was rather inconsistent with the button pushing sometimes it would go when pushed and also go when there’s nothing pressing it. I figured it was just an issue with soldering and after some quick tune ups it worked properly. image test image test Here’s how the motor looked after being set up with my lever:

image test


Last update: July 14, 2022