Hugh's Blog

Goldsmiths Physical Computing: Lab 01

Requirements

Build a system that allows 10 LEDs to blink according to a pattern set in the software.

Analysis

This task will require 10 LEDs, and 10 560 ohm resistors wired in series. It will require sufficient wiring to connect each set of these components in series from their digital 'pin' to ground.

In addition, I have included a potentiometer to manipulate parameters of the pattern in the code. In the case of the example video, it sets the speed of the base 2 counter display.

Interactivity Design/Scenario

The input to this system, although not required in the lab task, is the potentiometer. The system will support in the case of my sample code, the manipulation of the speed of the binary counter display.

The outputs to the system are the LEDs that display the current value of the count in base 2.

Notes and Testing

The first problem I took most notice of is the difficulty of placing components on the breadboard without cutting them so that while the parts remain reusable, I don't cause any shorts. I overcame that problem by double-checking every wire, and manually shaping the legs of the resistors so that they didn't come into contact with anything they weren't meant to.

After that, I had difficulty with Fritzing - it seemed that whenever I finished one view, my edits to the next view break it, and I get stuck in an infinite loop of editing each view over and over again out of frustration. That issue is definitely down to familiarity with the software, I'm sure it will improve with practice.

Another issue is that I realised that I'm not aware of best practices of diagramming circuits - how to properly route the connections, how to arrange components most legibly, etc. This is something that will improve with practice and with reading other circuit diagrams.

In terms of the programming, I found very little difficulty. I have some limited prior experience of working with Arduino code, and am familiar with the documentation.

One problem with the hardware that I encountered is that when I tried to power the Arduino with a brand new 9v battery, it didn't work. The battery connector wires heated up indicating a short within the connector. I unplugged it and used USB, however I will attempt to repair the 9v battery connector without causing damage.

In summary, I encountered some problems in both the hardware, and my knowledge of it, and have either finished solving the problems, or have developed strategies to solve those problems over the coming weeks.

Diagrams

The following is a circuit diagram for this project built in Fritzing. circuit diagram

The following is a breadboard image for this project built in Fritzing. breadboard schematic

The following is an image of the constructed board. circuit image

Video:

The following is a video of my system in operation, demonstrating the 10 bit binary counter and speed setting using the potentiometer.

Apologies if I've overdone it on the music.

Code

int startPin = 2;
int pinCount = 10;
int inputPin = 5;
int inputValue = 0;
int count = 0;

void setup() {
  pinMode(inputPin,INPUT);
  // initialize digital pin 13 as an output.
  for(int i = 0; i < pinCount; i++){
    pinMode(startPin + i, OUTPUT);
  }
}

void loop() {
  inputValue = analogRead(inputPin);
  for(int i = 0; i < pinCount; i++){
    digitalWrite(startPin+i, bitRead(count,i));
  }
  delay(inputValue);
  count = (count + 1) % 1024;
}