Simon says game in BeagleBoard SBC

Category

Blog IoT
24 December, 2014 0

Introduction

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.

Development

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: https://github.com/rsisto/simonSaysLuaGpio

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

COMMENTS

Leave a Reply

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

bkadmin
Wednesday December 24, 2014 - 21:12 Blog, IoT
Recent posts
Managing React server state: a simpler approach

The role of the state The state is a property of each component that holds its data, it gives personality […]

Read More…

Continue reading
17 May, 2021
The Importance Of Retrospectives Meetings

What are retrospectives and why are they important? If you know SCRUM you will be familiar with the retrospective meeting […]

Read More…

Continue reading
10 May, 2021
Using Mockito to create Java Unit Test

Let’s start with the definition given by the official page. “Mockito is a mocking framework that tastes really good. It […]

Read More…

Continue reading
1 December, 2020
From idea to deploy

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

Read More…

Continue reading
11 August, 2020