231a-ag complete instructions

From CSclasswiki
Jump to: navigation, search

Complete Instructions To Do It Yourself

I recently realized that all my progress reports and instructions on how to wire things, etc. are scattered all over the place. Here is a complete "instruction manual" on how to recreate this project!

Supplies

  • Arduino Diecimilia
  • Buzzer
  • LED Matrix - Dual Color - Small (COM-00681)
  • Keypad - 12 Button (COM-08653)
  • 6 (six) 10 Kohms resistors
  • 1 (one) 300 ohms resistor
  • Small breadboard
  • A lot of wires (preferably lots of colours, so you can colour-code things!)

Schematic

231a-ag revisedArduinoschematic4.png

Wiring

1. "Attach" the Arduino to the breadboard, using an elastic. 2. Wire the buzzer:

  • The buzzer has two wires extending from it, one black and one red. "Plug" the black wire into the Arduino, at digital I/O pin 13.
  • "Plug" the red wire into the breadboard.
  • Wire the 300 ohms resistor on the breadboard (it needs to be "connected" to the buzzer).
  • Using another piece of wire, wire another column of the breadboard to 5V.
  • Using yet another piece of wire, wire the 5V column of the breadboard to the 300 ohms resistor to complete the buzzer circuit.

3. Wire the LED matrix:

  • Digital I/O pins 10, 11 and 12 connect to columns 3, 4 and 5 of the LED matrix. Take three wires, and connect one end into digital I/O pins 10, 11 and 12 (one wire for each pin).
  • Connect these three wires to the breadboard, where they will eventually be wired to resistors.
  • Connect three 10 Kohms resistors to the breadboard.
  • Take another 3 pieces of wire, and connect them to pins 18, 15 and 4 on the LED matrix. We do this because it is the "columns" part of the LED matrix that needs the resistors. Be sure that the resistor coming from Arduino pin 10 is going to LED matrix pin 18, the resistor coming from Arduino pin 11 is going to LED matrix pin 15, and the resistor coming from Arduino pin 12 is going to LED matrix pin 1.
  • The "rows" part of the LED matrix does not need resistors. Therefore, take another three pieces of wire, and connect them from Arduino digital I/O pins 9, 8 and 7 to LED matrix pins 16, 13 and 5 respectively.

4. Solder wires to the keypad! 5. Wire the keypad:

  • Keypad pins 2, 6 and 7 do not require resistors. Take three wires, and connect these pins to Arduino digital I/O pins 5, 4 and 3 respectively.
  • Keypad pins 1, 3 and 5 will require resistors. Take three wires, and connect these pins to the breadboard, where they will eventually be wired to resistors.
  • Connect three 10 Kohms resistors to the breadboard.
  • Take another 3 pieces of wire, and connect them to Arduino analog pins 1, 0 and 2 respectively (to keypad pins 1, 3 and 5).
  • Take yet another 3 pieces of wire, and connect the three resistor columns (which are connected to keypad pins 1, 3 and 5) to the 5V column on the breadboard.

6. Optional step: Take some electrical tape, and section off the part of the LED matrix that you'll be using! It makes it easier to read.

231a-ag whatItLooksLike.jpg
That's what mine looks like!

Test It!

This is the testing code I used for my project.

/*
 * Hardware Testing
 *
 * Program that tests the Arduino hardware.
 *
 */

int ledPin = 8;                   // LED connected to digital pin 8 and 12
int ledPin2 = 12;
int buzzerPin = 13;

int keypadDPin3 = 3;
int keypadDPin4 = 4;
int keypadDPin5 = 5;

int keypadAPin0 = 0;
int keypadAPin1 = 1;
int keypadAPin2 = 2;

int padNumber3 = 0;
int padNumber1 = 0;
int padNumber5 = 0;

int padNumber2 = 0;
int padNumber7 = 0;
int padNumber6 = 0;

void setup()                       // run once, when the sketch starts
{
  pinMode(ledPin, OUTPUT);         // sets the digital pin as output
  pinMode(ledPin2, OUTPUT);
  pinMode(buzzerPin, OUTPUT);
  
  pinMode(keypadDPin3, OUTPUT);
  pinMode(keypadDPin4, OUTPUT);
  pinMode(keypadDPin5, OUTPUT);
  
  pinMode(keypadAPin0, INPUT);
  pinMode(keypadAPin1, INPUT);
  pinMode(keypadAPin2, INPUT);
  
  Serial.begin(9600);
}

void loop()                        // run over and over again
{
  digitalWrite(buzzerPin, LOW);    // sets buzzer on
  digitalWrite(ledPin, LOW);         // test the LED matrix
  digitalWrite(ledPin2, HIGH);

  digitalWrite(keypadDPin3, LOW);
  digitalWrite(keypadDPin4, LOW);
  digitalWrite(keypadDPin5, LOW);

  padNumber3 = analogRead(keypadAPin0);
  padNumber1 = analogRead(keypadAPin1);
  padNumber5 = analogRead(keypadAPin2);

  Serial.println(padNumber3);        // testing the keypad buttons
  Serial.println(padNumber1);
  Serial.println(padNumber5);
}

If you use this code, you whenever you press the keypad numbers 1, 4 or 7, you should see a number lower than 200 for padNumber3. When you press keypad numbers 2, 5 or 8, you should see a number lower than 200 for padNumber1. And when you press keypad numbers 3, 6 and 9, you should see a number lower than 200 for padNumber5. An easy way to make sure this is working is to comment out each one in turn =)

Arduino Sketch

Load this Arduino sketch into the Arduino, and it'll work! (Well, not completely, there's no assembly program... see other documentation pages for details.)