Simon says game in BeagleBoard SBC


Blog IoT
24 December, 2014 0


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! ?


Leave a Reply

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

Wednesday December 24, 2014 - 21:12 Blog, IoT
Recent posts
From idea to deploy

When the great idea and background just isn’t enough […]

Read More…

Continue reading
11 August, 2020
Reclaim your disk space from Xcode

Do you have problems with the space on your disk? You are in the right place! This post is for […]

Read More…

Continue reading
25 June, 2020
RoR – Get your exceptions notified via Slack

Have you ever wanted to be one step ahead, and be notified of any unwanted exception before your users have […]

Read More…

Continue reading
18 October, 2018
Easy creation of a new Node + React project

Starting a new project is something everybody loves to do. However, some steps are always the same for every project. […]

Read More…

Continue reading
3 October, 2018