Rechercher dans ce blog

Affichage des articles dont le libellé est Raspberry Pi. Afficher tous les articles
Affichage des articles dont le libellé est Raspberry Pi. Afficher tous les articles

lundi 10 février 2014

Control an LED with the Raspberry Pi and via the web

What a great little device the Raspberry Pi is! After my initial setup it is time to play around with the input and output pins. The first example has to be to switch on an LED. This can also be done remotely via a web interface and better, I cannot only switch the LED off, but the whole Raspberry Pi as well.


Thanks to the work of many others, it is straightforward to control the GPIO (General-purpose input/output) pins. Gordon's Project site shows how this can be done with his wiringPi library. For testing purposes I use an LED and a small resistor on pin 17. To control the LED it is as simple as:
gpio mode 0 out
gpio write 0 1
gpio write 0 0
I can also use a browser to control the pins. The webiopi projects provides an out-of-the-box solution for this. That means, I can control the pins from any other device in the network, such as my mobile phone!


Even better, I can switch the Pi off from my phone as well. Daniel Pecos presents a little script and layout that shuts the Pi down via a physical button on pin 4. But, I can also use my phone via webiopi; with Daniel's script running in the background, I can set pin 4 to input, tap it and the Raspberry Pi will shutdown.

Control an LED with the Raspberry Pi and via the web

What a great little device the Raspberry Pi is! After my initial setup it is time to play around with the input and output pins. The first example has to be to switch on an LED. This can also be done remotely via a web interface and better, I cannot only switch the LED off, but the whole Raspberry Pi as well.


Thanks to the work of many others, it is straightforward to control the GPIO (General-purpose input/output) pins. Gordon's Project site shows how this can be done with his wiringPi library. For testing purposes I use an LED and a small resistor on pin 17. To control the LED it is as simple as:
gpio mode 0 out
gpio write 0 1
gpio write 0 0
I can also use a browser to control the pins. The webiopi projects provides an out-of-the-box solution for this. That means, I can control the pins from any other device in the network, such as my mobile phone!


Even better, I can switch the Pi off from my phone as well. Daniel Pecos presents a little script and layout that shuts the Pi down via a physical button on pin 4. But, I can also use my phone via webiopi; with Daniel's script running in the background, I can set pin 4 to input, tap it and the Raspberry Pi will shutdown.

mardi 21 janvier 2014

Fun with the Raspberry Pi

Since Christmas I have been playing around with a Raspberry Pi. It is certainly not the fastest computer, but what a great little toy! Here are a few experiences and online resources that I found helpful.

Setup

Initially I connected the Raspberry Pi via HDMI to a TV; together with keyboard, mouse and an old USB Wifi adapter. Everything worked out of the box and I could install Raspbian and set up the network.

HDMI to VGA

Using an old VGA computer monitor via an adapter required changes to the file /boot/config.txt. You can find the parameters that match your monitor on Raspberry Pi StackExchange. In my case I had to set:
hdmi_group=2
hdmi_mode=35 # 1280x1024 @ 60Hz

Remote Access

But who needs a monitor when you can access the Pi remotely anyway? The command ifconfig tells me the local IP address of the Raspberry Pi.

With XQuartz on my Mac running I can connect to the Raspberry Pi via ssh with the X session forwarded:
ssh -X pi@your.ip.address.here
However, the performance is a bit sluggish and online comments suggest to use VNC instead. Nothing easier than that, install the VNC server on the Pi and use Screen Sharing on your Mac to access the Pi. Mitch Malone has a great post on this subject. Following the VNC setup on the Raspberry Pi I can type:
vnc://pi@your.ip.address.here:5901
into Safari and that will bring up the Screen Sharing App; see screen shot below.

AirPrint and AirPlay

Ok, let's give the Pi something to do: Rohan Kapoor explains how to set up the Raspberry Pi as a print server with AirPrint.

How about AirPlay as well? Follow Thorin Klosowski's steps on Lifehacker and you can stream music from your iOS devices to the Raspberry Pi's audio out.

Mathematica and R



Just before Christmas Stephen Wolfram announced that Mathematica would be made freely available for the Raspberry Pi. I had used Mathematica a little at university and was curious to see it on the Pi. Alex Newman posted the installation instructions on the Wolfram community site. It is as simple as:
sudo apt-get update && sudo apt-get install wolfram-engine
As a little toy example I run Paul Nylander's Mathematica code for a Feigenbaum diagram:

Surprisingly, it took about 3.5 minutes to run. Curious to find out if my old R routine would run faster I installed R on my Pi:
sudo apt-get install r-base
and adapted the code to match the parameters of the Mathematica routine (well, so I think):

The R code finished after about 10 seconds. Surely, there must be ways to speed up the Mathematica code that I have to investigate.

Fun with the Raspberry Pi

Since Christmas I have been playing around with a Raspberry Pi. It is certainly not the fastest computer, but what a great little toy! Here are a few experiences and online resources that I found helpful.

Setup

Initially I connected the Raspberry Pi via HDMI to a TV; together with keyboard, mouse and an old USB Wifi adapter. Everything worked out of the box and I could install Raspbian and set up the network.

HDMI to VGA

Using an old VGA computer monitor via an adapter required changes to the file /boot/config.txt. You can find the parameters that match your monitor on Raspberry Pi StackExchange. In my case I had to set:
hdmi_group=2
hdmi_mode=35 # 1280x1024 @ 60Hz

Remote Access

But who needs a monitor when you can access the Pi remotely anyway? The command ifconfig tells me the local IP address of the Raspberry Pi.

With XQuartz on my Mac running I can connect to the Raspberry Pi via ssh with the X session forwarded:
ssh -X pi@your.ip.address.here
However, the performance is a bit sluggish and online comments suggest to use VNC instead. Nothing easier than that, install the VNC server on the Pi and use Screen Sharing on your Mac to access the Pi. Mitch Malone has a great post on this subject. Following the VNC setup on the Raspberry Pi I can type:
vnc://pi@your.ip.address.here:5901
into Safari and that will bring up the Screen Sharing App; see screen shot below.

AirPrint and AirPlay

Ok, let's give the Pi something to do: Rohan Kapoor explains how to set up the Raspberry Pi as a print server with AirPrint.

How about AirPlay as well? Follow Thorin Klosowski's steps on Lifehacker and you can stream music from your iOS devices to the Raspberry Pi's audio out.

Mathematica and R



Just before Christmas Stephen Wolfram announced that Mathematica would be made freely available for the Raspberry Pi. I had used Mathematica a little at university and was curious to see it on the Pi. Alex Newman posted the installation instructions on the Wolfram community site. It is as simple as:
sudo apt-get update && sudo apt-get install wolfram-engine
As a little toy example I run Paul Nylander's Mathematica code for a Feigenbaum diagram:

Surprisingly, it took about 3.5 minutes to run. Curious to find out if my old R routine would run faster I installed R on my Pi:
sudo apt-get install r-base
and adapted the code to match the parameters of the Mathematica routine (well, so I think):

The R code finished after about 10 seconds. Surely, there must be ways to speed up the Mathematica code that I have to investigate.