Road to Create | Art of creation



Mini-morse-code bug

For some reason I needed to package a message to some people without me wanting to type it out, or even write it out. No, there needed to be a new approach to how I sent this message. Something I came up with was a morse-code-bug, that contained the message I wanted to send. A simple way of achieving this goal would be by just recording a piece of morse code and sending it over email or something. This however didn’t seem too much fun to me so I wanted to do something different. I had chosen to write a small piece of embedded code and accompany it with some hardware to run it on. The microcontroller I have chosen for this device is the Attiny25. Why this controller? Well a smaller controller wouldnt’ have enough programspace to contain a message, a bigger controller is more expensive.

The device can be made really easily. You simply take the 8pin chip, add power to the corresponding pins, add a buzzer on port B4 (or any other io pin if you change it in the code) and throw the code on the controller. (this last part can be either done by an AVRISP MKII or clone, or by using an arduino as a programmer (

The code is available as a download here, feel free to use it for your own sinister purposes!


MorseCode <– Download is a loose piece of c code. Can also really easily be ported to Arduino or any other MCU.

No tags

For a school project we needed to run four 50Watt peltier elements with an Arduino. Ofcourse pulling the power from the Arduino itself wasn’t an option. Also due to the fact that the Peltiers need 12V to run on full power and the Arduino environment can only supply 5V. Fixing this solution with a bunch of transistors would have been nice, if the total amps needed wouldn’t have been as high as >10A. So this resulted in a big quest over the campus, trying to find a H-bridge we could use, without having to promise we wouldn’t break it. (Common, everyone know I love to watch things burn :p) So Finally we stumbled upon a perfect, relatively cheap solution for our project. The Pololu driver with the VNH2SP30 on board. This neat little board can provide us with up to 14Amp continuous power. Pretty much perfect for now. Sadly there wasn’t an Arduino library available yet, so I decided to build one myself. The library is pretty easy. It provides you with some basic functionality like:

  • PD(PWM pin, FWD pin, RVS pin)  -  Initializes the library (make sure you use a PWM port to actually be able to run PWM!)
  • begin()  -  Initializes the ports and starts the library
  • stop()  -  Stops the driver from driving
  • forward(unsigned byte)  -  Runs the driver in one direction at the given speed
  • reverse(unsigned byte)  - Runs the driver in the other direction at the given speed

There is an expample sketch provided if you are still not sure how to use it.

Is the library not working or do you have any other questions please let me know ;)



· · ·

Today I was fiddling around with my new Saleae Logic analyzer, and got to fix a bug in my simple software UART transmitter along the way.

All excited what to first analyze with my new neat toy, I remembered I was working on a piece of software to enable the attiny45 to spit out some sensible data. Ofcourse I could have chosen to go for the USI interface Atmel built into the device, but I first wanted to go all low level on it and build a piece of bitbanging software.

After fiddling around for an hour or two I finally had it working correctly. Before I had been using my DS Scope to compare the data and count bits, which is as some of you may know an awful lot of work to do. So adding a logic analyzer to the equation was a good idea in my opinion.

The result

The software is capable of running a uart tx pin at the staggering rate of baud 1200. So this is not software you want to use to run a lot of data on.

For those of you interested in the code, feel free to dig around, its free to adapt and use. I would really appreciate to see the result if you make something nice out of it ;)

Download link: HERE

No tags



2 Digit Display (Weekend project)

For a project I needed a dual 7-segment display to show numbers varying from 00 to 99. About a year ago I tried to do the same, but I didn’t really know how to do it yet. Last weekend I summoned all my knowledge to try it again.

A 7-segment display is a display made out of 7 segments (Duh..) Those 7 segments are in my case simple red leds. There are 2 types of segment displays on the market, common anode and common cathode. Which means that all VCC or Ground pins are connected with eachother. For this project I choose to go for the common ground pin.
First I had to connect the display to the arduino. I used digital pin 2-11 for this, I skipped 0 and 1 because those are used for serial data. Between all the data pins and the display I added 1kOhm resistors. (At first I thought it wouldn’t be necessary, but when my poor arduino started to fry I added them anyway.)

