Introduction: Raspberry Pi and Arduino LCD
This is a beginning project for those who want to learn more about the basics of raspberry Pi. You do not need to have any experience with the Raspberry Pi or Arduino, but it would help if you had some past programming experience to understand the code that you will be copying.
Here you will connect the Pi to the Arduino, a wonderful micro-controller capable of doing much more motor control, sensor logging, and operating other complex ICs.
Those very tasks would be much more complicated with the raspberry Pi alone, but if you're up for the challenge feel free to do so, and come to me with any questions
Without further ado, let's begin.
Step 1: Materials
Now, I'll assume that you all already have the Pi; if not I recommend that you purchase one here. I'm certain that there are cheaper ones, but Adafruit Industries is very reliable, and well worth the additional expense.
With the Pi (I'm using model 3B) you will need:
- a monitor
- keyboard and mouse
- HDMI cable
- Power cable (for the Pi)
There rest of the materials are listed below:
- Arduino Uno R3
- USB cable for Arduino
- Liquid Crystal Display (LCD), but you will also need to solder the pins onto it
- Stranded/Solid 22 gauge wires and breadboard (get both here)
- Power supply (if you do not have this, that's fine, the Arduino can power the display, but you will get the most reliable and beautiful readings from the LCD with a steady 5VDC power supply)
Step 2: Circuitry
The connections here are going to familiar if you have worked with Arduino or LCDs before. This setup certainly does not take full advantage of the LCD's wonderful capabilities, but allows for a simple and functional connection with the micro-controller
Here is a helpful map if the first diagram was confusing:
- GND goes to the rightmost pin of the potentiometer, RW, and to the entire circuit's ground.
- VDD goes to the leftmost pin of the potentiometer and to the entire circuit's ground (I cover - / + connections first just as good practice, but this is not necessary)
- Vo goes to the pot's mid pin
- RS -> Digital pin 12
- E -> Digital pin 11
- D4 -> Digital pin 5
- D5 -> Digital pin 4
- D6 -> Digital pin 3
- D7 -> Digital pin 2
Awesome, with the circuit done, we can move on to the interesting stuff.
Step 3: Computer -> Arduino Programming
Now open the Arduino App. I think that the serial library is already pre-installed, but you might have to re-install it for the sketch to work.
After running the SerialDisplay.ino program, open the Arduino command prompt (Cmd + SHIFT + M), and type in "hello LCD", and press enter, the LCD should now display the message. If so, unplug the Arduino, and move on to the next step.
- Check if the circuit is correct
- Make sure that the Arduino sketch has properly uploaded
- Make sure that USB cable is working
If all else fails, connect the LCD to an external power supply, and if that doesn't work, leave a comment below
Step 4: Raspberry Pi -> Arduino Programming
Hopefully, you've been able to communicate with the LCD with your computer. Now it's time to do so with the Raspberry Pi.
With the Arduino not connected to the Pi, run the following command from the terminal app
Now connect your Arduino into the USB slots of your raspberry Pi. In terminal, then repeat the command write
Hopefully, you will see a difference in the ports listed. For me it was /dev/ttyACM0 that was different when I plugged in the Arduino. For most of you it should be this, but this is just to verify that it is indeed the Arduino.
Knowing this, open Python 2.0 in the menu, and run the following commands, pressing enter after each command:
ser = serial.Serial('/dev/ttyACM0',9600)
You should now see the words "RaspberryPi" appear on the LCD screen. If you do not see this on your LCD, leave a comment, and I'll get back to you as soon as humanly possible.
We have a be nice policy.
Please be positive and constructive.