Archive for the ‘Level 1’ Category

Video Experimenter on the Seeeduino Mega

The nootropic design Video Experimenter shield uses some pretty advanced features of the Arduino’s ATmega328 microcontroller. One downside of this is that you can’t use the Video Experimenter shield on an Arduino Mega. Why? Well, the designers of the Arduino Mega didn’t connect a lot of the ATmega1280/ATmega2560 pins to headers on the board so that you could use them! And, as it turns out, the pins with key features utilized by the Video Experimenter are not connected to anything!

To perform video overlay, the Video Experimenter relies on an input capture pin (to capture the exact time that the pin has changed state). Even though the ATmega1280/ATmega2560 has 4 input capture pins, none of them are connected!

Important pins not even connected!




And to capture video images in the Arduino’s memory, Video Experimenter uses the analog comparator in the chip. But the AIN0 pin for the analog comparator is not connected! What were the Arduino Mega designers thinking?

Fortunately, there is the Seeeduino Mega. The guys at Seeed Studio broke out nearly all the pins on the ATmega1280 so that you can use them. I love the Seeeduino Mega because it provides so many pins on a rather small board.

Simply make 5 connections with jumper wires and you can use the Video Experimenter on the Seeeduino Mega. No code changes necessary!

By connecting 5 jumper wires, you can use the Seeeduino Mega


 

Here are the connections to make:

11 to 9 (white wire in picture above)
7 to 29 on the Seeeduino Mega (yellow wire)
INPUT pin on the Video Experimenter to PE2 on the Seeeduino Mega (green wire)
SYNCOUT pin on the Video Experimenter to PD4 on the Seeeduino Mega (gray wire)
VSYNC pin on the Video Experimenter to 21 on the Seeeduino Mega (brown wire)

Now you can use the Video Experimenter with an Arduino that has a more powerful processor. It really helps to have 8K of SRAM instead of 2K. Now you can do text and graphics overlay with higher resolutions, like 192×128. Have fun!


Published by Michael, on July 13th, 2011 at 2:02 pm. Filed under: Arduino,Level 1,Video. | 4 Comments |

Tutorial: PCB Design T-Shirt

I recently had the idea of printing a PCB design on a t-shirt. Since I don’t do my own silkscreening, I just wanted to upload my EAGLE PCB design to a custom t-shirt provider and have them do the hard part. In this post I’ll show you how you can do the same for your favorite board design. Mine turned out great!

Photo by Paul Sobczak


 

First, I exported my board design from EAGLE by choosing File -> Export, then picking Image from the next menu. You want your image to be high resolution, so increase the DPI value to at least 400 to give you a large image. Choose a file location for your large PNG file.

In Eagle, choose File -> Export, then choose Image


 

I then used Custom Ink to have the t-shirt made. I chose a black short sleeve Hanes Beefy-T. The shirt design tool makes it easy to upload an artwork image. After uploading, it asks you to choose the colors that are in the image. My standard Eagle board image has red, blue, white, green, and yellow. The colors you choose don’t have to exactly match your image — it’s just for accurate pricing.

Choose colors included in your image.


 

Then I resized the image so that it filled the front of the shirt. I also made sure to select the checkbox that says “keep the white in my image”.

Resize and position your PCB design


 

Next, get a quote and order a shirt. Mine only cost $24.75 and shipping was free in the U.S. I thought this was a great price and was really happy with the result!


Published by Michael, on May 21st, 2011 at 1:40 pm. Filed under: Art,Level 1. | 1 Comment |

Digit Shield Temperature Display

Difficulty Level = 1 [What's this?]

The Digit Shield makes it trivial to add a numeric display to your project. I’ve used my simple LM34 temperature sensor in many projects, but this is the simplest. Here’s the LM34 sensor connected to analog input pin 0 on the Arduino, with the temperature displayed on the Digit Shield.







The code reads the sensor value, translates to millivolts, and then translates to a temperature (the sensor outputs 10mV per Fahrenheit degree). The Digit Shield library makes it so easy to display the temperature. Here’s the entire Arduino sketch:

#include 

float AREF = 1.1;

void setup() {
  analogReference(INTERNAL);
  DigitShield.begin();
  DigitShield.setPrecision(1);
}

void loop() {
  delay(500);
  int r = analogRead(0);
  int mv = (((float)r/1023.0) * AREF) * 1000.0;
  double t = mv / 10.0;
  DigitShield.setValue(t);
}

Published by Michael, on March 19th, 2011 at 4:27 pm. Filed under: Arduino,Level 1. | No Comments |

Reaction Timer

Difficulty Level = 1 [What's this?]

How fast can you press a button once a timer starts counting? Find out by attaching a button to your Arduino and the Digit Shield. A simple tactile button switch is connected to digital pin 8 and ground.




Press the button once to start the sequence. First the Arduino will wait a random amount of time between 2 and 5 seconds, then it will start counting milliseconds on the display. As soon as you see the numbers start, press the button again to stop the count. Then repeat: press the button again to clear the display and start the random wait before the numbers start counting again.

Here is the complete code:

#include 
#define BUTTON 8

unsigned long start, stop;

void setup() {
  randomSeed(analogRead(0));

  pinMode(8, INPUT);
  digitalWrite(8, HIGH);

  DigitShield.begin();
  DigitShield.setBlank(true);
}

void loop() {
  // wait until button press
  while (digitalRead(BUTTON) == HIGH);

  // turn off the display
  DigitShield.setBlank(true);

  // delay from 2 to 5 seconds
  delay(random(2000, 5000));
  start = millis();
  DigitShield.setBlank(false);

  while (true) {
    DigitShield.setValue((int)(millis() - start));
    if (digitalRead(BUTTON) == LOW) {
      stop = millis();
      break;
    }
  }

  DigitShield.setValue((int)(stop-start));
  delay(1000);
}

Published by Michael, on March 18th, 2011 at 4:40 pm. Filed under: Arduino,Level 1. | No Comments |

Tutorial: Reading a 12-Button Keypad

Difficulty Level = 1 [What's this?]

Most keypads like this are wired so it makes it straightforward to figure out what button is being pressed. With 3 columns and 4 rows of buttons, you only need 7 wires. Typically all the buttons in a column are connected together with the same wire, and all the buttons in a row are connected together with the same wire. To determine which button is pressed, you apply a voltage to the wire attached to a column and then check the wires attached to each row to see if current is flowing through any of them. If so, then the switch for a particular button is closed (button pressed). Then you proceed to the next column and try each row again, etc. Not rocket science — just scanning a bunch of switches to see which one is closed. In fact, there is a keypad library in the Arduino Playground that makes it easy to do this.

Well, the keypad I bought here has 10 wires instead of 7, and it’s wired in a really goofy way. I’m not sure if this is common, but I thought keypads were generally wired as described above. Here’s the schematic that shows how this one is actually wired:

Schematic of my non-standard keypad

Notice that the gray wire is used only for the 9 key. And the orange wire is only used for the * key. And the brown wire is only used for the # key. Why is this built so inefficiently? I have no idea!

Regardless, here is Arduino code that I used to scan this keypad. You can do something similar if you have a keypad that is not wired in a straightforward way.


// Pins
#define BLACK 2
#define WHITE 3
#define GRAY 4
#define PURPLE 5
#define BLUE 6
#define GREEN 7
#define YELLOW 8
#define ORANGE 9
#define RED 10
#define BROWN 11

#define STAR 10
#define POUND 11

void setup() {
  Serial.begin(115200);

  // Rows
  pinMode(BLACK, INPUT);
  digitalWrite(BLACK, HIGH);  // set pull-up resistors for all inputs

  pinMode(WHITE, INPUT);
  digitalWrite(WHITE, HIGH);

  pinMode(GRAY, INPUT);
  digitalWrite(GRAY, HIGH);

  pinMode(PURPLE, INPUT);
  digitalWrite(PURPLE, HIGH);

  pinMode(ORANGE, INPUT);
  digitalWrite(ORANGE, HIGH);

  pinMode(BROWN, INPUT);
  digitalWrite(BROWN, HIGH);

  // Columns
  pinMode(BLUE, OUTPUT);
  digitalWrite(BLUE, HIGH);

  pinMode(GREEN, OUTPUT);
  digitalWrite(GREEN, HIGH);

  pinMode(YELLOW, OUTPUT);
  digitalWrite(YELLOW, HIGH);

  pinMode(RED, OUTPUT);
  digitalWrite(RED, HIGH);

}

void loop() {
  int key = scanKeypad();

  if (key != -1) {
    if (key == STAR) {
      Serial.println("*");
    } else {
      if (key == POUND) {
        Serial.println("#");
      } else {
          Serial.println(key);
      }
    }
  }
}

int scanKeypad() {
  int key = -1;

  // Pull the first column low, then check each of the rows to see if a
  // button is pressed.
  digitalWrite(BLUE, LOW);
  if (digitalRead(BLACK) == LOW) {
    key = 1;
  }
  if (digitalRead(WHITE) == LOW) {
    key = 4;
  }
  if (digitalRead(PURPLE) == LOW) {
    key = 7;
  }
  digitalWrite(BLUE, HIGH);

  // Moving on to the second column....
  digitalWrite(GREEN, LOW);
  if (digitalRead(BLACK) == LOW) {
    key = 2;
  }
  if (digitalRead(WHITE) == LOW) {
    key = 5;
  }
  if (digitalRead(PURPLE) == LOW) {
    key = 8;
  }
  digitalWrite(GREEN, HIGH);

  // Third "column".  Note that the 0 key is wired to this column even though
  // the 0 is really in the second column.
  digitalWrite(YELLOW, LOW);
  if (digitalRead(BLACK) == LOW) {
    key = 3;
  }
  if (digitalRead(WHITE) == LOW) {
    key = 6;
  }
  if (digitalRead(GRAY) == LOW) {
    key = 9;
  }
  if (digitalRead(PURPLE) == LOW) {
    key = 0;
  }
  digitalWrite(YELLOW, HIGH);

  // Last "column" is not really it's own column.  Only wired to * and #
  digitalWrite(RED, LOW);
  if (digitalRead(ORANGE) == LOW) {
    key = STAR;
  }
  if (digitalRead(BROWN) == LOW) {
    key = POUND;
  }
  digitalWrite(RED, HIGH);

  return key;
}

Published by Michael, on April 3rd, 2010 at 1:29 pm. Filed under: Arduino,Level 1. | 1 Comment |