Great, we now have a hardware ALU with its most important elements implemented on a metric tonne of breadboard. However, this awesome little machine is missing a crucial component – the interface to Twitter.
Enter the Raspberry Pi (RPi) – everybody’s favourite credit-card sized PC. As good as it is for playing back high-definition video and surfing the web with a connected monitor, its real power is harnessed when it’s used for a different, deeper purpose.
The RPi sits between our ALU and Twitter’s Application Programming Interface (API). It has two main roles – 1. Managing the sending and receiving of Tweets, 2. Decoding instructions and interfacing with the hardware ALU. This is where the RPi comes into its own – it can run a fully featured Linux operating system and so can perform high level computing operations like fetching and posting a Tweet, but it can also interact with very low-level hardware using the few on-board GPIO pins and, more importantly, the super-powerful I2C and SPI buses.
Embedded applications are where the RPi really rocks. Out of the box it’s easy to power (via USB), has internet connectivity and has a great way of interfacing with the real world – I2C. I2C is a communications bus that allows communication of data and commands between Integrated Circuits, hence Inter IC, IIC and I2C. Find out more about I2C here.
The I2C bus was designed by Philips in the early ’80s to allow easy communication between components which reside on the same circuit board. – i2c-bus.org
We’re using it with several Microchip MCP23017 Port Expanders, which effectively gives the RPi 16 remote, bidirectional I/O ports. This is great as it allows us to put data into the registers and read from the output register using a single RPi.
An awesome example of how useful the Microchip Port Expanders are can be found at SK Pang Electronics blog where a Port Expander has been connected to the RPi using just four wires (PWR, GND, SDA, SCL) and gives the programmer 16 individually addressable IO pins, as shown by the 16 LEDs (check out the video). However, what’s even more impressive is that the Port Expanders themselves can be daisy chained to make available even more IO. More Port Expanders are easily introduced to the system by connecting them with the same four wires as the first one.