Simon says game in BeagleBoard SBC



Blog IoT


In my last post about GPIO and LEDs in lua, I wrote about a cool feature in Linux when working on embedded systems, such as the possibility to access hardware devices using the file system.

In this post, I’ll be using this feature to build the game, ‘Simon says’ in Lua. I’ll be using a BeagleBoard rev C4 with ubuntu 11.04 installed.

We did this project with my colleagues for an embedded robotics course, so the credit is also shared with them. ?

GPIOs in the Beagleboard Note

According to the Beagleboard datasheet, the processor can be configured to use all the pins in the expansion port as GPIOs, but this is a more advanced task that requires changing the MUX registers in the processor, which can be achieved by recompiling the kernel changing the kernel headers.

The Ubuntu image for Beagleboard already has several pins configured as GPIO. Thanks to Michael Shiloh, he found the pins that can be used as GPIO by default. This is the list of GPIOs you can use (and the corresponding pin in the expansion port):

  • 157 (pin 22)
  • 159 (pin 18)
  • 161 (pin 16)
  • 162 (pin 14)
  • 136 (pin 9)
  • 137 (pin 7)
  • 138 (pin 5)
  • 139 (pin 3)

For a reference on the pin number for each of these GPIOs read the Beagleboard datasheet.


For this game, I only used 3 LEDs, because at that time I didn’t have more of these ? but it’s very easy to add more.

I used 3 GPIO ports to connect the LEDs and 3 for the buttons. Using the default ubuntu installation I could plug 4 LEDs and 4 buttons. If I wanted more, I should tune the kernel as said earlier in the post.

Connecting the LEDs and buttons

The picture below shows how everything is connected. It works as a proof of concept, but I wouldn’t give this to anyone to play. ?

Since the picture does not explain this clearly:

I used pins 3,5,7 (GPIO 139,138,137 respectively) as input for the buttons and pins 12,14,16 (GPIO 158,162,161 respectively) as output GPIOs for the LEDs.

The diagram below shows how to connect the buttons and LEDs.

Source code

The source code is available in Github:

The source code is quite simple, The GPIO library explained in the GPIO post was used to interface with the LEDs and buttons.

The rest of the code is just a main loop implementing the game logic. When the user loses, the LEDs blink several times, and the application quits.

That’s it for now. Let me know if you have any comments or if the code was any use for you! Please share! ?

What’s your Reaction?

Leave a Reply

Your email address will not be published. Required fields are marked *

Are you interested in a project like this?

Hire Us