Week 9: Output devices

The assignment:

1. Group assignemt: Click here

2. Individual assignment: Add an output device to a microcontroller board you've designed, and program it to do something

How I did it

I wanted to get a servomotor working. I had access to a SM-S2309S.

See specs here

I started by going to a page about

Servo Motor Basics with Arduino

Here I could read about how to connect and control servo motors with Arduino IDE. I decided to make a setup where the servo moves from 0 degrees to 180 degrees and back again.

Next step: The code from the page was the same as the code in the Ardiono IDE library under servo>sweep. I used the code from the library. I determined the pin for where the data would be submitted to pin 4. I found out that I had switched the TX and RX pin, that’s why I used pin 4.

TX pin Pinouts

Now I was ready to upload the code to my ATtiny board. This is what I did to program the ATtiny with a programmer. I connected this programmer:

Programmer

with the AatTiny board:

Connector

I checked the settings for board, port and programmer and then I uploaded the code from the library using >sketch>upload using programmer.

Now I could make a serial connection. I checked the servo for connetions

Connector

and then the connector on the board

Connector

And connected it all on my desk

Connector

Now I was ready to customize the code myself. I wanted the servo to move based on humidity reading. 60% humidity or above should make the servo move 90 degrees and when the humidity drops to 58% percent or below it should go back to starting position and stop moving.

Code for servo

Here is the design file = Full code that made the servo move

Now the servo started to move as programmed: