posts tagged with the keyword ‘arduino’

2015.07.14

Teensy++ 2.0 LED Pin

Yes, this post is actually titled “Teensy++ 2.0 LED Pin” because it’s really specific. This is the solution to a problem that took me a while to fix. Actually, it didn’t take a long time to fix, it just took a long time for me to figure it out and implement it. (Maybe it did take a long time for me to fix…)

Anyway, when using most pins on a Teensy++ 2.0 (and probably every other Teensy) with Arduino code, you may have an issue using the LED pin as an input, because it functions differently than all the other pins. You might say “Hey, just use another pin!” but the project I did required every single pin on the Teensy++ 2.0. (Yes, all 46 pins!)

The code is below. The LED pin is sort of treated opposite of how other pins are treated. You short it with +5v instead of ground, and swap the risingEdge and fallingEdge typically used with the bounce library.

// LEDPinButton

#include <Bounce.h>
 
Bounce buttonD6 = Bounce(6, 80); // LED Pin - tie to +5v instead of GND
Bounce buttonD7 = Bounce(7, 80); // Normal Pin - tie to GND
 
void setup() {
  pinMode(PIN_D6, INPUT);        // LED Pin - use INPUT not INPUT_PULLUP
  pinMode(PIN_D7, INPUT_PULLUP);
}
 
void loop() {
  
  buttonD6.update();
  buttonD7.update();
 
  // D6 - LED Pin - tie to +5v instead of GND
  // use risingEdge instead of fallingEdge
  // a
  if (buttonD6.risingEdge()) {
    Keyboard.set_key1(KEY_A);
    Keyboard.send_now();
  }
  if (buttonD6.fallingEdge()) {
    Keyboard.set_key1(0);
    Keyboard.send_now();
  }
  
  // D7 - Normal Pin - tie to GND
  // b
  if (buttonD7.fallingEdge()) {
    Keyboard.set_key1(KEY_B);
    Keyboard.send_now();
  }
  if (buttonD7.risingEdge()) {
    Keyboard.set_key1(0);
    Keyboard.send_now();
  }
  
}

You can also grab this code from github.

2015.05.23

Laser Maze - Photo by Eric Schneeweis

You may remember the Laser Maze from Milwaukee MakerFest in 2013, or maybe you experienced it at Maker Faire Milwaukee in 2014. Well, it’s coming back! Somehow I volunteered to design & build the hardware for Laser Maze 2015!

Laser Pointers

Step 1: Acquire lasers.

I’ve got a big pile of laser pointers, so far so good. Now, I should mention I didn’t do the set-up in previous years, and I don’t have much to work from, so I’ll be making a bunch of decisions, and if they are terrible, let me know.

In the coming weeks I’ll be designing a 3D printed mount for the laser pointers. It will hold the front half, so we can unscrew the back half to change batteries without removing the laser from its position. There is a zip tie on the laser that slides and rotates into place to hold the button down. (A simple design, we’re going for simple on this whole thing.)

Scoreboard

The scoreboard is an Adafruit 1.2″ 4-Digit 7-Segment Display. I’ll probably use a Teensy 3.1 as the controller, and there will be a big green start button and a big red stop button. You press start at one end of the maze and the counter begins… and when you get to the end you press stop and you know your time from the scoreboard.

Oh, and the laser pointers… they bounce off some mirrors and hit solar panels connected to the Teensy. When you break the beam the voltage from the panel drops (which is recognized on the Teensy) and you get penalized. We’ll add time to your total as well. So if you’re 10 seconds into it and break a beam, the timer will suddenly display 20 seconds instead of 10 (or whatever, we’ll figure out the math later.)

There should also be a buzzer of some kind, for the start, stop, and breaking of the beam. I’m just using a piezo for prototyping, but we’ll make sure we have something LOUD for the event.

There are some notes about everything on the laser maze wiki page, but I’ll keep documenting here as I go.

2015.04.22

Electronics

I finally got the electronics for my Turntable Drawing Machine working. It wasn’t easy…

