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.

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_11 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_30.