Open Source Hardware

From BC Wiki
Jump to: navigation, search


The Making of Arduino

I highly recommend introducing sensors as early as possible: CdS photocells and NTC thermistors are cheap and durable and provide instant access to light and temperature.

Don't forget LEDs and breadboards  :D

Everywhere also has their own version of an Arduino Starter Kit.

Useful Shields[edit]

Arduino Motor Shield v2

Arduino Stacking Headers

Arduino-Compatible Headers, non-stacking

Light Sensing and Simple Control[edit]

This sketch uses a photodiode and a resistor to measure ambient light intensity. The intensity is recorded onto an SD card using an Ethernet Shield. The LED on Arduino also blinks at a rate proportional to the light intensity.

#include <SD.h>

  Analog Input
 Demonstrates analog input by reading an analog sensor on analog pin 0 and
 turning on and off a light emitting diode(LED)  connected to digital pin 13. 
 The amount of time the LED will be on and off depends on
 the value obtained by analogRead(). 
 The circuit:
 * Ethernet Shield with SD card
 * Potentiometer attached to analog input 0
 * center pin of the potentiometer to the analog pin
 * one side pin (either one) to ground
 * the other side pin to +5V
 * LED anode (long leg) attached to digital output 13
 * LED cathode (short leg) attached to ground
 * Note: because most Arduinos have a built-in LED attached 
 to pin 13 on the board, the LED is optional.
 Created by David Cuartielles
 modified 30 Aug 2011
 By Tom Igoe
 This example code is in the public domain.

int sensorPin = A0;    // select the input pin for the potentiometer
int ledPin = 13;      // select the pin for the LED
int sensorValue = 0;  // variable to store the value coming from the sensor
File myFile;

void setup() {
  // declare the ledPin as an OUTPUT:
  pinMode(ledPin, OUTPUT);

void loop() {
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);    
  // turn the ledPin on
  digitalWrite(ledPin, HIGH);  
  // stop the program for <sensorValue> milliseconds:
  // turn the ledPin off:        
  digitalWrite(ledPin, LOW);   
  // stop the program for for <sensorValue> milliseconds:

Arduino-Based Oscilloscope[edit]

From Google Docs:

Use the ‘AnalogReadSerial’ Arduino example sketch to send an analog voltage reading to the computer:

 Reads an analog input on pin 0, prints the result to the serial monitor 
 This example code is in the public domain.

void setup() {

void loop() {

Use this python program to receive the data on the computer and graph it: (note this requires the ‘matplotlib’ module — apt-get install python-matplotlib)

import serial, numpy, matplotlib
from time import sleep
port = '/dev/ttyACM0'
ser = serial.Serial(port,9600,timeout=0)
f = open('/tmp/workfile', 'w')
i = 0
while i<500:
    data =
    if len(data) > 0:
    i = i+1

data = numpy.genfromtxt('/tmp/workfile')
import matplotlib.pyplot as plt
z = plt.plot([])
z += plt.plot(data)

With a wire across the 555 terminal in place of a resistor, the LED is clearly blinking violently. The graph:

((insert graph here!))

Can I increase the baud rate above 9600 on the Arduino?

I currently use:


As it turns out, all I have to do is use:


possible baud rates: 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, or 115200

After making the same adjustment in the Python script:

((insert second graph!))

According to this: with this setup, I’m sampling around 500 times per second. I can add timestamps by printing ‘micros()’. As the site mentions, you can use Arduino memory magic to get up to 56k samples per second! But you’re still limited to only 100 samples by the onboard memory... must get an Arduino with a memory card!

Arduino References[edit]

Information on the pySerial module:

High-speed sampling with the Arduino:

Python i/o tutorial:

Python pyserial module:

Arduino serial information:

Sensing and Control[edit]

Electrical Conductivity[edit]


Ion-Selective Electrodes[edit]

Sensor Resources[edit]

Facebook's Open-Source Networking[edit]