Programming the Vega Edge

The Vega Edge uses the super-small ATtiny85 microchip running Arduino code. That means that you can reprogram it with whatever behaviour or flashing pattern you want!

You will be making an adaptor cable to connect your Vega Edge to an Arduino board. (What's Arduino?)

This tutorial requires basic Arduino experience and a functioning standard Arduino board (such as the UNO or Duemilanove).

If you've never used an Arduino board, get started at the Arduino website; it's a great resource.


What you will need
1. An Arduino UNO or Duemilanove and the Arduino software. This hack won’t work with Arduino Leonardo boards or older Arduino boards with an ATmega168 processor.2. One 10µF ceramic capacitor 
3. wire in two colours

4. male header pins
5. Solder and soldering iron

6. The arduino-tiny firmware, located here, get the one appropriate for your version of the Arduino software (probably Arduino 1.0). 

7. 
Our Vega code as a base to start programming from.


Step 1: Install the ATtiny firmware for Arduino

  1. Install the Arduino software, version 1.0.5 or 1.5.x Beta (1.0.2 and earlier will not work).
  2. Download the arduino-tiny firmware. If you’ve already done ATtiny-Arduino work, note that this is a different firmware from that used by MIT High-Low Tech.
  3. Unzip the firmware file. It should contain a folder called tiny.
  4. Within that folder rename the file Prospective Boards.txt to boards.txt.
  5. Locate your Arduino sketchbook folder (you can find its location in the preferences settings of the Arduino software, get there by File > Preferences in the menu). Within the sketchbook folder create a sub-folder called hardware, if it doesn’t exist already.
  6. Copy the tiny folder into the hardware folder. You should end up with folder structure like Documents/Arduino/hardware/tiny.
  7. Restart the Arduino software.
  8. You should see a list of new ATtiny entries in the menu Tools > Board 

Step 2: Configure your Arduino as a programmer

  1. Connect your Arduino board to your computer using a USB cable. 
  2. Open the Arduino software.
  3. In the top menu, go to Tools > Boards to select your Arduino board in the dropdown menu.
  4. In the top menu, go to Tools > Serial to select the appropriate serial port that your Arduino board is connected to.
  5. In the top menu, go to File > Examples > ArduinoISP.
  6. Upload this code to your Arduino board. This code configures your Arduino as a programmer for the Vega Edge.


Then, go to Tools > Boards and select:

ATtiny85 @ 1 Mhz (internal oscillator; BOD disabled)


Now you’re ready to programme your Vega Edge!

Step 3: Make the programming cable

The programming pinout for the Vega Edge was designed to make it easiest to program with a standard Arduino using an adaptor cable. If you would like to use an existing AVR programmer, we provide the pinouts at the bottom of this page. Here's a photo of our programming cable next to the Edge components and an Arduino (just ignore that it's an Arduino Leonardo which won't work with this tutorial!):

We used some ribbon cable with six wires in it, but you can also use six individual pieces of wire.

  1. Cut 6 lengths of wire (at least 20 cm (or 8 inches)). It would help if one of these wires was a different colour to help you locate pin 1 on the headers going to the Edge, you'll see that ours is red.
  2. Strip the tip of each wire, and solder one to each pin of the male header strip. If you have one coloured wire, solder it to one of the outside header pins.
  3. Then do the same to the other side of the wires, but solder an individual header pin to that lone, other-coloured wire. See the left end of our cable in the image above. This single pin goes to the 5V on the Arduino board (instructions below).

Step 4: Physically connect the Arduino to the Vega Edge

The Vega Edge is programmed using the row of six holes in the Edge’s circuit board.

First, insert the 10µF ceramic capacitor into the Arduino between the GND and RESET sockets, the negative side of the capacitor should go to GND.

Then plug the end of the cable with the row of 5 headers into the Arduino sockets GND, 13, 12, 11, 10, and the lone little male header pin goes into the 5V socket on the Arduino.

Place the other end of the cable with the strip of 6 male headers into the row of 6 holes on the Vega Edge board. You will not be soldering them in placeyou will be making a temporary connection while uploading your code.

Pay close attention to the placement of Pin 1, which is identified by the square solder pad on the Vega Edge, and your other-coloured wire, and connects to 5V on the Arduino. Do not put this in the wrong way! Your battery will get hot and bad things will happen.

To make a good connection between the male headers and the holes on the Vega Edge you will need to tilt the headers within the holes so that they are all simultaneously and firmly touching the metal in the holes and hold them there with your fingers while programming.

Here's a diagram of what connects to what:

And here's a photo of how you should hold the cable into the Edge board:

Step 5: Upload your code to the Vega Edge

Download our Vega Code, unzip it, and open Vega40.ino in the Arduino software.

While holding the adaptor cable firmly with your hand in the Edge circuit board, upload your code to the Vega Edge like any other Arduino sketch.

This can sometimes be finicky and may take several tries before you get an “upload successful” message. Hold the pins firmly in the holes. If you get uploading problems, wiggle the pins in the holes and try again. Sometimes this can be tricky, but you’ll get the hang of it!

You’ve successfully reprogrammed the Vega Edge! Yay! Take a look at our code to get an idea of how the Edge is set up—modify it or start from scratch. Take a look at our programming suggestions below.


THINKING ABOUT THE CODE

Off or Sleep?

In our code, every press or release of the button will cycle to a new program state. Because there’s one button controlling the whole thing, the Vega Edge never really turns “off”—its “off” state is actually putting the little guy to sleep. We’ve taken lots of precautions to save every little drop of power we can in sleep mode. If your code doesn’t ever put the Vega Edge to sleep by calling the goToSleep() function then you will run out of power sooner than you think. This isn't the end of the world, but be aware!

Double-clicking and power consumption

We use a double-click to turn the device on. In our user testing, a single click to turn on meant that the Vega Edge kept turning itself on accidentally while in a pocket or purse, secretly draining the battery. You can get rid of the double click, but do so at your power-wasting peril!

Flashing patterns, memory storage, and timing

The two flashing patterns use different structures, showing the different ways that you can think about creating flashing patterns, seen in the fadePatterns sketch tab. flash_type 1 uses logic to modify variables, flash_type 2 walks through a 256-step sequence of LED brightness values.

When using something like flash_type 1 remember that the ATtiny is much slower than what you may be used to with an Arduino, and timing in your flashing patterns might not be what you expect. Experiment! When using something like flash_type 2 remember that the ATtiny has very little memory space. If you create enormous arrays, or many arrays, you may experience weird behaviour as you try to use more memory than the chip has.

As a bonus, the code you downloaded contains the flashing patterns available in the Kickstarter Sparkle pack as well as other patterns we never implemented!

The mysterious Pin 2, measuring battery level?

Pin 2, also known as A3, is actually set up with a voltage divider to measure the voltage of the battery, and potentially warn the user when it's time to recharge. We weren't able to implement this function in time for the launch of the Edge, but the functionality is there in the hardware. Between day jobs and diaper changes we're working on implementing this for the next round of Edges, but if you implement this in your Edge please let us know!


OTHER QUESTIONS?

Why isn't it programmable by USB like the Adafruit Gemma?

The Gemma looks like  a great little device. Unfortunately it was released after the production of the Edge, and so we weren't able to investigate if it could be a basis for the Edge. And last we checked, it only had two dimmable (PWM) outputs, and our Edge design needs three dimmable outputs. But USB programming for the Edge is still on our wish list.

Why the weird programming pinout?

Why did we create our own weird pinout and programming solution rather than the standard 6-pin AVR male headers?

The Vega Edge is a wearable object and those concerns came first. Male headers would have been bulky, the flat headers used in products like the Lilypad Arduino would have take up too much real estate on the board, and the 2x3 AVR layout would have made the pin-insertion unreliable.

We also wanted to allow for as many people to play with it as possible, and many more people have Arduino boards than AVR programmers, so we chose a layout that would make it easiest for those with an Arduino.

Do you have a better solution? We’d love to hear about it!

For those of you with AVR programmers, we figured that if you’re smart enough to have an AVR programmer, you already have the skills to make an adaptor cable to your programmer, and it might look something like this.


Would you like to help us make it better?

If you're thinking things like....

          “I can show you a better way to save more battery power!”
          “I’ve created a tool for designing flashing patterns. Want to see?”
          “You’re doing it all wrong. Let me show you how to do it right.”
          "There are mistakes on this page, can I help?"

Then please write to us! We want everyone’s Vega Edge to be the best it can possibly be. Send us all your suggestions!