Getting stuff in like light sensors, pressure sensors and switches, and getting stuff out like LEDS and motors is a fairly easy job using a raspberry pi and an arduino. Theres a lot of different things to learn, and remember , and i would suggest going on a short how to use an arduino course. The guide here is a general how-to guide and will list different resources for you to investigate further.
The raspberry pi can do what a arduino can do with out an arduino, but having an external board you can plug in and out is a more convenient way to deal with sensors.
Arduino come in many flavours and styles, there’s also much cheaper knock off versions available too (although these sometimes need a bit of “fiddling”) i would suggest for your first arduino project buy an UNO.
preparing your arduino for pure data
before you can use your arduino you have to install standard firmata on it. Pretty easy if you follow these instructions
preparing pure data for the arduino
the floss instructions have the basics of pduino and is a good place to reference.meanwhile……
In a terminal window on the pi type
sudo apt-get install pd-comport
tihs will install the external comport into your library if you dont haave it already.
Attach your arduino to one of the pi’s usb ports, then open pd. we need to download the pduino external, then point pd path to it.
now we can open the pduino help patch from the browser
if we’re lucky it’ll open the arduino up first time (the StandardFirmata.ino 2.5 message gives it away) and we can see the details of the arduino in the pd window. If it doesn’t show up click the message box marked “devices” and all the devices and their device numbers are listed in the pure data window (you can see mine listed as serial line device 1 (/dev/tty/USB0)), type this number in the “enter the number of your serial device” number box and the arduino will get recognised. Now its time to attach sensors.
lots of different sensors do lots of different things, and theres a few ways of wiring up different sensors, they plug into the arduino in different ways. A good place to start would be to purchase a sensor kit like this. which comes with a detailed pdf.
heres a couple of the pages, showing you the knock sensor and how to wire it up. We don’t need all the information (it goes on to give a program to use it on an arduino – but we’ll be using the pi and arduino), we just need to know what pins do what and how to wire it to the arduino.
the pin with the info on it (the signal) goes to arduino digital pin 3
we can interrogate this pin to find out what is happening .Go to the pd_INPUT_DIGITAL box and double click, which will bring up this interface. In set pin mode click the circle with 3 above it to turn the pin on, and now the number 3 cross below should light up each time we get a knock.
digital pins IN gives us an on and off (like a switch) that we can monitor, digital pins OUT give us an on and off that could turn on a LED ,motor or circuit.
analogue pins IN give us a range of values, something like a light or temperature sensor, similarly at PWM out give us a sliding scale so we can fade up an led or slow down a motor.
Theres also output-servo settings that can precision control servo motors.
here you can see an analogue sensor for humidity testing wired in. See how its now connected to the first analogue in
with pdunio i open ANALOG_INPUTS and click on the 14th circle marked A0. That turns on the input for analogue 0 and we can see it being monitored underneath.