Significant Software


Home



This page is called significant software as it only includes big pieces like libraries and codes for projects. Most of the software here is scattered around other pages too, but I thought I would put it all together into one page. All of the codes and libraries here are ones that I have written, not other people. As a result, if they are not up to the standard that you see from other peoples codes, you will know why.

Jump to:





This code is for my 5X5X5 LED cube that has been mentioned lots in the news section. I have built the cube and written the software, but I still need to construct the driver circuit. For that I will use a stand alone ATmega 328, 4 shift registers, and 30 transistors. Call back soon to see the completed cube! You can see the completed software here.

top of page



This library has been put up in the news section as a download. To help people who just want to browse through the code, you can see it all here.

.h file:
#ifndef RGB_h
#define RGB_h

#include "WProgram.h"

class RGB
{
  public:
    RGB(int red, int green, int blue);
    void red();
    void green();
    void blue();
    void cyan();
    void magenta();
    void yellow();
    void white();
    void purple();
    void custom(int r, int g, int b);
  private:
    int _red;
    int _green;
    int _blue;
};

#endif

This defines the RGB class, all the functions and variables used, and the class constructor. The .cpp file explains to the compiler what each function does. That is here:
#include "WProgram.h"
#include "RGB.h"

RGB::RGB(int red, int green, int blue)
{
  pinMode(red, OUTPUT);
  pinMode(green, OUTPUT);
  pinMode(blue, OUTPUT);
  _red = red;
  _green = green;
  _blue = blue;
}




void RGB::red(){
   digitalWrite(_red, LOW);
   digitalWrite(_green, HIGH);
   digitalWrite(_blue, HIGH);
}

void RGB::green(){
   digitalWrite(_red, HIGH);
   digitalWrite(_green, LOW);
   digitalWrite(_blue, HIGH);
}

void RGB::blue(){
   digitalWrite(_red, HIGH);
   digitalWrite(_green, HIGH);
   digitalWrite(_blue, LOW);
}

void RGB::cyan(){
   digitalWrite(_red, HIGH);
   digitalWrite(_green, LOW);
   digitalWrite(_blue, LOW);
}

void RGB::magenta(){
   digitalWrite(_red, LOW);
   digitalWrite(_green, HIGH);
   digitalWrite(_blue, LOW);
}

void RGB::yellow(){
   digitalWrite(_red, LOW);
   digitalWrite(_green, LOW);
   digitalWrite(_blue, HIGH);
}

void RGB::white(){
   digitalWrite(_red, LOW);
   digitalWrite(_green, LOW);
   digitalWrite(_blue, LOW);
}

void RGB::purple(){
   digitalWrite(_red, LOW);
   digitalWrite(_green, HIGH);
   digitalWrite(_blue, LOW);
}

void RGB::custom(int r, int g, int b){
   r = 255 - r;
   g = 255 - g;
   b = 255 - b;
   analogWrite(_red, r);
   analogWrite(_green, g);
   analogWrite(_blue, b);
}

With all libraries, a keywords file is included. This tells the IDE to change the colour of the functions. The keywords file is here:
RGB	KEYWORD1
red	KEYWORD2
green	KEYWORD2
blue	KEYWORD2
cyan	KEYWORD2
magenta	KEYWORD2
yellow	KEYWORD2
white	KEYWORD2
custom	KEYWORD2
purple	KEYWORD2

Click here to download the library for the non-beta version of the arduino IDE, and here to download the version for the beta IDE.




top of page



This code is for my analog values circuit. It is designed to produce proper analog values, rather than the PWM psuedo analog values that the arduino makes. All the details of it have been released in the news page, but I will repeat them here as well. The .h file - the library's class defining functions and variables, is here:
/*
  Analog.h - Library for outputting true analog values.
  Created by Mark Blyth, April 22, 2011.
*/


#ifndef Morse_h
#define Morse_h

#include "WProgram.h"


class Analog
{
  public:
    Analog(int dataPin, int clockPin, int latchPin);
    Analog(int dataPin, int clockPin);
    void analogOut(byte voltage);
  private:
    int _dataPin;
    int _clockPin;
    int _latchPin;
};


#endif
The .cpp code containing all the functions is here:
#include "WProgram.h"
#include "Analog.h"

Analog::Analog(int dataPin, int clockPin, int latchPin)
{
  pinMode(dataPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(latchPin, OUTPUT);
  _dataPin = dataPin;
  _clockPin = clockPin;
  _latchPin = latchPin;
}

Analog::Analog(int dataPin, int clockPin)
{
  pinMode(dataPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  _dataPin = dataPin;
  _clockPin = clockPin;
}


void Analog::analogOut(byte voltage)
{
  digitalWrite(_latchPin, LOW);
  shiftOut(_dataPin, _clockPin, MSBFIRST, voltage);
  digitalWrite(_latchPin, HIGH);
}
As was said for the RGB library, all libraries have an accompanying keywords file. The analog keywords are here:
Analog	KEYWORD1
analogOut	KEYWORD2
You can download the library here (non-beta IDE) or here (beta version IDE). A full write up of the analog library can be found here.


top of page