# data[].attributes.attachment_link.title
Overview | Adafruit's Raspberry Pi Lesson 2. First Time Configuration | Adafruit Learning System

# data[].attributes.attachment_link.description
We do this using a tool called Raspi-Config that runs automatically the first time you boot your Raspberry Pi. This starts before the windowing system and so you have to use the cursor keys and Return key to navigate the menu system.

# data[].attributes.attachment_link.readable_text
People are doing a lot of cool things with the Raspberry Pi. One of the first things I thought to do was to see if I could make a Raspberry Pi web server. Being a web developer and overall geek I figured it might be kind of fun to do, and as I found out it's really easy.

My New Course: Hands on Internet of Things with the Raspberry Pi

I have just released my new course titled " Hands on Internet of Things" which is intended to be a course for people who want to get started with IoT. I'll take you through blinking lights and reading sensors to creating YOUR own IoT endpoint and dashboard. I'm offering this special coupon for readers of my site: get %50 off this course here. Thanks for being a reader!
Like my IoT projects? Sign up here to be added to my IoT newsletter

Getting Started

Setting up a Web Server on this device really isn't much different from any other Linux machine, but there are a couple things you'll want to do in order to get it working right.

The first thing you want to do is get the Raspian Wheezy Image from here. As you probably guessed this is a custom Debian image for the Pi. Once you install it and boot up, you'll come to a configuration screen that looks like this:

The Raspberry Pi has a "memory_split" option that divides the memory between the CPU and GPU (Graphics). Since we're using this a webserver we don't need that much GPU memory so change it to 16M:

You may want to also enable the SSH server if that's how you're going to be accessing the device. There are other options there you can adjust, including overclocking.

Note: You can overclock this device, but I wouldn't recommend it. With a web server setup like this you're not going to see any real gains, but you'll be reducing the life of the CPU and creating instability. It's not worth doing for this setup.

After you've saved your settings reboot the device. Now you'll want to update your firmware and software. The first thing you'll want to do is get Debian up to date:

Next we're going to do a firmware upgrade, we need to install git:

then download the firmware update and run it:

After the firmware update completes, you should see something like the following:

If you didn't see any errors, reboot the device.

Change the default password, especially if you're going to be connecting this to the internet:

Install the web server software

Now that everything is up to date we're ready to install the LAMP stack. This is really no different from any other Debian web server setup:

Install Apache and PHP:

Install MySQL:

Then make any changes you need to the Apache configuration and restart:

If you want to take a look at your PHP configuration, create the following file:

Inside that file put the following code:

Save it, and load it up in your browser, it should look something like this:

You're ready to go!

Summary

This isn't too much different from any other web server install with a few minor tweaks, and updating the device. But I thought I'd share it for those willing to try it out. This is for hacker fun only, I wouldn't recommend using this for any real commercial website but there's plenty you could do with this as a webserver just to experiment and play.

On the other hand I haven't really tested it thoroughly it might be a decent option for hosting smaller sites for all I know. It might be a fun experiment to set up one as a web server, one MySQL, one Varnish, etc. and throw some traffic at it. I'll be doing some other cool experiments with this device and documenting it here. I love hearing feedback so if you have any questions or comments send them my way!

My New Course: Hands on Internet of Things with the Raspberry Pi

Like my IoT projects? Sign up here to be added to my IoT newsletter

I have just released my new course titled " Hands on Internet of Things" which is intended to be a course for people who want to get started with IoT. I'll take you through blinking lights and reading sensors to creating YOUR own IoT endpoint and dashboard. I'm offering this special coupon for readers of my site: get %50 off this course here. Thanks for being a reader!

# data[].attributes.attachment_link.title
Tutorial: How to Set Up a Raspberry Pi Web Server

# data[].attributes.attachment_link.description
People are doing a lot of cool things with the Raspberry Pi. One of the first things I thought to do was to see if I could make a Raspberry Pi web server. Being a web developer and overall geek I figured it might be kind of fun to do, and as I found out it's really easy.

# data[].attributes.attachment_link.readable_text
What is the Raspberry Pi?

Initially, the Raspberry Pi was seeded out as an early developer release, with hopes of gaining early support from the development community. However, on the night of release, all distributor sites where slammed with a glut of requests. If you were lucky enough to nab one of the first units, odds are you were either amazed or utterly disappointed by what arrived in the mail.

If you were underwhelmed by the Pi, it might be that you got it for the wrong reasons. Let's be honest: the Pi is really an educational device, meant for hobbyists and aspiring youths out there to learn about programming. It's not meant to replace that powerhouse Linux desktop you built last summer with your savings.

Sporting a meager 256MB of RAM and a 700MHz ARM-11 processor, the Pi is a modest piece of kit. Keep in mind this chip's main purpose is to power a cheap computer with a basic level of functionality, mainly geared towards education. The Model B also sports two USB ports, HDMI out and a 10/100 Ethernet port. For your audio needs, you've got a 3.5mm audio jack and that HDMI output, which also supports audio transmission. The Raspberry Pi's GPU boasts 1 Gpixel/s, 1.5 Gtexel/s or 24 GFLOPs of general purpose compute power and is OpenGL 2.0 Compliant. In other words, it's got the graphics power of the original Xbox.

In this article we're going to take you through the setup steps to get your Raspberry Pi Model B up and running with Raspbian, the Debian-based Linux distro used here.

Getting your hands on one

