Pages

New domain and blog

Please head over to my new domain to view my blog and current projects

Wednesday, 29 August 2012

Raspberry Pi: GPIO input and output

So I got my Raspberry Pi yesterday and am super excited. I feel like a 10 year old on Christmas morning. I had already loaded the the Raspbian image onto an SD card so as soon as I got it I powered it up and away it ran.

The first thing that I wanted to get working was the GPIO pins. I did a bit of reading and some basic python examples and away I went. Have a look at this website for a very decent crash course in python.

The first thing you need to do is import the GPIO module. This can be installed from here.

Then you need to tell python that you are going to use the Raspberry Pi's pin numbers when referencing the ports. The direction of the port is then set.

Once the setup is complete, you can start your code. In my hardware, I connected a push button switch to pin 11 and pin 18 and an LED to pin 3 and pin 5.