background preloader

Raspberry Pi and Arduino

Raspberry Pi and Arduino
Note. There is now a followup to this post here. The Raspberry Pi is creating quite a storm of interest. I have just got mine and one of the first things that I wanted to try was to get it talking to an Arduino over USB using Python. .. and you know what? It proved to be a lot easier than I expected. Arduino Let's start with the Arduino end. Here is the sketch - paste it into a new Arduino IDE window and load it up onto your Arduino using your regular computer. const int ledPin = 13;void setup(){ pinMode(ledPin, OUTPUT); Serial.begin(9600);}void loop(){ Serial.println("Hello Pi"); if (Serial.available()) { flash( - '0'); } delay(1000);}void flash(int n){ for (int i = 0; i < n; i++) { digitalWrite(ledPin, HIGH); delay(100); digitalWrite(ledPin, LOW); delay(100); }}Raspberry Pi There is a Python library for serial communications called 'pySerial' which has history with Arduino. Step 1. Step 2. Step 3. Step 4. Step 5. Thats it! You type the parts after >>> ls /dev/tty* When you type

Related:  Arduino

Connect Raspberry Pi and Arduino with Serial USB Cable There are many ways of connecting the Raspberry Pi and Arduino, such as using the GPIO and Serial pins and using I2C. But this could be one of the easiest way to get them talking, because hardware that required is minimal: all you will need is a micro USB cable that comes with the Arduino. To Setup your Raspberry Pi, check out this article. Connecting the Raspberry Pi with an Arduino using the UART The use case of the GPIO pins on the Raspberry Pi are rather limited and since I have an Arduino Mega 2560 lying around I can easily connect the two. In the next couple of weeks I’ll explain my process of connecting the Arduino with the Raspberry Pi and creating some sort of Library so the Arduino can be controlled from a web browser using a Raspberry Pi. Connection options for and Arduino to Raspberry Pi connection There are a couple of options for connecting an Arduino with a Raspberry Pi. The first and obvious one is of course plugging the USB port in the Raspberry Pi.

RPi Easy SD Card Setup Back to the Hub Getting Started: Buying Guide - for advice on buying the Raspberry Pi. SD Card Setup - for information on how to prepare the SD Card used to boot your Raspberry Pi. Basic Setup - for help with buying / selecting other hardware and setting it up. Beginners Guide - you are up and running, now what can you do? peripherals - How to attach an Arduino Arduinos usually appear as USB serial devices. The current boards use the USB serial driver built into the main microprocessor, but older Arduinos (and clones) used separate third-party USB-serial chips. To simply receive Serial.print data on the Raspberry Pi from the Arduino, I use the GNU Screen program as a basic terminal: screen [serial-port] [baud-rate] (for instance screen /dev/ttyACM0 9600).

Raspberry Pi and Arduino Connected Over Serial GPIO One way to connect the Raspberry Pi and Arduino is by connecting the GPIO on the Raspberry Pi and the Serial Pins on the Arduino. Because there is a voltage difference between the two device on these interface, a voltage divider or logic level converter would be required. Check my article about connecting the two using I2C if you haven’t already seen it. Before we start, we need to set up the Raspberry Pi so it’s ready for serial communication. 0. if you have not seen my article on how to remote access your Raspberry Pi, take a look here: 1. Using PHP serial class with Arduino and Raspberry Pi Last time I talked about connecting the Raspberry Pi with the Arduino, I could send simple echo strings from the Raspberry Pi to my Arduino. Great now lets step it up! During research I came across the PHP serial class, a great implementation of serial control for PHP. Although the class lacks decent support for Windows, it fully supports Linux (and Raspberry Pi).

Csound music making <CsOptions>; XO-+rtmidi=portmidi -Ma -+rtaudio=alsa -odac:hw:1,0 -r44100 -k441; Mac;-odac0 -+rtmidi=PortMIDI -M1 sr = 44100ksmps = 256nchnls = 2 cpuprc 1, 2 Raspberry Pi and Arduino via GPIO UART In an attempt to get my Raspberry Pi talking to my Arduino I’m exploring various different options. The first was to just use the USB connection, but that was too simple. So, here is how to connect the two using the UART on the GPIO pins of the Raspberry Pi. Raspberry Pi and Arduino Connected Using I2C With Raspberry Pi and I2C communication, we can connect the Pi with single or multiple Arduino boards. The Raspberry Pi has only 8 GPIO’s, so it would be really useful to have additional Inputs and outputs by combining the Raspberry Pi and Arduino. There are many ways of Linking them such as using USB cable and Serial Connection.

ArduinoPi web based controller for Arduino UPDATE: New version found here The ArduinoPi is a web-based controller for the Arduino using the Raspberry Pi. The advantage of using a Raspberry Pi (€28) is that its cheaper than an Ethernet shield (€35) and actually more useful. I talked about connecting the Raspberry Pi and Arduino over a serial connection and how to install and configure PHP serial class so PHP can talk with the Arduino. command line music making My Pi arrived this morning. I installed the debian6-19-04-2012 image.chuck installed easily: Code: Select all sudo apt-get updatesudo apt-get install chuck Arduino and Raspberry Pi communicating over 2.4GHz with cheap nRF24L01+ modules I've had a lot of fun over the past year messing with wireless comms. The 433Mhz/434MHz dirt-cheap modules are fantastic for Arduino, particularly when used with the VirtualWire library which makes them trivial to setup. I've been able to send sensor data and RC car commands using them with just a few lines of code. However, there isn't a version of VirtualWire for RaspberryPi and I don't have the time/skills to port the Arduino one.