Sunday, December 19, 2010

Project 2/3 Photos



















Found a few pictures from the making of Project 2/3........

Project 1 Update....

Better late than never.....  Thought I would toss up a few pictures from the making of project 1.....


















what a silly group.... lol  looks like they are having fun though.

Monday, November 29, 2010

MS Tag...... more complicated than you might think.

This is what happens when your having a bad day and you fill out a new account and skip reading the fineprint........ or any other part for that matter. lol

The old group is back together.

Hey everyone,

If you couldn't get enough of project 2 then your in luck.....!!!!!!   The old band is back together for an after show encore.   Project 2 is back for repairs from the Beta Version.  New and improved Project 2.1 may include any of the following updates:

pamphlets of supplemental literature
lines on the map to distinguish states
more labeling around led's
a website link from a bar code
labels of state names
and a gas pump rt next to our display

Please remember to check in regularly to find out more exciting news about Project 2.

Friday, November 12, 2010

Pull Down Resistor

Apperently the pull down resistor is the necessary ingredient to getting a matrix of buttons to work .... lol

Here is the site that exlains the concept very clearly:

http://www.ladyada.net/learn/arduino/lesson5.html
Fig 5.5 (unfortuneatly the picture was not cooperative see above link)

The pull-down resistor here is the 10K resistor. When the switch is held down, the 100Ω resistor is connected directly to 5V. When the switch is released, the 100Ω resistor is connected to the 10K resistor which pulls it down to ground.
Here's how to think of it: When you press the button and connect the 100Ω resistor to 5V, the button has a very small resistance (less than 1 Ω!), so it provides a strong pull to 5V.
The 10KΩ resistor is also connecting the 100Ω resistor to ground, but since the 10KΩ resistor has 10000 times more resistance than the button, its a very weak pull to ground and can't compete. The strong 5V connection overpowers the weak ground connection and the input pin reads HIGH.
However, when the switch is disconnected, there is no longer a strong pull to 5V. In fact, its let go completely. But there is still weak pull to ground. Despite being a weak connection, it's better than nothing and so the resistor pulls the input pin to LOW.

Serial Communications using the TX and RX pins

I have successfully gotten two arduinos to communicate with a very simple program.  I used the push button example, the switch case program, along with serialprint() serialread() examples from the arduino home page... combining these three codes allows me to use a button to print the ascii coded letter m or n onto the serial pins (RX and TX) then the other arduino will read the letter n or m and execute a switch case program to turn on either a red or yellow led.  Of course this is a very simplified example but it demonstrates how I will use an indicator of which state is called upon by the user and serially communicate that data to another arduino which will display that states energy consumption information


here are some pictures showing the last 3 hours of work.... lol


----------------------------------------------------------------------------------
//SERIAL OUT PROGRAM

const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin
char val = 0;
char val1 = 0;
// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  Serial.begin(9600);
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);     
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);   
}

void loop(){
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {   
    // turn LED on:   
    digitalWrite(ledPin, HIGH);
      val = 'm';
      if (val != val1) {
           Serial.print(val);
           val1=val;
           delay(200);
  }


  }
      else {
        // turn LED off:
        digitalWrite(ledPin, LOW);
          val = 'n';
          if (val != val1) {
               Serial.print(val);
               val1=val;
               delay(200);
  }
  }
}


--------------------------------------------------------------------------------------

//SERIAL IN PROGRAM

int incomingByte = 0;    // for incoming serial data

void setup() {
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
    Serial.begin(9600);    // opens serial port, sets data rate to 9600 bps
}

void loop() {

    // send data only when you receive data:
     if (Serial.available() > 0) {
        // read the incoming byte:
        incomingByte = Serial.read();

        // say what you got:
        Serial.print("I received: ");
        Serial.println(incomingByte,BYTE);
                switch (incomingByte) {
                        case 'm':
                            digitalWrite(4, LOW);   // sets the LED on
                            //delay(4000);                  // waits for a second
                            digitalWrite(5,HIGH);    // sets the LED off
                            //delay(1000);
                            break;
                        case 'n':
                            digitalWrite(5, LOW);   // sets the LED on
                            //delay(4000);                  // waits for a second
                            digitalWrite(4, HIGH);    // sets the LED off
                            //delay(1000);
                            break;
                        default:
                          break;
  }

}
}
these are the two programs I have written from pieces of code I found on the Arduino website

Key Pad Example

What is it?

The Keypad library allows your Arduino to read a matrix type keypad. You can scavenge these keypads from old telephones or you can get them from almost any electronics parts store for less than $5 USD. They come in 3x4, 4x4 and various other configurations with words, letters and numbers written on the keys. This library is capable of supporting all of those.