To support the wonderful cause of the Raspberry Pi Foundation, we encourage you to grab yourself a $35 Model B Raspberry Pi from one of the distributors: Premier Farnell / element14 or RS Components.

You'll also need the following:
▪ One SD card
▪ An SD card reader so you can write the OS image to your SD card
▪ A means of supplying power to the unit (we use an old Android phone charger). At the very least, you'll need a 5v micro-USB adapter.
▪ An HDMI cable and HDMI-to-DVI converter if you're using a monitor instead of a high-definition television. If you're just using a TV or a monitor that supports HDMI, you won't need an adapter.
▪ A USB mouse and keyboard
▪ An Ethernet cable

Optional items:
* A case to hold your Raspberry Pi
* A USB Hub if you plan on using the USB ports for more than just a mouse and keyboard

What we're using, in case you're wondering:
▪ A Model B Raspberry Pi
▪ A 16GB Class 10 SanDisk Ultra SDHC card (rated at 300 MB/s)
▪ An old HTC Inspire power charger
▪ A wireless Logitech K260 keyboard and mouse combo. (It only uses one of the two available USB ports.)
▪ An RJ-45 cable

Setup

Once this awesome little device arrives at your door and you've gathered all the necessary gear it's time to get this Pi baked. Let's get started.
Installing the Raspbian image to an SD Card
Now that the Raspberry Pi has been out a while, there are quite a few methods for writing the Raspbian image to your SD card, regardless of whether you're using Windows, Mac OS X or Linux. For the purposes of this article, however, we'll stick to the more generic methods. Specifically, we'll be using the dd tool on OS X and Linux, and Win32DiskImager on Windows.
If you're using a Mac:
For simplicity's sake, we recommend you clear your Downloads folder before beginning. Then, grab the Raspbian .zip file from here. You want the latest direct download of Raspbian. You can also choose to obtain the .zip via torrent -- remember to be a good web citizen and seed for a while.

Once you've unzipped the folder containing the software image, you'll need the Terminal app. Assuming you're using OS X 10.7 or later, you can launch it from Applications, and then either click Utilities (in 10.7) or Other (in 10.8). Once the Terminal App is up and running, navigate over to your Downloads folder via the command "cd ~/Downloads":

You should now have at least two items in your Downloads folder. Verify that there's an ".img" file as well as a ".zip" file by typing "ls".

Now let's focus on getting that extracted image file onto the SD card and no, you can't just drag and drop it onto the drive. First, we need your device layout before we insert the card. So if you jumped the gun and put your card in your Mac, take a moment to remove it safely.

In the Terminal App, type: "df -h". You should see some output like this:

Now insert your SD card and run the above command again, and note the new "/dev/disk1s1" line. Keep this handy -- you'll need to convert this to a raw disk name.

Next we need to unmount that volume so the "dd" tool will be able to write the image to the SD card. Do this via the command "sudo diskutil unmount /dev/disk1s1". You'll get prompted for your system password, so enter that when asked.

You should now see the last line "Volume XXX unmounted" with "XXX" being the name of your card. Now, without further ado, we can finally write the Raspbian .img file to the SD.

Remember that part where we told you to keep the disk name of your card handy? Now's the time for the conversion. Whatever your disk was named (e.g., /dev/disk1s1), remove the "s1" and add "r" in front of "disk" so that "/dev/disk1s1" becomes "/dev/rdisk1".

So, for instance, "/dev/disk1s1" = "/dev/rdisk1". Make sense?

Then type the following: "sudo dd bs=1m if=2012-06-15-wheezy-raspbian.img of=/dev/YOURDISKNAME". Replace with your actual raw disk name -- more than likely this will be /dev/rdisk1.

If you're using Linux
This will take a moment to complete. Once the "dd" command is done, safely unmount your SD card by dragging the disk image now showing on your desktop to the Trash bin.

Our prep work is finished! Skip ahead to "Booting your Pi for the first time."

Whichever Linux distribution you're using, ensure you have the "dd" tool which you should have installed by default, regardless of the distro.

Some assumptions we're making here:

1) You have sudo configured and are familiar with it.
2) You have fdisk installed (installed by default on most Linux distros).

We tested this on Ubuntu since it's such a popular distro, and both of these are indeed present by default.

Start out by downloading the Raspbian .zip to your home directory from this location. Again, you want the latest direct download of Raspbian. Here, too, consider seeding the torrent for karma's sake. Once you've downloaded the .zip file containing the Raspbian image, you'll naturally want to unzip it.

Fire up a terminal on your Linux box and cd to your home directory via the "cd ~" command. Type "unzip imagename.zip", replacing "imagename" with the actual image you just downloaded (obviously).

Notice the devices listed; more than likely you'll see something like this.
Next we need to determine the device name your SD card currently is using. Insert your SD Card and type "sudo fdisk -l".
If you're using Windows

