Raspberry Pi 10 LED “Chaser” Mini Project

LED Chaser Project

LED “Chaser” Project

I have been a little overwhelmed with school right now. With 6 courses, I am biting off a larger chunk than the rest of the student body. The saving grace among the slew of work is one of my courses that involves Embedded Systems.

In class we do not use the Raspberry Pi of course as it is relatively new. Instead we use a RISC based board from Analog Devices called the ADSP-BF533. So far we have played with controlling LEDs and switches. To entertain myself on the long weekend, I decided to blow the dust off my Pi and apply my new found knowledge outside the classroom.

To refresh myself with some of the pi’s functionality, I was traversing through the following article about turning on and off LEDs: https://projects.drogon.net/raspberry-pi/gpio-examples/tux-crossing/gpio-examples-1-a-single-led/ .

At the end of the article, there are instructions to add 5 LEDs and a switch to create a basic pedestrian/traffic light system dubbed the ‘Tuxx’. I decided to crack open the provided C file to see just what was involved in making the project work. As expected, I found a very simple program that uses the authors GPIO library known as ‘wiringPi’. This library makes dealing with the RPi GPIO a piece of cake.

I opened up my IDE and began to code my own program. However, unlike the ‘Tuxx’ I will start with something a little more simple: an LED Chaser.

Parts Involved:

1x Raspberry Pi Model B
1x Prototyping Breadboard
1x Adafruit Breakout Kit
10x 1k-1.2k Ohm Resistors
10x Red LEDs
Mess of wires

My Code:

/* 	Matthew Sembinelli
*	October 13, 2013
*	slappablog.com

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h> 
#include <wiringPi.h> 

// The input button

#define	BUTTON	16

void setup(void);
void waitButton(void);
void LightInOrder(int);

void setup (void)
	int i;

  if (geteuid () != 0)
	fprintf (stderr, "Run again as root. Exiting...\n") ;
    exit (0) ;

  if (wiringPiSetup () == -1)
    exit (1) ;

  printf ("Setup ... ") ; fflush (stdout) ;
  for (i = 0 ; i < 10 ; ++i)
    pinMode (i, OUTPUT) ;
    digitalWrite (i, 0) ;

  pinMode (BUTTON, INPUT) ;

  printf ("OK\n") ;

void waitButton (void)
	fflush (stdout) ;
	while (digitalRead (BUTTON) == HIGH)
    delay (100) ;

void LightInOrder(int delayTime)
	int i;

	for (i = 0 ; i < 5 ; i++)
		digitalWrite (i, 1) ;
		digitalWrite ((i-1), 0) ;

	for (i = 0 ; i >= 0 ; i--)
		digitalWrite (i, 1) ;
		digitalWrite ((i+1), 0) ;

void main(void)
	int delayTime = 20; //Adjust this delay time to increase or decrease the speed of the chaser

Thanks for taking the time to look at this post. I sure had fun doing this mini project, and there are many more to come! Drop a comment below if you have any questions.

MIDI Song on Raspberry Pi W/ Piezo Speaker

I pulled a piezo speaker from an old desktop computer that I had. These things can run directly off the GPIO or you can add a resistor to lower the volume if necessary. I connected the speaker to pin GPIO18 (PWM) and GND.

I then used a modified version of the code presented here on the third post. I do not take any credit for writing this code.


What the poster did not mention was that “tone 60” is equivalent to MIDI middle C. From there you can figure out what value most of the major notes are. Then you can create a little song by expanding upon that script which is what I have done. I did it line by line which is likely the laziest and most inefficient method. Instead an array could have been used or an input file to be parsed. You can also change the time length of each note but I just left most of them 0.1 seconds.

There are more efficient ways of doing it, but I was working with what I had for my first go at the GPIOs.

I get my GPIO breakout and breadboard this week, so I will play around more.

Quick Cold Air Llano Runs – A8-3870K

So after llano released I wanted to give it a shot but never got around to it. Now finally after so long I’m going back to it. (See previous posts for motherboard and CPU shots)
Picked up the Gigabyte A75-UD4H and 3870K for around $160CAD total so it couldnt hurt 🙂

This is the ram kit I have

I decided to do some preliminary CPU tests under cold air. For those of you that do not know, Llano does not clock nearly as well as Phenom II did on air. Max stable air clocks for my chip are around 3.5GHz on the corsair H50 so I’m using cold air to give a little bit more headroom for benchmarks.

About -10C outside currently.

Just did some quick and dirty chilled H2O runs with my corsair H50 on the 3870K. Corsair rad was put out the window in -10C weather.

Ram was left at a stock XMP profile, just overclocking with multiplier here. Untuned Win 7 X64

Shot of the setup

4GHz SuperPi 1M

3.8GHz wPrime 32m

3.8GHz PiFast

3.8Ghz Cinebench………….the 3.4GHz result was actually done at 3.6

4.1GHz validation All 4 Cores………mm voltage

Thats all for tonight, the chip is back to folding for the time being.

When I get time to bench again, next up is some ram+GPU tuning and some 3d benchies vs stock benchies 🙂

Making Up For Lost Time – A8-3870K Will Be On Hand Soon!

Well amidst all the new releases of trinity and PD, I have opted to pick up a 3870K paired with a GA-75-UD4H to have a little bit of fun.
I skipped over llano when it came out and most other releases as I have been pretty busy with life outside the forums/blog.

So now it is time to make up for all that.

I will be receiving my 3870K in a week, but for now here are some shots of the board and ram:

This is the ram kit I have : http://www.legitreviews.com/article/1647/1/

Hopefully this can provide enough bandwidth for the iGPU…especially once I tweak it 😛

I will be posting results in here once I get the APU

Slappa’s IceTube – A6-3400M APU Overclocked to 3.4GHz

I have recently been working on fixing my HP g6 laptop. As a result, everything is ripped apart down to the bare bone hardware itself.

That is when I started to get ideas. …

We all know that mobile llano (sabine) is capable of being software clocked using K10Stat. So I decided to bust out a lightweight dry ice pot and fill it with regular ice cubes!


All Set Up!

Down Pot Shot

Getting Frosty…oh and If you’re wondering why I’m reading the GPU temp, it is on die so it is the same as the CPU temp 🙂

Mobile Madness! 3.4GHz on an A6-3400M APU

Base Shot, and SODIMMs

Beware of condensation!
Fun Fact: Right after I took this photo the water leaked through the seal and dripped down onto the socket. Luckily I unplugged the motherboard before any damage was done.

Now for a couple fun little benchmark runs!

SuperPi 1M @ 3.3GHz

wPrime 32m 4 Threads
3400M @ 3GHz

Well all I can say is that was fun. The laptop motherboard I am using actually has a broken connector for the LCD screen so I am waiting for a new one to ship. Maybe I can pick up a cheap A8-3500M and do some benching on that!