Download latest (This includes four example sketches.)


Identifying the keypad pins

First you need to get a piece of paper and draw the right hand diagram as you see it below. I've already written my pin numbers (1,2,3 across the bottom and 7,6,5,4 down the right side) which you can just leave off of your drawing. Next, you are going to use your Ohm meter to find out which pins are connected to which keys. The first thing to do is count how many pins are on your keypad (as seen in the photo below.) The photo is showing 14 pins though not all of the pins are used. Don't worry, the unused pins will just be ignored.

Procedure

  1. Connect your Ohm meter leads to pins 1 and 2.
  2. Press all the buttons until the meter indicates a closure.
  3. Write down the pin numbers next to the column and row for the key you just found. Example: Your meter is connected to pins 1 and 5. When you pressed the number 7 your meter reacted. Write 1 under COL0 and 5 next to ROW2.
  4. If the meter didn't react then move the meter lead from pin 2 to pin 3 and repeat steps 2 and 3 above.
  5. Now, keep moving the lead to the next pin and repeat steps 2 and 3 for each pin.
  6. Once you have reached the end move the first meter lead from pin 1 to pin 2 and repeat steps 2 and 3 while connecting the second meter lead to pins 3 through the highest pin.
  7. Once you have completely identified all the pins on the diagram then you can safely ignore any unused keypad pins. You are now ready to wire the keypad to your Arduino.

Notes on using the library

  • The library is non-blocking which means you can press and hold the key all day long and your Arduino will continue processing the rest of your code.
  • Consider, though, when you are writing your code that every delay() you use will take processing time away from the keypad. Something as short as delay(250) can make the keypad seem very unresponsive. And the same thing will happen if you sprinkle a bunch of delay(10)'s all through your code.
  • The function getKey() returns a key value as soon as you press the key but it does not repeat automatically. Also, when you release the key you can track the KEY_RELEASED event if you are using the eventListener feature of the library.
  • You will need pullup resistors, somewhere between 2k to 10k, on each of the row pins.

Example

< Find more examples on how to use the new library. >

/*  Keypadtest.pde
 *
 *  Demonstrate the simplest use of the  keypad library.
 *
 *  The first step is to connect your keypad to the
 *  Arduino  using the pin numbers listed below in
 *  rowPins[] and colPins[]. If you want to use different
 *  pins then  you  can  change  the  numbers below to
 *  match your setup.
 *
 *  Note: Make sure to use pullup resistors on each of
 *  the rowPins.
 */
#include <Keypad.h>

const byte ROWS = 4; // Four rows
const byte COLS = 3; // Three columns
// Define the Keymap
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'#','0','*'}
};
// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = { 9, 8, 7, 6 };
// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
byte colPins[COLS] = { 12, 11, 10 }; 

// Create the Keypad
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

#define ledpin 13

void setup()
{
  digitalWrite(ledpin, HIGH);
  Serial.begin(9600);
}

void loop()
{
  char key = kpd.getKey();
  if(key)  // same as if(key != NO_KEY)
  {
    switch (key)
    {
      case '*':
        digitalWrite(ledpin, LOW);
        break;
      case '#':
        digitalWrite(ledpin, HIGH);
        break;
      default:
        Serial.println(key);
    }
  }
}

Troubleshooting

Make sure you are using pull-up resistors on the row pins of your keypad.
You can pretty much connect your keypad to any pins you would like. Be careful not to use the serial pins if you are using them for communication.
If key presses take a long time to register then you need to make sure that you are not using long delay()'s in your code.
Make sure you understand the pin mappings and have the keypad wired up to match. If you did wire the pins incorrectly you may be able to redefine the pins and/or keymap to make your keypad work.

Modifying the library

The library supports user defined pins and keymaps so it should not be necessary to change the library. However, if you do then you should delete the library's .o file after any changes so that the library will be properly recompiled.

More information on using and creating libraries

Thursday, November 11, 2010


Mary took a picture of me working on the LED particularly for blogging purposes. Basically, what we have here is the bunch of LEDs turning on and off with such a short delay, that they look like they are always on with a slight flicker. The code is designed so that they light up in sequences, firs the the red, then the yellow, then the larger red (which will be switched to orange) and then the green.

in other news : rhino

 

we need three different types of cuts on our project. so, we need three different rhino files for each different cut type.

we started with the first image (far left) as the main drawing, and then made the other three files from it. the second one is the text cut (send from the left) the next one i the cut outs for the LEDs and photo resistors (send from the right) the last (far right) is the actual map of the states.



note on the map : the map file is actually quite intricate, it has to be pared down to its simplest  line construction for the CNC router. . .

after more hours of research, and hours work...

if you remember in my last post, i said :


"I almost missed a super simple solution......  $9.00 worth of analog MUXs from digikey and were in business........ anyone who want reliable ic components quickly check out DIGIKEY.COM
analog multiplexer/demultiplexer------------------4051"

NOT the case. Sleepless nights, 15 hours and a bunch of engineers working on this, found that we using decoders and IC chips based on the other schematic that is from the sample code. to finally get to a working point

Friday, November 5, 2010

After hours of research......

I almost missed a super simple solution......  $9.00 worth of analog MUXs from digikey and were in buisness........ anyone who want reliable ic components quickly check out DIGIKEY.COM


analog multiplexer/demultiplexer------------------4051


A multiplexer or demultiplexer enables you to expand the in-and outputs on your Arduino board. The 4051 is an 8 channel analog multiplexer / demultiplexer, thus:
  • If you use the 4051 as a Multiplexer: You can choose between 8 different inputs and select just one you want to read at the time.
  • If you use the 4051 as a Demultiplexer you can choose between 8 different outputs and select just one you want to write at the time.
Futhermore, the 4051 is able to work with analog values; in the case of the Arduino, you are able to use the analog inputs with a voltage between 0-5V and route them to an Analog-In Pin on your Arduino.
To select the Pin we would like to read or write, we have to use the three Select Pins (S0, S1 and S2). Each of these pins have to be connected to one digital out pin on the Arduino. Every pin is representing a number (S0 = 1; S1 = 2; S2 = 4) and if we set one of these Select pins to HIGH, the number the pin is representing will be transmitted to the 4051. For example:
  • If S0 and S1 are HIGH and S2 is LOW pin y3 is selected (1+2+0 = 3).
  • If S0 and S2 is HIGH and S1 LOW pin y5 is selected (1+0+4 = 5).
It is not possible to read or write more than one pin on the 4051 at the same time, because you can only select one pin at a time. But you can read and write to the pins quite fast. There is no delay needed between selecting and read or writing the pin.
  • Z ----- common input/output (connected to Arduino Input/Output)
  • E ----- enable input (active LOW) (connected to ground (gnd))
  • Vee --- negative supply voltage (connected to ground (gnd))
  • gnd --- ground (0 V)
  • S0-S2 - select inputs (connected to three arduino digitalOut Pins)
  • y0-y7 - independent inputs/outputs
  • Vcc --- positive supply voltage (5v)
The left image above is an example how to use 9 multiplexer to read 64 analog Inputs just with one Analog-In-Pin on the arduino. The right image above is an example how to use two 4051 (one as demultiplexer and one as multiplexer) in a 8x8 Matrix to check 64 buttons or other digital Inputs just with one digital-In-Pin on the arduino (with the second setup you can just have two buttons on at the same time, otherwise you have to use the first (left) setup).
//////////////////////////////////////////////////////////////////////code example
  1. /*
  2.  * codeexample for useing a 4051 * analog multiplexer / demultiplexer
  3.  * by david c. and tomek n.* for k3 / malm� h�gskola
  4.  *
  5.  */  
  6.  
  7. int led = 13;    //just a led
  8. int r0 = 0;      //value select pin at the 4051 (s0)
  9. int r1 = 0;      //value select pin at the 4051 (s1)
  10. int r2 = 0;      //value select pin at the 4051 (s2)
  11. int row = 0;     // storeing the bin code
  12. int count = 0;    // just a count
  13. int  bin [] = {000, 1, 10, 11, 100, 101, 110, 111};//bin = bin�r, some times it is so easy
  14.  
  15. void setup(){
  16.  
  17.   pinMode(2, OUTPUT);    // s0
  18.   pinMode(3, OUTPUT);    // s1
  19.   pinMode(4, OUTPUT);    // s2
  20.  digitalWrite(led, HIGH);
  21.   beginSerial(9600);
  22. }
  23.  
  24. void loop () {
  25.  
  26.   for (count=0; count<=7; count++) {
  27.     row = bin[count];      
  28.     r0 = row & 0x01;
  29.     r1 = (row>>1) & 0x01;
  30.     r2 = (row>>2) & 0x01;
  31.     digitalWrite(2, r0);
  32.     digitalWrite(3, r1);
  33.     digitalWrite(4, r2);
  34.     //Serial.println(bin[count]);
  35.     delay (1000);
  36.   }  
  37. }

Inspirations----- this is exactly what i want to do YAY!!!




/*
 * Show messages on an 8x8 led matrix,
 * scrolling from right to left.
 *
 * Uses FrequencyTimer2 library to
 * constantly run an interrupt routine
 * at a specified frequency. This
 * refreshes the display without the
 * main loop having to do anything.
 *
 */


#include <FrequencyTimer2.h>