Our device is "sdb," the one with 15.9GB of space. (Obviously, it's not our main 250GB hard drive.) Make note of the devices listed under "/dev/sdb", as you'll want to unmount them prior to writing the image for safety. In our case we see "/dev/sdb1" and "/dev/sdb2", so we'll run:

sudo umount /dev/sdb1
sudo umount /dev/sdb2

Now let's write our image with "dd". Type "sudo dd bs=1M if=2012-08-16-wheezy-raspbian.img of=/dev/sdb". As we warned in the Mac how-to above, this will take a few minutes to complete.

If you see a successful write as illustrated above, move on to "Booting your Pi for the first time."

If you've got a Windows system there's a nice little application called Win32DiskImager, which you can download here or here. Once you've done that, grab the Raspbian image from here. Choose the latest direct download of Raspbian.

Once you've downloaded both Win32DiskImager and the Raspbian image, we'll need to unzip them. To keep things simple, extract everything to the desktop, or a folder located there, in easy reach. Unzip both win32diskimager-binary.zip and 2012-08-16-wheezy-raspbian.zip.

Then insert your SD card into your reader. Make note of the drive letter. After unzipping those files and connecting your card, double-click the Win32DiskImager binary to load the program.

As soon as Win32DiskImager loads, you'll see an error (in Windows 7, anyway).

We found this safe to ignore. Click OK and the Application will load.

Click the blue folder icon in Win32 Disk Imager and select your Raspbian image file, and ensure the Device listed is the same drive letter as your SD Card.

Once you open your image, click "Write", click "Yes" to confirm the write and go grab a cup of coffee.

When the writing has completed, you'll get this message, at which point it's safe to eject your SD card.

If you happen to get stuck writing the image to your card, we recommend you head to the excellent beginners wiki found here.

Booting your Pi for the first time

The first time you boot the Raspberry Pi you'll see a configuration tool called "raspi-config." (If you ever need to revisit this configuration screen again, you can always call the "raspi-config" command from the terminal of your Pi.) While you're there, you'll need to change a few options.

First off, we need to select "expand_rootfs". What this does is expand the installed image to use the maximum available size of your SD card. If you are using a larger card (16GB, say), you'll definitely want to make sure you can use the full capacity, since the install image is only about 2GB.

Highlight that "expand_rootfs" option and press Enter. You'll then see the confirmation below, at which point pressing Enter will take you back to the main raspi-config screen.

Next up is the overscan option. If you notice, the screen is not taking up the entire real estate afforded by your monitor; it's best to disable overscan so that you can utilize your monitor or television to its entirety. If your screen looks fine, though, you can skip this step. In any case, assuming you do go through with this step, select "overscan" and press Enter.

Here you get the option to disable or enable. If you ever upgrade to a new monitor or television you may need to re-enable overscan at a later point.

After that quick step, now we want to verify our keyboard settings. If you are in America you want to change this; if you're in Great Britain these are safe to leave at the standard config.

Select "configure_keyboard" and press Enter. Then you'll be presented with a very long list of keyboard options. If you know your keyboard setup, select it in the list, otherwise you'll be fine with the default 105-key option.

After selecting your keyboard type, you'll need to specify the layout. There's a good chance you want a different layout than English (UK), so choose "Other" and select the most appropriate option.

You'll then be asked about modifier keys -- just choose the default here, as well as "No compose key" on the next screen. If later you find you need a compose key to create alternative characters, you can return to this configuration screen by running "raspi-config".

The last option you'll need to set in the Keyboard configuration is the ALT / CTRL / BACKSPACE feature to kill X11. We recommend you enable this, so that in case your GUI ever crashes you can safely kill it without rebooting.

Back at the main menu, the next step is to set a user password.

Select "change_pass" and press Enter. After a confirmation screen, you'll be prompted to choose a new UNIX user password.

Almost done now. Let's set your "locale," which is the general character set used by your native language. Again, if you don't live in Great Britain, you'll want to change this to your local character set. If you're in the good ol' US of A, you want en_US.UTF-8. Scroll down to your locale of choice, and de-select the en_GB option on your way. In our case, we'll be enabling en_US.UTF-8

The next dialogue window will ask you to choose a default locale, select the locale you just chose on the previous screen and press Enter.

Back on raspi-config's main menu, set the appropriate timezone by selecting -- you guessed it -- the "change_timezone" option. You'll be presented with a list of regions first.

The next dialogue will show you a list of zones within that region. We think you know what to do here.

Back at the main setup, you can safely ignore the remaining options for now and select "Finish." You'll be prompted to reboot to make changes; do so. Once your system is back online, you'll get a login prompt like so:

Your login is "pi" and the password will be what you set it to earlier.

Using your Raspberry Pi
Writing your first program on the Raspberry Pi
Now that you've logged in to your freshly baked Raspberry Pi, the first thing you want to do is type "startx" to get your GUI environment loaded, which from here on out we'll refer to as your Window Manager.

After a quick screen flicker you should end up with this (minus the terminal window):

Welcome to the LXDE Window Manager. LXDE is a very lightweight, full-featured UI that runs pretty well on the Raspberry Pi. If you've never used LXDE before, it drives very similar to Windows. If you click the lower left icon, you'll see an application list. It works exactly how you'd expect it to.

Now what?

After you've got your Pi powered and the LXDE WM up and running, you essentially have a full-fledged Linux box running Debian. At this point you can browse the web with Midori, setup a webserver, or do general computing tasks.

But first, let's talk about some utilities that are focused around what the Raspberry Pi is all about: education. Specifically, software development education.

Raspbian comes preloaded with Python, the official programming language of the Raspberry Pi and IDLE 3, a Python Integrated Development Environment. We're going to show you now how to get started with IDLE and write your very first, albeit simple, Python program.

When learning a new language, it's very common to create the classic "Hello World!" program, which is what we're going to show you how to do, but with a small twist. This Python program will ask for your name and introduce itself to you.

First, load up IDLE 3 by double-clicking the icon on your LXDE desktop.

Click File > New Window, which will then bring up a new blank window which you can type in.

Then, type the following in your new window:

#my first Python program
username = input("Hello, I'm Raspberry Pi! What is your name? ")
print ('Nice to meet you, ' + username + ' have a nice day!')

Now click File > Save As and in the new dialogue window that pops up, call your file "hello" and click "Save".

Let's run that program you just wrote!

Click Run > Run Module or simply press F5.

When you get prompted "Hello, I'm Raspberry Pi! What is your name?" in the IDLE 3 window, type your name and press Enter. You'll see the Raspberry Pi responds. Et voila! Not much else to it.

Wrap-up

Your first Raspberry Pi program is, quite frankly, a very trivial start. Many more powerful applications can be written using the Python programming language. From here we recommend you take the Python tutorial over on the official Python site. If a seven-year-old can write a game on the Pi, surely you can.

When you get tired of learning Python, you may want to relax and kick back with some retro gaming. You can configure your Pi to act as a MAME Arcade Emulator and connect it to your television, as shown here. Then, once your thumbs get sore, why not head over here and install XBMC? Since the Pi is capable of playing full 1080p video, it can act as a fairly decent media center once connected to an HD television.

Of course, if you just want a cheap $35 Linux machine, the Raspberry Pi works great for that too. You'll find it's truly a joy to use -- a hacker's dream device with enormous possibilities. We expect to see a lot more applications for the Pi in the coming months, especially now that the Gertboard has been announced. Hopefully this article will inspire you to pick up one up and give it a try.

# data[].attributes.attachment_link.description
What is the Raspberry Pi? Initially, the Raspberry Pi was seeded out as an early developer release, with hopes of gaining early support from the development community. However, on the night of release, all distributor sites where slammed with a glut of requests.

# data[].attributes.headline
Tutorial: How to use your Raspberry Pi like an Arduino

# data[].attributes.subject
Tutorial: How to use your Raspberry Pi like an Arduino

# data[].attributes.attachment_link.readable_text
Finally got to experiment with the Raspberry Pi's GPIO (General Purpose Input/Output) pins. I tried three methods: Python, Bash and C, and will describe each. But first, here's some setup information.

Connecting to the RPi's GPIO header: I used an old floppy disk drive IDE ribbon cable. It has 34 pins, but the RPi's header is only 26 pins, so part of the connector is unused. I soldered some breadboard-friendly header pins onto the other end, which is working pretty well so far. Bear in mind that some IDE cables may be more complicated than they look. Before powering anything up, make sure you check that each conductor is indeed separate and you're not accidentally grounding or shorting anything. You can always make your own by getting some 26-conductor IDC connectors and using a vice to crimp it onto a piece of ribbon cable.

Pin Connections: ...are confusing! There's a master table here, and a diagram here. Looking at the diagram, my breakout header starts with 3.3V and moves left to right, top to bottom. Here are the pin connections from my header as pictured:

Pin 2: 5V

Pin 3: "GPIO0". Connected to one end of the switch (the other end is connected to ground, since this GPIO pin has an internal pull-up resistor. This means that when the switch is not closed, the pin reads as "High," and when closed, "Low."

Pin 6: GND (note that it's jumpered to my ground rail on my breakout board)

Pin 7: "GPIO4". The anode of the LED through a 220-ohm resistor.

I'll use this breakout board setup for all the following examples. Different libraries/tools use different pin numbers, adding to the confusion, so I'll try to clear it up. Also note that I'm doing this through an SSH session, so there's no monitor attached to the RPi. See my beginning instructions here if you don't already have an SSH connection to your Pi.

Important Note: The RPi Wiki takes pains to remind you that these GPIO pins are unbuffered and unprotected, so if you short something out, you could fry your whole Pi, so be careful! There are a number of other breakout boards being developed that should make this safer.

Important Note: Any program that accesses the GPIO pins must be run as root, so if you get an error, remember to "sudo" your command.

Python: One of my preferred languages, so I figured I'd try it out. First, install pip (Python package installer):

sudo curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python

Next, install the RPi.GPIO Python module:

sudo pip install rpi.gpio

Now, you can enter the python interpreter (sudo python) and do stuff like:

import RPi.GPIO as GPIO
GPIO.setup(7, GPIO.OUT)
GPIO.output(7, True)
GPIO.output(7,False)

Bash: Something I've always loved about Unix is the idea that everything is a file. On the Raspberry Pi, the GPIO pins are files too! With the pictured breadboard setup, we can do the following to turn the LED on and off (note that this uses the "BCM" pin numbering but the breadboard stays the same!):

(You can't just put sudo before each command because the second command that the output is directed to would not be run as root. So, for simplicity, we drop into root first.)
sudo su -
echo "4" > /sys/class/gpio/export
echo "4" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio4/direction
echo "1" > /sys/class/gpio/gpio4/value
echo "0" > /sys/class/gpio/gpio4/value

To read from an input, 'cat' it like any other file!
echo "0" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio0/direction
cat /sys/class/gpio/gpio0/value

C: Good old C. The native example for C is really hairy, but luckily a plucky fellow named Gordon wrote an Arduino-like library just for the Raspberry Pi! Here's what you need to do:

Where's my analogRead? Sadly, unlike an Arduino, the RPi doesn't have an onboard ADC (Analog to Digital Converter). However, some of the breakout boards being designed will include an external ADC, such as the Gertboard. You can add your own external ADC, such as this one, by using the SPI bus on the RPi (the MOSI, MISO and SCK pins).

That's all for now! Hope this helps, and as always, let me know if it works or you run into any problems.

Related Posts:

# data[].attributes.attachment_link.title
Tutorial: How to use your Raspberry Pi like an Arduino

# data[].attributes.attachment_link.description
Finally got to experiment with the Raspberry Pi's GPIO (General Purpose Input/Output) pins. I tried three methods: Python, Bash and C, and will describe each. But first, here's some setup information. Connecting to the RPi's GPIO header: I used an old floppy disk drive IDE ribbon cable.

# data[].attributes.headline
Invent your own computer games with Python

# data[].attributes.subject
Invent your own computer games with Python

# data[].attributes.headline
Video Intro to Raspberry Pi by lifeHacker

# data[].attributes.subject
Video Intro to Raspberry Pi by lifeHacker

# data[].attributes.attachment_link.readable_text
The Raspberry Pi is a wonderful little computer that fits in the palm of your hand, yet packs enough power to run your home media center, a VPN, and a lot more. Before you can do anything awesome, however, you need to configure it and install an operating system. Here's how.

Update: We've created a new, always-up-to-date guide for setting up your Raspberry Pi that includes all the newest information, check that post out instead.
It's Raspberry Pi week at Lifehacker, and for the next five days we'll be showing you some cool DIY projects you can put together with this little miracle of a device. If you haven't bought one yet, check out the first section below to learn more about what it is, what you'll need, and the cool stuff you can do with one.
Update: Raspberry Pi week is over! Check out these Raspberry Pi guides to see all the fun stuff we did, and check out our Raspberry Pi tag for more cool projects.

This past week, we walked you through some of the common projects people tackle with their Raspberry Pi, like:

What's a Raspberry Pi?

The Raspberry Pi is a very capable mini computer that's small enough to fit in your pocket (even though you'd probably never keep it there). For about $35-40, you get a caseless computer with HDMI and analog composite video output. You can add up to two USB devices (which, in most cases, will be a mouse and keyboard) and connect it to the internet via wired ethernet. The Raspberry Pi is powerful and inexpensive, allowing you to create a home media center, internet radio, or even your own VPN server on the cheap. That said, a little setup and a lot of other parts are required to get it up and running. In this post we'll take a look at how to get a Raspberry Pi set up so you can start using it for a variety of purposes.

What You'll Need

The Raspberry Pi may be a computer all on its own, but you'll still need a lot of other things to make it work:

A Raspberry Pi: If you're not sure where to buy one, you'll find links below to help you out.

An HDMI- or composite video-capable television or monitor: In this post we'll be working with an HDMI-capable monitor because it offers better resolution and built-in sound. You can use analog if you want, however.

An HDMI or composite video cable: You'll need this cable to connect your Raspberry Pi to your television or monitor.

A 4GB Class 4 SD card (or better) and a card reader (if you don't have one built into your computer): Most SD cards will work, but some aren't compatible and will therefore cause issues. You can find out which cards are compatible, or locate a place to buy a compatible card with an operating system pre-installed, on this page.

A USB keyboard and mouse: Any standard USB keyboard or mouse will do. Wireless (non-Bluetooth) peripherals worked for me, but I had to unplug them and plug them back in after the Raspberry Pi booted. You'll have fewer issues with fully wired keyboards and mice.

An ethernet cable: Any standard ethernet cable will do. You only need this to connect to your network and the internet, however, so you can leave this item out if desired.

A good quality, micro USB power supply that can provide at least
700mA at 5V: Most modern smartphone chargers supply 700mA at 5V, but not all do. Check the bottom of your charger and look for a block of text. You'll see its output values in that text which may read 0.7A instead of 700mA). If it offers at least that much power, you're probably good to go. Just don't use a poor quality charger or you may run into problems.

A 3.5mm stereo audio cable: You only need this if you're using analog video and want to connect your Raspberry Pi to a set of external speakers or internal ones on your television or monitor.

You can find the majority of those items pretty much anywhere, but Raspberry Pi units are difficult to come by due to popular demand. Here are a few places to try that often have a few in stock:

Once you've got your Raspberry Pi, you can start setting it up!

How to Set Up Your Raspberry Pi with a Basic Operating System

You can use the Raspberry Pi for all sorts of different things-some of which may require their own special operating systems-but to start out, it's a good idea to get acquainted with the Pi by installing Raspbian, a Raspberry Pi-focused version of Linux. Here's what you need to do.

Step One: Prepare Your SD Card

First things first, we need to prepare your SD card for the Raspberry Pi. This involves formatting it properly and putting Raspbian, the standard Raspberry Pi operating system, on it. The steps vary depending on whether or not you're on a Mac, Linux, or Windows PC, so just follow the instructions for your operating system below.

Windows

1. Download the lastest version of Raspbian and unzip the .img file inside. (It's almost 500MB so it may take a little while to download.)

2. Download Win32DiskImager and unzip the application (.exe file) inside.

3. Insert your SD card into your Windows PC using a card reader.

4. Open Win32DiskImager.exe, the application you just downloaded, by double-clicking on it. If you're running Windows 7 or 8, right click on it and choose "Run as Administrator" instead.

5. If your SD card isn't automatically detected by the application, click on the drop-down menu at the top right (labeled "Device") and choose it from the list.

6. In the image file section of the application, click the little folder icon and choose the Raspbian .img file you just downloaded.

7. Click the Write button and wait for Win32DiskImager to do its thing. When it finishes, you can safely eject your SD card and insert it into your Raspberry Pi.

OS X

1. Download the lastest version of Raspbian and unzip the .img file inside. (It's almost 500MB so it may take a little while to download.)

2. Download RPi-sd card builder (be sure to pick the appropriate version for your installed version of OS X) and unzip the application.

3. Insert your SD card into your Mac using a card reader.

4. Open RPi-sd card builder. You'll immediately be asked to choose a Raspbian image. Choose the .img file you downloaded earlier.

5. You'll be asked if your SD card is connected. Since we inserted it earlier, it is, so go ahead and click Continue. You'll be presented with SD card options. If you only have one inserted, you won't see anything else in the list and it'll be checked. If not, just check only the card you want to use and click OK.

6. Enter your administrator password and click OK.

7. You'll be asked if the SD card was ejected. This is supposed to happen, as the application needs to unmount it so it can perform a direct copy. Double-check that your SD card is no longer available in the Finder. DO NOT remove it from your USB port. When you're sure, click Continue.

8. RPi-sd card builder finishes prepping your SD card, safely eject it and insert it into your Raspberry Pi unit.

RPi-sd card builder isn't an app so much as it's an Automator action that acts like one. Some people have reported issues using it, so if you run into problems just open up the Terminal app (Your Hard Drive → Applications → Utilities → Terminal) and follow the instructions for Linux.

Linux

1. Download the lastest version of Raspbian and unzip the .img file inside. (It's almost 500MB so it may take a little while to download.)

2. Open up your Linux terminal emulator of choice. If you don't have one, try our favorite.

3. Insert your SD card. If it mounts automatically, unmount it but make note of its location (e.g. /dev/disk2s1). Even though the card is unmounted, do not remove it from the reader

4. In the command line, you're going to need to type a single line to copy the contents of the Raspbian .img file to your SD card. It'll look like this: sudo dd if=PATH_TO_IMG_FILE of=PATH_TO_SD_CARD_MOUNT_POINT bs=1m You'll need to replace PATH_TO_IMG_FILE with the path to the .img file and PATH_TO_SD_CARD_MOUNT_POINT with the path to the SD card mount point. (The bs=1m just specifies the byte size and you don't need to mess with it.) When you're done, the command should look something like this: sudo dd if=/Users/adachis/Downloads/2012-12-16-wheezy-raspbian.img of=/dev/disk2s1 bs=1m It's very important that you do not get this information wrong or you could end up writing Raspbian to the wrong disk and cause serious data loss. Be careful! When you're sure you've got everything right, press enter.

5. You will be prompted for the root password (or your administrator password for those of you on OS X who are using this method). Type it and press enter.

6. It'll take some time for the dd command to copy everything over to your SD card. While that happens, it'll probably look like the Terminal froze up. Don't worry, it's still working and will likely take longer than an average 2GB copy to an SD card (so be patient). When it finishes, the command prompt will return and your SD card will be ready. Eject it safely and stick it in your Raspberry Pi.

Step Two: Hook Up Your Raspberry Pi

Connecting everything to your Raspberry Pi is pretty easy. Start by connecting the HDMI cable from the unit to your television (or monitor). If you're using the analog composite video connection instead, connect it to your television (or monitor) and plug in a set of speakers to the 3.5mm audio jack. If you want your Raspberry Pi to connect to your network and/or the internet, use an Ethernet cable to connect it to your router. If you've set up a computer before, this should all seem familiar.

Finally, you need to connect your Raspberry Pi with a micro USB power adapter. As mentioned earlier, you need an adapter that can provide at least 700mA at 5V. Fortunately, you probably already have one. Many smartphone and tablet chargers utilize micro USB and provide 700mA at 5V (or more). You can find out by reading the small text on the plug and looking for the output section. (Note: it may say 0.7A (or higher) instead of 700mA.) When you have a compatible power adapter on hand, connect it to a micro USB cable and then connect that cable to the micro USB port on your Raspberry Pi unit. It'll turn on all by itself and you should see it boot for the first time.

Step Three: Configure Your Raspberry Pi

Once your Raspberry Pi boots for the first time you'll need to configure a few things. You'll know it's ready for you when you see a Raspi-config window with a pretty big list of settings. You can mess with the others if you feel so inclined, but the only thing you really need to do is expand the file system so you can use up all the space on your SD card. To do so, follow these steps:

1. Select expand_rootfs (the second option) and press enter.

2. Confirm that you want to expand the file system and let Raspbian do its thing.

3. When you're returned to the configuration list, go all the way to the bottom and select the Finish option.

4. It'll ask you if you want to reboot. Choose yes.

Your Raspberry Pi will reboot and take a little longer this time because it needs to expand the file system. After a about a minute you'll be asked to log in. You'll need to use the default username and password:

Once you've logged in, you've got yourself a working Raspberry Pi. Congratulations!

Of course, this is far from the end. You can use your Pi as much more than just a tiny computer, so check out Lifehacker all week at 8:00 AM PT for how-tos on some of the coolest things you can do with it. Tomorrow we'll show you how to turn that tiny little board into a killer XBMC media center.

Photos by Denise Kappa (Shutterstock), maymak (Shutterstock), Pakhnyushcha (Shutterstock), and Anan Kaewkhammul (Shutterstock), and me.

# data[].attributes.attachment_link.title
A Beginner's Guide to DIYing with the Raspberry Pi

# data[].attributes.attachment_link.description
The Raspberry Pi is a wonderful little computer that fits in the palm of your hand, yet packs enough power to run your home media center, a VPN, and a lot more. Before you can do anything awesome, however, you need to configure it and install an operating system. Here's how.

# data[].attributes.attachment_link.description
An introduction to the Raspberry PI computer. More information and a video of the accompanying lecture by Professor Alan Mycroft from the Raspberry Pi foundati...

# data[].attributes.attachment_link.description
PYPORTAL EMAIL DISPLAY WITH ZAPIER AND ADAFRUIT IO

# data[].attributes.headline
How To Control and Use GPIO Pins on Raspberry Pi?

# data[].attributes.subject
How To Control and Use GPIO Pins on Raspberry Pi?

# data[].attributes.attachment_link.readable_text
A great feature on the Raspberry Pi is the GPIO pins (stands for General Purpose Input Output). These GPIO pins on Raspberry Pi can be found in 2×13 header pins which can perform tasks include SPI, I2C, serial UART, 3V3 and 5V power.

There are eight of these pins can be used directly for digital output and input (Hight and Low). These pins can be set high by connecting it to a voltage supply, or set low by connecting it to ground.

So you can control electronics devices such as LEDs, Motor Driver and so on using these GPIO pins. Input devices like push buttons and toggle switches can also be used to control the Raspberry Pi.

How To Control and Use GPIO Pins on Raspberry Pi?

This includes two steps, software on the Pi, and how to connect the hardware.

Install RPi.GPIO Python Library

The RPi.GPIO Python Library probably have come pre-installed on your Raspbian OS, to verify this, fire up Python:

sudo python

and type in this line

import RPi.GPIO as GPIO

If you don't get any error, you are should be fine. If you do get an error, then do the following to install the library.

To install it launch a command line (i.e. LXTerminal) and enter the following commands :

1. Download the RPi GPIO Library
wget http://pypi.python.org/packages/source/R/RPi.GPIO/RPi.GPIO-0.3.1a.tar.gz

2. Extract the files
tar zxf RPi.GPIO-0.3.1a.tar.gz

3. Browse to the extracted folder
cd RPi.GPIO-0.3.1a

4. Install the library
 sudo python setup.py install

The Library should be ready now.

Usage of the Python RPi.GPIO Library

[sourcecode language="python"]

# import library

import RPi.GPIO as GPIO

# to use Raspberry Pi board pin numbers

GPIO.setmode(GPIO.BOARD) # or GPIO.setmode(GPIO.BCM)

# set up the GPIO Pins - for input or output

GPIO.setup(11, GPIO.IN)

GPIO.setup(13, GPIO.OUT)

# taking input value from Pin 11
input_value = GPIO.input(11)

# setting output value to Pin 13
GPIO.output(13, GPIO.HIGH)

#GPIO.output(13, GPIO.LOW)

[/sourcecode]

The difference between GPIO.setmode(GPIO.BOARD) and GPIO.setmode(GPIO.BCM) is the pin numbering system. BOARD signifies using the physical pin numbers on the Raspberry Pi P1 connector. BCM signifies the Broadcom SOC channel designation. However you should know the BCM channels changed a little between revision 1 and revision 2 of the Raspberry Pi board, and the BOARD numbering system stays working between board revisions.

Connection of GPIO Pins On Raspberry Pi and LEDs/buttons

There are 8 available GPIO Pins on Raspberry Pi.

See connection shown in the diagram.

Resistors value can be caculated as this. My 5mm LED's forward current is around 20mA (might be different to yours), voltage supply from RPi is 3.3V, so the resistor for LED is 3.3 V / 20 mA = 165 omh. For the push buttons, I used 1K ohm resistors.

Source Code

[sourcecode language="python"]
from time import sleep
import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BOARD)

GPIO.setup(16, GPIO.IN)
GPIO.setup(18, GPIO.IN)

# state - decides what LED should be on and off
state = 0

# increment - the direction of states
inc = 1

while True:

# state toggle button is pressed
if ( GPIO.input(16) == True ):

if (state == 1):
GPIO.output(11, GPIO.HIGH)
GPIO.output(13, GPIO.LOW)
GPIO.output(15, GPIO.LOW)
elif (state == 2):
GPIO.output(11, GPIO.HIGH)
GPIO.output(13, GPIO.HIGH)
GPIO.output(15, GPIO.LOW)
elif (state == 3):
GPIO.output(11, GPIO.HIGH)
GPIO.output(13, GPIO.HIGH)
GPIO.output(15, GPIO.HIGH)
else:
GPIO.output(11, GPIO.LOW)
GPIO.output(13, GPIO.LOW)
GPIO.output(15, GPIO.LOW)
print("pressed B1 ", state)

# reset button is pressed
if ( GPIO.input(18) == True ):

state = 0
inc = 1
GPIO.output(11, GPIO.LOW)
GPIO.output(13, GPIO.LOW)
GPIO.output(15, GPIO.LOW)

print("pressed B2 ", state)

sleep(0.2);
[/sourcecode]

Although the Raspberry Pi has much more powerful computational capacity than the Arduino, it's shortage in digital pins and analogue pins is still a disadvantage for many DIY, electronics hobbyists. However there are possibilities in expanding the number of digital pins and adding analogue pins. I might do some projects around these area in the near future.

# data[].attributes.attachment_link.title
How To Use GPIO Pins On Raspberry Pi - Buttons And LED Tutorial - Oscar Liang

# data[].attributes.attachment_link.description
A great feature on the Raspberry Pi is the GPIO pins (stands for General Purpose Input Output). These GPIO pins on Raspberry Pi can be found in 2×13 header pins which can perform tasks include SPI, I2C, serial UART, 3V3 and 5V power.

# data[].attributes.headline
How to set up a webserver on your raspberry pi

# data[].attributes.subject
How to set up a webserver on your raspberry pi

# data[].attributes.attachment_link.readable_text
This page aims to summarise the steps required to install a webserver with PHP support onto your Raspberry Pi. This will allow the Pi to server HTML and PHP pages to users on the same network. This is a useful mechanism to view images and/or data on the Pi from another device, whether that is a PC, laptop, tablet or mobile phone.

Note : Before experimenting with network enabled features you should really make sure you have changed your Pi password from the "raspberry" default.

Step 1 - Install Lighttpd

Lighttpd is a lightweight web server application that works well on the Pi. It can be installed using the following commands :

sudo apt-get update
sudo apt-get -y install lighttpd

Step 2 - Install PHP

Next we need to install PHP. The order in which php5-common, php5-cgi and php5 are installed is important so don't change their ordering in the line below :

sudo apt-get -y install php5-common php5-cgi php5

Then enable the Fastcgi module which will handle the PHP pages :

sudo lighty-enable-mod fastcgi-php

Once these packages are installed we can restart the Lighttpd service to pick up the changes :

sudo service lighttpd force-reload

Step 3 - Testing

In order to test your new webserver you need to know the IP address your Pi has on your network. To do this run this command :

sudo ip addr show

You will see a block of information similar to this :

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast
    state UP qlen 1000
    link/ether b1:11:ab:42:24:2c brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.45/24 brd 192.168.0.255 scope global eth0

The IP address in this example is 192.168.0.45. Take this IP address and enter it into the address bar of a web browser on another device.

If everything has worked you should see the default Lighttpd "Placeholder" web page. It's not very exciting but it is easy to replace with your own page.

Step 4 - Tweak Permissions

Now we will adjust some permissions to ensure the "Pi" user account can write files to the location where Lighttpd expects to find web pages. The /var/www directory is currently owned by the "root" user. So let's make the "www-data" user and group the owner of the /var/www directory.

sudo chown www-data:www-data /var/www

Now we will allow the "www-data" group permission to write to this directory.

sudo chmod 775 /var/www

Finally we can add the "Pi" user to the "www-data" group.

sudo usermod -a -G www-data pi

For these permissions to take effect it is best to reboot your Pi at this point using :

sudo reboot

Step 5 - Replace the placeholder page

Let's browse to the /var/www/html directory and rename this default page :

cd /var/www/html
sudo mv index.lighttpd.html index.lighttpd.hxxx

Now we can replace it with a new php page :

sudo wget https://www.raspberrypi-spy.co.uk/archive/misc/lighttpd_test.php.txt -O /var/www/html/index.php

The command above grabs a text file from this website, renames it as "index.php" and saves it to the /var/www/html directory. If you want to look at the test page first click here.

Note : The '-O' in the command is a capital letter O (O for Orange) not a zero or lowercase o.

Refresh your browser and you should see the new page. If PHP is working OK you will see a summary of your PHP configuration.

You are now ready to populate /var/www with HTML, CSS, JS, PHP and image files just as you would for a normal website. These files could be created by your own programs which gives your projects and experiments a way to publish their data to other devices.

This is yet another great way for other devices to interact with your Pi.

If you want your Pi web server to be available on the internet (i.e. beyond your own network) you will need to follow some additional steps. I'm not covering them here but they usually involve "port forwarding" on your router to enable pages to be requested from your Pi by an external visitor.

Optional Steps

By default web servers communicate over port 80. If you want to change the port number that Lighttpd uses you can easily change it by editing the lighttpd.conf file :

sudo nano /etc/lighttpd/lighttpd.conf

then change the "server port" line to define your chosen port number :

server.port  = 40045

Exit nano using CTRL-X followed by Y. To restart the server and get it to pick up this change use :

sudo /etc/init.d/lighttpd restart

You can now access your web server on another device on your network using :

192.168.0.45:40045

Recommended Book

If you fancy reading a lot more about Lighttpd in a printed book then take a look at "Lighttpd" by Andre Bogus.

This is also available as a Kindle version as well if you prefer your reference material e-book style.

# data[].attributes.attachment_link.title
How To Setup A Web Server On Your Raspberry Pi - Raspberry Pi Spy

# data[].attributes.attachment_link.description
This page aims to summarise the steps required to install a webserver with PHP support onto your Raspberry Pi. This will allow the Pi to server HTML and PHP pages to users on the same network. This is a useful mechanism to view images and/or data on the Pi from another device, whether that is a PC, laptop, tablet or mobile phone.

# data[].attributes.attachment_link.title
SSH under Windows | Adafruit's Raspberry Pi Lesson 6. Using SSH | Adafruit Learning System

# data[].attributes.attachment_link.description
Learn how to remote control your Raspberry Pi using SSH

# data[].attributes.headline
Another set of instructions to set up a webserver on your Pi

# data[].attributes.subject
Another set of instructions to set up a webserver on your Pi

# data[].attributes.attachment_link.title
How2Setup a web server with php support on your Raspberry Pi - Simon The Pi Man

# data[].attributes.attachment_link.description
How2Setup a web server with php support on your Raspberry Pi - Simon the Pi Man(Resource for the Raspberry Pi computer)