I decided to use a DC gearmotor controlled by an Arduino and potentiometer for the speed. I did a quick test of this with a Leonardo and a DRV8835 Dual Motor Driver Shield for Arduino. It worked fine for controlling the speed of the motor, but I didn’t really want to use the shield, so I used a DRV8835 Dual Motor Driver Carrier I had on hand. (Since I’m only using one DC motor, I probably could have used a DRV8838 Single Brushed DC Motor Driver Carrier.)

Pololu has an easy-to-use Arduino library for the DRV8835 Dual Motor Driver Shield which worked fine for the shield, but doesn’t (I mean didn’t) work with the DRV8835 Dual Motor Driver Carrier. I ended up hacking the library a bit to make it work. All was well until I added a servo. Since the Arduino library for the shield is hard-coded to use pins 7, 8, 9 and 10 there’s an issue because the default Arduino servo library disables PWM control on pins 9 and 10. I then changed the library to not use pins 9 and 10, but that still didn’t quite work… Seems that the servo library and the motor control library both need to use times, so there’s some weirdness there…

I ended up digging through the forums and eventually found some useful posts and a link to ServoTimer2.zip. (It’s worth noting that there are a number of ServoTimer2 libraries, but I tried this one and it worked.)

Once I had the ServoTimer2 library in place, getting it to work with the my hacked ‘DRV8835DualDriver’ library was simple. (I’m saying “simple” but it took a few hours of screwing around with things that should have worked but didn’t) If I had used one of the Arduino Megas I had lying around, I probably could have avoided some of the issues the Servo library causes.

Alright, well… electronics seem good! Next step is to build things, and get the turntable portion constructed to test if the DC gearbox will work out. I think it will, as it’s got plenty of torque, and there shouldn’t be much resistance.

2015.04.20

Arduino.cc

In accordance with a request from organizations and people I respect, here’s a photo take on 2015-04-19 showing the packaging from an Arduino UNO I purchased from Adafruit Industries (in the United States of America) on 2010-10-19 showing the text “Manufactured under license from Arduino by SMART PROJECTS S.r.l.”.

Adafruit / Arduino.cc

Here is the order information from that purchase. For more info, see the Hackaday post Your Arduino Packaging Could Sway a Court Case and the Adafruit post Please post old Arduino packaging that says “Manufactured under license from Arduino” #TeamArduinoCC.

2015.03.29

When last we discussed rotary encoding, it was all experimental. Since the project (which will eventually be revealed) is complete, I figured I should share a bit more about the exploration and final solution.

Encoding Disk

I moved from printed paper disks to laser-cut disks. I cut some 3mm Baltic Birch plywood at Milwaukee Makerspace. They worked well, but since I was hoping to get more steps/resolution I continued with the paper prototypes as well.

Encoding Disk

The one in the photo above was a bit too fine… too many steps. The more steps the more precise the alignment has to be, and the more chance of errors.

Gap

We had some concerns about a disk spinning between a U-shaped sensor with just a few millimeters on each side, so rather than just go with the GP1A57HRJ00F Photo Interrupter, I started experimenting with the QRD1114 Optical Detector / Phototransistor as an alternative.

Sensors

The idea would be to use a wider disk and instead of it spinning between two pieces, it would have the encoding stripe on the edge, and the sensors would be on the outside of the disk. Back to the breadboard! The QRD1114s require a pair of resistors to work properly, so I wired it up and did a few tests and things seemed to work.

Encoding Strips

My first tests just involved sliding a piece of striped paper across the sensors, but I needed a real disk. I used the laser cutter at Brown Dog Gadgets to cut some disks from 1″ pink foam, and also from 1/4″ foamcore board. The pink foam actually ended up with concave sides due to the melting power of the laser, so I used the foamcore board pieces stacked up.

Stripes

Math time! How long of a strip do we need to wrap around the disk? Well, you can determine the circumference of a circle if you know the radius or diameter. Hooray for math! Above is a letter size file that I could print on a laser printer to produce the stripes I needed. The thin line on the right side was used for alignment since I had to use multiple stripes to wrap around the disk.

Encoder

Here’s a sneak peek of what the final disk looks like. There’s a few more steps before we got this far though, so I’ll continue the story next time.

« Older Entries |


buy the button:

Buy The Button

top recent artists: