Wiring Up

First wire up an LED, switch and a potentiometer. The table below shows what pins are available. The LED and switch can go on any GPIO (general purpose IO) pin. The pot goes on one of the AIN (analog in) pins.

P9P8

Wiring an LED

Take an LED and attach the long lead (anode) into pin P9_11. That is, pin 11 on the P9 (left) header. Put the short lead on a column on the breadboard. Put one end of the 270Ω resistor in the same column as the LED and the other end in pin P9_1 (GND).

Wiring a switch

Attach one end of the switch on P9_2 (GND) and the other on P9_13. If you don't have a switch, put one end of a wire in P9_2 and touch the other end to P9_13 when you want to turn it on.

Wiring a potentiometer

Attach the middle pin of the pot to P9_36 (AIN5). Place one of the outer pins to P9_32 (Vdd_ADC) which is a 3.3V analog reference. Place the other on pin P9_34 (GNDA_ADC) the analog ground.

IO via BoneScript

Writing a pin

Click on the digitalWrite() link on the left column under BoneScript Functions.

Click run and verify that the USR0 LED is on.

Edit the code and replace 'USR0' with 'P9_11' (the pin you wired the LED to).

Click run

Play around

Reading a pin

Click on the digitalRead() link on the left column under BoneScript Functions.

Edit the code and replace 'P8_19' with 'P9_13' (the pin you wired the switch to).

Click run. Push the switch and click run

Play around

Can you modify the code to read the switch and turn on the LED in response?

Reading analog

Click on the analogRead() link on the left column under BoneScript Functions.

Click run (you wired the pot to P9_36). Change the pot and click run again.

Play around

Linux Warm Up

Before we can interact with LEDs and switches we need to learn some simple Linux commands.

On your host computer, running Windows, start up puTTY.

If you get a Security Warning, click Run.

Enter 192.168.7.2 in the Host Name field and click Open

Login as root with no password.

Enter ls to list what files you have. You shouldn't see much.

At this point you need to learn a few simple Linux commands for creating and displaying files. Once you know these commands it's easy to turn an LED on and off.

First, let's edit a file using the nano editor. Nano is a simple editor that easy to learn. This will edit (and create) the file play.txt.

bone$ nano play.txt

Add a couple of lines of text to the file, it doesn't really matter what and then Exit. You can list the files in the current directory with ls and show the contents of a file with cat.

Blinking an LED

gpio via the Shell Command Line and sysfs

Another easy way to do general purpose I/O (gpio) on the Beagle is through a terminal window and a shell prompt. In Linux, almost everything is treated as a file, even things that aren't files. Here we'll use a virtual file system called sysfs. sysfs exposes the drivers for the hardware so you can easily use them.

Blinking an External LED via gpio

Earlier we wired an LED to the P9_12 General Purpose IO (gpio) port and controlled it via BoneScript. Here we'll control it via a shell command. First we need to figure out which gpio pin P9_12 is attached to. The following figure shows it attached to gpio_60.