First steps towards a robot: GPIO on the NGW100

After the arduous task of getting Python to cross-compile for the AVR32, the next step was to relax a bit and take a stab at getting some preliminary communication with the I/O ports going (which is the first step towards getting peripherals going, which means robot time). My co-conspirator on this project, Tim, was looking into CherryPy to allow web-based communication. This is an interesting idea, so I decided to take a stab at mixing it all together to make a web-based LED control program. Resulting code is after the break.

import cherrypy
class gpio_pin:
    def open(self, port_name, pin_mask, mode):
        self.port_name = port_name
        self.pin_mask = pin_mask
        self.mode = mode
        self.file = open(self.port_name, self.mode)
    def close(self):
    def toggle_on(self):
        if self.mode == 'w':
    def toggle_off(self):
        if self.mode == 'w':
class HelloWorld:
    def index(self, led=None, command=None):
        data = """<form action="index" method="post">"""
        if( led and command ):
           if( led == 'A' ):
           if( led == 'B' ):
           if( command == "On" ):
           if( command == "Off" ):
        data += """
<select name="led">
<select name="command">
<input type="submit" value="Send">
        return data = True
gpio = gpio_pin()
This entry was posted in tech. Bookmark the permalink.

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>