Class 05- Lab assignments 13 14

Lab assignment 13:  CapacitiveSensor . Using the  body
The wires and the foil make a live capacitor as the body approaches the foil the capitance changes.
Key terms:
// import the library (must be located in the Arduino/libraries directory)
#include <CapacitiveSensor.h>

// create an instance of the library
// pin 4 sends electrical energy
// pin 2 senses senses a change
CapacitiveSensor capSensor = CapacitiveSensor(4, 2);

// open a serial connection
// set the LED pin as an output
pinMode(ledPin, OUTPUT);

void loop() {
// store the value reported by the sensor in a variable
long sensorValue = capSensor.capacitiveSensor(30);



Lab assignment 14:  Set Serial communication between Arduinio+Processing
Use the values from a potentiometer and pass them directly to processing to control the color of a sketch
Key terms:

// initialize serial communication

void loop() {
// read the value of A0, divide by 4 and send it as a byte over the
// serial connection
//Serial.print(“POTENTIOMETER =”);
// Serial.println(analogRead(0) / 4.0);
Serial.write(analogRead(0) / 4.0);


// import the serial library
import processing.serial.*;

// create an instance of the serial library
Serial myPort;

// create an instance of PImage
PImage logo;

// load the Arduino logo into the PImage instance
logo = loadImage(“”);

// print a list of available serial ports to the Processing status window

println(“Available serial ports:”);

// Tell the serial object the information it needs to communicate with the
// Arduino. Change Serial.list()[0] to the correct port corresponding to
// your Arduino board. The last parameter (e.g. 9600) is the speed of the
// communication. It has to correspond to the value passed to
// Serial.begin() in your Arduino sketch.
myPort = new Serial(this, Serial.list()[0], 9600);


Class 04- Lab assignments 10 11 12

Lab assignment 10:
   H-Bridge integrated circuit. Reverse Motor
An H-bridge has up to 4 inputs and outputs with 2 separate power supplies. A potentiometer is used to control the power supply Arduino will send 2 seperate highs and lows change the motor direction.
Key terms:
// if the on/off button changed state since the last loop()
if (onOffSwitchState != previousOnOffSwitchState) {
// change the value of motorEnabled if pressed
if (onOffSwitchState == HIGH) {
motorEnabled = !motorEnabled

// if the motor is supposed to be on
if (motorEnabled == 1) {
// PWM the enable pin to vary the speed
analogWrite(enablePin, motorSpeed);
} else { // if the motor is not supposed to be on
//turn the motor off
analogWrite(enablePin, 0);


Lab assignment 11:   LCD Display with messages
Use a tilt switch randomly select 8 messages to be displayed on a lcd screen. Use the potentiometer to control the screen brightness. 
Key terms:
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// set up the number of columns and rows on the LCD
lcd.begin(16, 2);
// line 1 is the second row, since counting begins with 0
lcd.setCursor(0, 1);
// print to the second line
lcd.print(“Crystal Ball!”);



Lab assignment 12: Use a Piezo as a sound in input
Use a piezo as a sound input and monitor the sound values between different inputs to signal a LED output and control a servo motor which acts as a visual signal.
Key terms:
// import the library
#include <Servo.h>
// create an instance of the Servo library
Servo myServo;
// attach the servo to pin 9
// this function checks to see if a detected knock is within max and min range
boolean checkForKnock(int value) {
if (value > quietKnock && value < loudKnock) {
return true;
// check the value of the piezo
knockVal = analogRead(piezo);


Class 05- Soldering Assignment

Soldering assignment :   Solder on to a proto-board a previous sketch from the Arduino kit. 02: Space interface

Sketch:  (click on image to enlarge)

week 05-soldering-fritzing-2

Circuit Soldered

Soldered board: (click on image to enlarge)

Soldered Board

Soldered Board





Class 03- Lab assignments 06 07 08 09

Lab assignment 06:   Use a Piezo as a Theremin
Use a photoresistor to calibrate a Piezo that changes the frequency.
The calibration process takes place with while loop (millis() < 5000). The key point in calibration is the high and low points are initially reversed. sensorValue <1023 (LOW)
sensorValue > 0 (HIGH)
Key terms:
while (millis() < 5000) {
sensorValue = analogRead(A0);
// remap sensr 0-1023 to freq 50,4000
int pitch = map (sensorValue,sensorLow,sensorHigh,500,4000);



Lab assignment 07:   Use a Piezo as a Keyboard
Using a resistor ladder. Take reading from 5 resistors in series the voltage drops across each resistor giving a different output. The values are converted to frequencies for the piezo.

Key terms:
int notes[] = {262,294,330,349};
int keyVal = analogRead(A0); (0-1023)
(keyVal >= 990 && keyVal <=1010) 


Lab assignment 08:   Digital Hourglass +tilt switch
Using a millis() function to read the time in milliseconds count the interval time and then set on a LED for that time period. Then use the tilt switch to reset all the LED’s.

Key terms:
unsigned long previousTime = 0;
long interval = 1000;
//read switchpin 8
switchState = digitalRead(switchPin);(either 1 or 0)



Lab assignment 09:  Motor switch using a transistor gate and switch
Press a button to send a signal to arduino that resends a high to the transistor gate. That activates the motor. Use a diode in parallel with the motor to counteract reverse induced voltage.

Key terms:
 pinMode(motorPin, OUTPUT);

switchState = digitalRead(switchPin);

if (switchState == HIGH) {

} else {




Class 06- Lab Christmas project Idea 03


Interactive Stain Glass Sculpture
Making a 1ft 6 piece square pyramid sculpture connected by copper wire. Each pyramid has a LED inside it which will be activated using a sonar distance sensor. 

As the hand moves up and down the sculpture the LEDS mirror the rough position of the hand and switch on and off as the hand passes.


  1. Paper mockup build and connect
  2. 2amp 9 volt power supply for ardunino or arduino uno.
  3. stain glass and copper foil and solder and solder wire
  4. support copper wire & conducting wire leds
  5. switch to turn on and off
  6. sonar distance detector.
  7. wooden housing box
  8. possible audio shield
  9. shifter register
  10. LED 8MM PL9823 RGB integrated controller
  11. Solder. Glass and copper foil and flux and cutters.

Further development: add sound to be triggered in the same way

Mockup and circuit diagram:


Interactive Glass Sculpture

 Acrylic surfaces retextured with iridescent film:


Solid state circuit built and complete and tested with mig-welded stand;
Prototype finished test:

Class 02- Lab assignments 02 03 04 05

Lab assignment 02:   Use a switch to flicker between LED’S.

Reading from a digital input find out if a button has been pressed and send messages to LED’s to flick between them. 
Key terms:
switchState= digitalRead(2);


Lab assignment 03:   Use a temperature sensor to light up LED’S.
Read from a sensor and calibrate its reading to meaningful data (C) and display onto the serial monitor. Use the temperature to switch on the value of a series of LED’s.
Key terms:
voltage = (sensorVal/1023.0) * 5.0;
temperature = (voltage -.5) * 100; 
if(temperature > baselineTemp+6 )


Lab assignment 04:   Use photoresistors to  light up a cathode RGB LED.
Read data from 3 photoresistors each with their own gels (r,g,b) 0-1023 convert the data
to 0-255 for the led values using PWM.Pulse Width Modulation. A call to is on a scale of 0 – 255, such that analogWrite(255) requests a 100% duty cycle (always on), and analogWrite(127) is a 50% duty cycle (on half the time) for example.
Key terms:
analogWrite(redLEDPin,redValue); (0-255)


Lab assignment 05:   Use a potentiometer to control a servomotor
Use an include library (servo) and add a servo class object to read the values from a potentiometer to a servo motor (0-180Deg). Remap potentiometer values (0-1023) to a servo motor values (0-180)
Key terms:
#include <Servo.h>
Servo myservo;
 angle = map(potVal,0,1023,0,179);






Class 01- Lab assignments 01

Class01 Lab work assignments:
Just using the power supply of the computer. Create a simple series and parallel circuit to light a LED enabled with switches.

Key terms: