Using an Arduino Shield with an aLaMode Board and a Raspberry Pi
You want to use an Arduino shield with a Raspberry Pi.
Use an aLaMode interface board. You may find that the board requires the Arduinostyle header sockets for shields to be soldered into place.
As an example, you’ll connect an Arduino LCD shield to the aLaMode (Figure 14-21).
To make this recipe, you need:
• aLaMode Board (see “Modules” on page 381)
• Arduino LCD shield (see “Modules” on page 381)
As with all the program examples in this book, you can also download this sketch from the Code section of http://www.raspberrypicookbook.com, where it is called AlaMode‐Shield.
#include <LiquidCrystal.h> // pins for Freetronics LCD Shield LiquidCrystal lcd(8, 9, 4, 5, 6, 7); void setup() { lcd.begin(16, 2); lcd.print(“Counting!”); } void loop() { lcd.setCursor(0, 1); lcd.print(millis() / s1000); } |
Simply upload the sketch onto the aLaMode and you should see the message “Counting” appear on the top row of the display, while the bottom row should show a number that counts the seconds.
Discussion
This example used the Freetronics LCD shield. There are a number of other LCD display shields, and some have different pin allocations. If you use a different module, you’ll need to change the line:
LiquidCrystal lcd(8, 9, 4, 5, 6, 7); |
The parameters are the Arduino pins to be used for the following LCD connections: rs, enable, d4, d5, d6, and d7, in that order.
See Also
The reference material for the Arduino LiquidCrystal library can be found at http://arduino.cc/en/Reference/LiquidCrystal.
Table A-8. Modules | |
Raspberry Pi camera module | Adafruit: 1367, MCM: 28-17733, CPC: SC13023 |
Arduino Uno | SparkFun: DEV-11021, Adafruit: 50, CPC: A000066 |
Level converter, four-way | SparkFun: BOB-11978, Adafruit: 757 |
Level converter eight-way | Adafruit: 395 |
LiPo boost converter/charger | SparkFun: PRT-11231 |
PowerSwitch tail | Adafruit: 268 |
16-channel servo controller | Adafruit: 815 |
Motor driver 1A dual | SparkFun: ROB-09457 |
RaspiRobot board | Sparkfun: KIT-11561, raspirobot.com |
PiFace digital interface board | MCM: 83-14472, CPC: SC12827 |
Humble Pi | MCM: 83-14637, CPC: SC12871 |
Pi Plate | Adafruit: 801 |
Gertboard | MCM: 83-14460, CPC: SC12828 |
Breakout board with paddle terminals | MCM: 83-14876, CPC: SC12885 |
PIR motion detector | Adafruit: 189 |
Venus GPS module | SparkFun: GPS-11058 |
Methane sensor | SparkFun: SEN-09404 |
Gas sensor breakout board | SparkFun: BOB-08891 |
ADXL335 triple-axis accelerometer | Adafruit: 163 |
4×7-segment LED with I2C backpack | Adafruit: 878 |
Bicolor LED square-pixel matrix with I2C backpack | Adafruit: 902 |
PiLite interface board | Ciseco, CPC: SC13018 |
aLaMode interface board | Makershed: MKWY1, Seeedstudio: ARD10251P |
Freetronics Arduino LCD shield | www.freetronics.com |
RTC module | Adafruit: 264 |
16 x 2 HD44780 compatible LCD module | SparkFun: LCD-00255, Adafruit: 181 |