#define SPACE { \
    {0, 0, 0, 0, 0, 0, 0, 0},  \
    {0, 0, 0, 0, 0, 0, 0, 0}, \
    {0, 0, 0, 0, 0, 0, 0, 0}, \
    {0, 0, 0, 0, 0, 0, 0, 0}, \
    {0, 0, 0, 0, 0, 0, 0, 0}, \
    {0, 0, 0, 0, 0, 0, 0, 0}, \
    {0, 0, 0, 0, 0, 0, 0, 0}, \
    {0, 0, 0, 0, 0, 0, 0, 0} \
}


#define H { \
    {0, 1, 0, 0, 0, 0, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 1, 0}, \
    {0, 1, 1, 1, 1, 1, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 1, 0}  \
}


#define E  { \
    {0, 1, 1, 1, 1, 1, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 1, 1, 1, 1, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 1, 1, 1, 1, 1, 0}  \
}


#define L { \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 1, 1, 1, 1, 1, 0}  \
}


#define O { \
    {0, 0, 0, 1, 1, 0, 0, 0}, \
    {0, 0, 1, 0, 0, 1, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 1, 0}, \
    {0, 0, 1, 0, 0, 1, 0, 0}, \
    {0, 0, 0, 1, 1, 0, 0, 0}  \
}


byte col = 0;
byte leds[8][8];

// pin[xx] on led matrix connected to nn on Arduino (-1 is dummy to make array start at pos 1)
int pins[17]= {-1, 5, 4, 3, 2, 14, 15, 16, 17, 13, 12, 11, 10, 9, 8, 7, 6};

// col[xx] of leds = pin yy on led matrix
int cols[8] = {pins[13], pins[3], pins[4], pins[10], pins[06], pins[11], pins[15], pins[16]};

// row[xx] of leds = pin yy on led matrix
int rows[8] = {pins[9], pins[14], pins[8], pins[12], pins[1], pins[7], pins[2], pins[5]};

const int numPatterns = 6;
byte patterns[numPatterns][8][8] = {
  H,E,L,L,O,SPACE
};

int pattern = 0;

void setup() {
  // sets the pins as output
  for (int i = 1; i <= 16; i++) {
    pinMode(pins[i], OUTPUT);
  }

  // set up cols and rows
  for (int i = 1; i <= 8; i++) {
    digitalWrite(cols[i - 1], LOW);
  }

  for (int i = 1; i <= 8; i++) {
    digitalWrite(rows[i - 1], LOW);
  }

  clearLeds();

  // Turn off toggling of pin 11
  FrequencyTimer2::disable();
  // Set refresh rate (interrupt timeout period)
  FrequencyTimer2::setPeriod(2000);
  // Set interrupt routine to be called
  FrequencyTimer2::setOnOverflow(display);

  setPattern(pattern);
}

void loop() {
    pattern = ++pattern % numPatterns;
    slidePattern(pattern, 60);
}

void clearLeds() {
  // Clear display array
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 8; j++) {
      leds[i][j] = 0;
    }
  }
}

void setPattern(int pattern) {
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 8; j++) {
      leds[i][j] = patterns[pattern][i][j];
    }
  }
}

void slidePattern(int pattern, int del) {
  for (int l = 0; l < 8; l++) {
    for (int i = 0; i < 7; i++) {
      for (int j = 0; j < 8; j++) {
        leds[j][i] = leds[j][i+1];
      }
    }
    for (int j = 0; j < 8; j++) {
      leds[j][7] = patterns[pattern][j][0 + l];
    }
    delay(del);
  }
}

// Interrupt routine
void display() {
  digitalWrite(cols[col], LOW);  // Turn whole previous column off
  col++;
  if (col == 8) {
    col = 0;
  }
  for (int row = 0; row < 8; row++) {
    if (leds[col][7 - row] == 1) {
      digitalWrite(rows[row], LOW);  // Turn on this led
    }
    else {
      digitalWrite(rows[row], HIGH); // Turn off this led
    }
  }
  digitalWrite(cols[col], HIGH); // Turn whole column on at once (for equal lighting times)
}

Monday, November 1, 2010

project 2 - where our idea comes from

My group discussed several ideas.... We talked about current topics such as AIDS, oil consumption, Gay Rights, Poor Parenting skills of todays parents and even Politics.  After some discussion we decided to place all of our ideas in a hat and choose randomly.  Today's oil consumption won!! yay

Tuesday, October 19, 2010

Project 2

This is my group (minus me of course) for the second project along with our sketch of the idea for project 2.

We are trying to address energy awareness and dependence on the nonrenewable oil supply.

We are discussing the idea of routering out a relief map on a piece of MDF and adding interactive light sensors and led's that let the user see information.