Archive

Reference

Here is one patch some of you may be of interest in your final assignment. It uses the BANG to play a sequence of midi note in an octave.

Advertisements

Using a piezo plate, we implement a very simple knock sensor. We need a larger resistor (1M Ohm) connected in parallel with the piezo plate.

Piezo element with the connection wires

Connect the piezo to the beardboard

Connect the resistor in parallel with the piezo element

Connect the LED indicator

 

 
Code sample

const int LED = 7;
const int KNOCK = 1;

void setup()
{
  pinMode(LED, OUTPUT);
}

void loop()
{
  int value = analogRead(KNOCK);
  if (value>100)
  {
    digitalWrite(LED, HIGH);
  }
  else 
  {
    digitalWrite(LED, LOW);
  }
  delay(50);
}

Since a lot of you may drive larger load of LEDs, the IC ULN2803A can be useful. Please see the following description and example.

How to use the ULN2803A IC with Arduino and its breadboard? In this demonstration, I use only one pair of input and output of the IC. You can use up to 8 pairs to control your lighting devices or others facilities.

Prepare an external power plug to use your 12V power adaptor.

Insert the ULN2803A IC on the breadboard.

Connect the power and ground of the IC.

Connect the IC to the Arduino’s Digital Output pin.

Testing

You can use the blinking LED program to test the circuit.

Here is a summary of the common forward voltage drop (explained later) for different LEDs. The maximum continuous forward current for most 5mm LEDs will be in the range 15 – 70nA. In most projects, we use a resistor of 200 – 300 Ohm when using a LED.

  • Red (1.5 – 2.2V)
  • Green (2 – 3V)
  • Blue (2.5 – 3.5V)
  • Yellow (1.5 – 2.2V)
  • White (3.5 – 4V)