The display is connected to the pins written next to the segments.
The next thing that had to be done, is making a list of all characters I wanted to use, and check which pins should be high for that matter. (on the right)
I’m always having trouble programming things I do not completely understand. Therefore I had to choose a data structure to save the character data in a way I could visualize it. That’s why I have chosen to go for a two-dimensional array.

In case you’re not familiar with arrays, here’s a short explanation:

Left top shows a simple variable, containing a value of the size integer. This variable can easily be requested by asking for “a”.
The left right shows a simple array. I accidentally forgot to write the name of the array, so it would actually be something like: int a[]. In this array you can put values of the size integer.
int a[] = {4,6,2}
a[1] Will return the value 6, since 6 is the second number in the array. (Arrays start counting at 0)

The structure I’ve chosen is shown below the previous two, namely a two-dimensional array.
If a variable can be a box containing a variable, and an array a set of boxes containing a variable a two-dimensional array are multiple sets of boxes stacked on each other.

int nums[][8] = { 
  {1,1,1,0,0,1,1,1} , 	//Digit ZERO
  { 0,0,1,0,0,0,0,1} 	//Digit ONE

This piece of code initializes an array called nums, containing two arrays with a predefined length of 8 integers.

So, now we’ve got the character data saved for usage. The next problem we have to face is the switching between the two displays. Switching between the two screens happens in the following sequence:
- Disable display 2
- Enable display 1
- Show data for display 1
- Disable dispay 1
- Enable display 2
- Show data for display 2

Enabling ground on the two displays is done by a transistor, connecting the display to ground when the signal on the base of the transistor is high.

The rest of the information for creating a two character display can be substracted from the code. If anything is still unclear you can always leave a comment or mail me for more information.

int nums[][8] = { 
    1,1,1,0,0,1,1,1                                  }
  ,     //Digit ZERO
    0,0,1,0,0,0,0,1                                  }
  ,     //Digit ONE
    1,1,0,0,1,0,1,1                                  }
  ,     //Digit TWO
    0,1,1,0,1,0,1,1                                  }
  ,     //Digit THREE
    0,0,1,0,1,1,0,1                                  }
  ,    //Digit FOUR
    0,1,1,0,1,1,1,0                                  }
  ,    //Digit FIVE
    1,1,1,0,1,1,1,0                                  }
  ,    //Digit SIX
    0,0,1,0,0,0,1,1                                  }
  ,    //Digit SEVEN
    1,1,1,0,1,1,1,1                                  }
  ,    //Digit EIGHT
    0,1,1,0,1,1,1,1                                  }
  ,    //Digit NINE
    2,3,4,5,6,7,8,9                                  }
  ,    //PIN INITS

int fdig, sdig;
int val;
int j;

void setup()  { 

  for(int i = 0; i<8; i++){
    pinMode(nums[10][i], OUTPUT); //Initialize all pins for writing
  pinMode(10, OUTPUT); //First Digit 
  pinMode(11, OUTPUT); //Second Digit

void loop()  {
  val = analogRead(0);    //Read the input pin
  j = map(val, 200, 1023, 0, 99); //Potmeter
  digitalWrite(11,LOW);    //Disable second Digit  
  digitalWrite(10,HIGH);   //Enable first Digit

  if (j>=10){                  //If Number > 10 use first digit
    fdig = j/10;               //Calculate the first digit
    for(int i = 0; i<8; i++){  //Run through the arrays for showing the numbers
      digitalWrite(nums[10][i], nums[fdig][i]);    //nums[arraynr][ledstatus(0/1)]

  else{                        //If Number <10 
    fdig = 0;                  //make first digit 0
    for(int i = 0; i<8; i++){
      digitalWrite(nums[10][i], nums[fdig][i]); 

  delay(10);               //Giving my sweet controller some time to rest

  digitalWrite(10,LOW);    //Disable first Digit 
  digitalWrite(11,HIGH);   //Enable second Digit

  sdig = j%10;             //Modulo 10, remains are for second digit

  for(int i = 0; i<8; i++){//Run through the arrays for showing the numbers
    digitalWrite(nums[10][i], nums[sdig][i]); //nums[arraynr][ledstatus(0/1)]

  delay(10);                //Giving my sweet controller some time to rest

No tags

Theme Design by