pygame + arduino + lolshield = pylolgraph

My son and I soldered together a lolshield for the Arduino Duemilanove at the 2010 Maker Faire:

(Video Note: The flickering you see is based on the camera capture, it doesn’t actually do that…)

After making it… what to do with it? I thought it would be fun to make a Python \ Arduino library that would allow you to send Pygame graphics to the lolshield, and that’s what I implemented.

There are two main parts to the library:

And, I’ve made an example Pygame application illustrating usage:

You can also download all three in a zip here

How to use:

  • My system is WinXP. Not tested on anything else.
  • Download pylolgraph.pde, and upload it to your Arduino. Make sure the BAUD variable matches that in your Python module (below).
  • Download, put it in your Python path.
  • Download Set it’s BAUD variable to match that in pylolgraph.pde, and set its PORT variable to be the port your Arduino is on (will vary depending on your OS).
  • Start pylolgraph.pde on the Arduino. Run from the command-line or double-click the icon: You should see a small Pygame window pop up: When you click the LMB, a white donut will appear in the Pygame window. The same donut should then appear on the lolshield.

Inspect the documentation in for more details on implementation. Here is example pseudo-code for writing your own Pygame application with the code:

import pygame
import pylolgraph

# Setup some constants:
# Create a resolution that corresponds to the lolshield.
# See docs on the pylolgraph.LOLShield.setSurface() method
# for acceptable resolutions.
WIDTH, HEIGHT = (448, 288)
# Baud rate must be the same as setup in pylolgraph.pde
BAUD = 28800
# Port the Arduino is on, on my WinXP box.

# Start Pygame application:
# Make surface that will have its data sent to lolshield:
screenSurf = pygame.display.set_mode((WIDTH, HEIGHT))

# Setup lolshield object:
lolshield = pylolgraph.LolShield(port=PORT, baudrate=BAUD)
# Set the surfcae that will have its pixel data sent to the Arduino\lolshield:

# inside main loop:
    # Draw stuff to screenSurf.  Then:
  1. No comments yet.

  1. August 12th, 2010
    Trackback from : LoL Shield Projects