Showing posts with label adafruit. Show all posts
Showing posts with label adafruit. Show all posts

Tuesday, August 18, 2015

@MAKE #Electronics Experiment 32: Robot Cart

I'm ready to start on this. First step was to gather the materials.  The parts list on page 268 is incomplete, although on p. 276 there's a "you will also need..." See the schematic on p.277 and this blog post by +James Floyd Kelly  (it's on experiment 31, but references shopping for 32). The 50K potentiometer shown in the schematic controls the time the motor runs in reverse before going forward again.
Make: Electronics by Charles Platt, Figure 5-98. p.277 (in the edition I have)

Also, the erratum on p. 277 mentions adding a diode or transistor. I'm going to try a diode (handsonelectronics says diode).

I found that my DPDT relays on hand are not appropriate. Some are latching relays bought for experiment 20, and the other was 12V, so I ordered two 5V DPDT non-latching relays from Amazon.

Charles spends a great deal of time on fabrication and not much on the circuit.  Since I care more about the circuit, and there are some issues with it, I'm going to build that first. I'm going to try to use plastic for fabrication. I have some 12"X12" pieces of ABS, and the shell of a multi-function printer that I tore-down.

Here's the concept:
When switched on, the cart moves forward until one of the microswitches hits something, it cuts power to 555 Trigger Pin 2, causing the the Output Pin 3 to pulse the relay, which then flops, reversing voltage to the motor, which reverses. The timer cycle (determined by 555 Threshold Pin 6 and Discharge Pin 7 as powered by the capacitor/resistor combination along with the Pot). When the cycle ends, the Output Pin 3 goes low and the relay flops back, causing the motor to reverse again (making it go forward).

The time it reverses starts at ~5 seconds (47uf cap*100000Ohm resistor = 47//1000000*100000 = 4.7). The Pot did not make much difference, if any. I thought it did, but it turned out that I had unhooked the 100K resistor. DUH.

I had other DUH moments in this, but I was helped immeasurably but people running into the same problems I did, particularly +James Floyd Kelly .  Thank you James. First, I bought a 5V gearmotor from robotshop .com. I fussed around for way too long trying to figure out how to wire it--then I noticed the two copper tabs on the neck.  Second, I was getting weird buzzing from the relay, and the motor was not reversing. I remember the symptoms from James' blog. My relay had different pinouts from the schematic. There are 8 pins. If you number them 1-8 starting with 1 at upper left and go counter clock-wise, I needed to switch pins 2 and 3 on one side and 7 and 6 on the other.  I could not find a datasheet for this relay, but I had a similar issue once before with another DPDT relay, so I guessed.

Third problem was the diode,  The motor would not reverse, but fortunately I had seen this before (thanks James), so I added the diode across pins 1 and 8 of the relay with the cathode towards pin 8.

I also struggled with wiring the switches.  I tested it with just the switches, power supply, and a meter, and came up with:
555 Trigger Pin 2  to switch1 NO prong, connected to switch 2 NO
Both NC Prongs connected to GND
Both COM prongs (on the side--at least on mine) connected to GND

If neither switch is pressed, current is flowing to the trigger pin through the 10K pull-up resistor making it high and thus the output pin is low. When either switch is pressed, the trigger pin goes low, making the output pin high, and flopping the relay and reversing then motor.  The output pin stays high until the 47uf capacitor dishcarges (4.7sec) to the threshold pin, making it high and setting the output pin back to low, flopping the relay back and the moving the motor in the original direction.

It works.  Here's the video.

Wednesday, July 1, 2015

@MAKE #Electronics Experiment 29: Filtering Frequencies Part II


Note: first, apologies to +Eric Buijs who noted that the TEA2025B runs hot at 9V.  I either did not notice or did not perceive that in part 1. However, in part 2 I experienced the same thing. Using an adjustable wall wart, I was able to apply different voltages.  9V works best, but it runs at safer temps at 7,5V and 6V. Besides the heat, the biggest difference is the volume coming out of the speaker (see video at link below).

Part 2 of this experiment involves adding a 555 timer in astable mode (with resistors and capacitors) and two pots: a 500 Ohm for volume control (between output pin 3 of the 555 and the input of the TEA2025B) and a 100K to manipulate the waveform (between 555 discharge pin 7 and threshold pin 6). I skipped the buttons for this exercise, and connected it with each filter and with no filter at all. The differences are discernible.

I did not have a 500Ohm pot, so I used a 1K.  It really only worked as a volume control at 9V.

Charles says to disconnect the audio source and use the timer as input to the amp.  I also added my cell phone playing Pandora back in.  It works for that, too.

A very worthwhile experiment. I'm looking forward to doing more with audio.

Here's the video.

Saturday, May 16, 2015

Twinkling Daffodils Based on Adafruit Neopixel Tiara (As Seen On Adafruit Show-and-Tell)

This was a fun project.  The final tiara project its for my granddaughter's pre-school graduation. I would have done a mortar board, but I think it might be unseemly for a 5-year old to wear a tricked-out costume in her procession, so I decided on a tiara that should could wear at family events to celebrate her accomplishment.

Rather than the headband plus wires in the tutorial, I decided to buy a tiara and add the neopixels to it.  I looked all over Michael's, AC Moore, ToysRUs, Itzaparty, etc, and found nothing suitable, but I found this online and bought 2 so I'd have one for backup.

Meanwhile, I was preparing for our local "in-Bloom" festival and decided to see what I could do with fake daffodils. That same day (but I had the idea first) Wearable Wednesday had a floral bouquet project, so I knew I was on the right track. It turns out fake daffodils are hard to find, but AC Moore had a fake potted plant.

Here's what I bought to add neopixels to

I'm in this to learn, and I was not disappointed by this project.

What I learned (or at least some of it...some things re-learned)

Screen shot from video re tiara on a breadboard
That's a 3V Trinket with 4 neopixels connected to 3V pin on Trinket via breadboard
Powered by a DIY 5V regulated power supply
  1. See my post on setting up the neopixels on a breadboard...that was the initial test. I got it going with 4 neopixels, both a Gemma and a 3V Trinket, and some alligator clips
  2. I wanted to add colors to the code supplied.  The comments are pretty clear:  
    // Here is where you can put in your favorite colors that will appear!
    // just add new {nnn, nnn, nnn}, lines. They will be picked out randomly
    //                          R   G   B
    uint8_t myColors[][3] = {{232, 100, 255},   // purple
                             {200, 200, 20},   // yellow
                             {30, 200, 200},   // blue
                              };                   
    // don't edit the line below
    #define FAVCOLORS sizeof(myColors) / 3
    However, I was not sure about the  [][3] construct (i.e., not specifying one dimension of the array).  Some Googling revealed that if the array is initialized, the dimension can be omitted. This one is initialized, so all I had to do was  more colors (more rows of {R,G,B}). The comments in the example code say that, but not why.  I have been programming for 40 years in a variety of languages, so arrays are very familiar--sometimes I just have to learn the details to apply them with understanding. So, I added 5 colors.  
  3. The tiara example shows the neopixels powered from the 3.3V pin on the Gemma, and that works with both a Gemma and a 3V Trinket. The Adafruit Neopixel Uberguide says to always power neopixels separately from the power pin on the microcontroller, and that they need 5V. As far as I can tell the guide is accurate, but for projects using a few neopixels from a Gemma or 3V Trinket, powering from the 3.3V pin works. The guide also says not to use alligator clips, but I didn't have any trouble with them for testing.
  4. The Uberguide says to add a 1000uf capacitor across the + and - pins of the power supply, and also a 300-500Ohm Resistor between the data pin and the first neopixel.  I will reserve that knowledge for future projects. Becky's tiara tutorial does not mention this, and the circuit works without them. Just for grins, I will add the cap and resistor to the daffodil circuit.
  5. Further, the guide says that if you're using a 3V microcontroller and power the neopixels from a 5V supply, you need a logic level shifter. I decided to stick with the tutorial for the tiara (3V Gemma with neopixels connected to 3.3V and GND on the Gemma), but for the daffodils I will use a 5V Trinket to avoid the need for a level shifter, and power the neopixels from power rail. not the 5V pin on the Trinket. I was going to power the circuit from  my 5V regulated power supply, but that adds an extra component, so I'll just solder a barrel jack on the perma-proto and use a 5V wall wart (I'd need power anyway to power the 5V supply). I'm using the Adafruit Compact Switching Power Supply.
  6. After fussing with ideas about an enclosure, I decided that I didn't need one. The circuit is very simple, and I don't need a lot of internal connections. So, I'm putting it on a small mint tin size perma-proto, with a barrel jack for the connection to power. Since the power rails are down the center, I can place the trinket horizontally across the board, with the BAT and GND pins over the power rails, supplied by the barrel jack.  Since pin #4 is next to GND, I can modify the data pin in the code and connect DATA, GND, and Vcc to header pins to connect to the 3-wire connector and on to the daffodils.  That's it.  I will put 3/4" standoffs on the 4 corners of the perma proto to provide clearance.I don't need to solder anything other than the 3 wires to the Trinket...that will make it easier to reuse.
  7. Speaking of the 3-wire connector, I found some, labeled B2-2832, that I ordered a while back, I don't remember from where. Googling the number doesn't yield anything useful. Anyway, it simplified the wiring a lot.  I'll cut it in half, use the receptacle end to attached to  the Trinket pin and power rails, and solder the other ends to data. power and ground coming from the circuit.  I'll put the resistor in the connection on the data wire. 
  8. I had originally planned to put the neopixels inside the corona (trumpet part of daffodil). My wife, who understands crafty stuff better than I, suggested just positioning the neopixels outside of the flowers, to let flowers diffuse the light. This turned out to look better, and also simplify the project.  I would have had to clip out the flowery stuff inside the corona (fake pistil, stigma, and anther), poke holes in the corona for wires, and solder the inter-flower data wires and heat shrink on the flower.I made more work for myself because I started out with the original design in mind, but the tutorial reflects the improved process.

Finished Product

Parts, Supplies, and Tools

  1. Barrel Jack
  2. 5V Trinket
  3. 1000uf Capacitor
  4. 470 Ohm Resistor
  5. Breadboard (size not important, I used a half-size)
  6. Silicone-Coated stranded wire
  7. 22-gauge solid core hookup wire
  8. Heat shrink tubing
  9. 3-wire connector (optional, here's an example for illustration--or use what you have)
  10. header pins (also optional, but it made it easier for me)
  11. flora neopixels V2 (6) (I bought this sheet of 20--they also come in quantities of 4)
  12. small mint tin size perma proto-board
  13. 3/4 inch nylon standoffs & screws (4)
  14. 5V or switchable wall adapter
  15. Short alligator clips
  16. In-line power switch
  17. Fake daffodils in fake flower pot (you're on your own here--I found mine at AC Moore, try Michael's, etc.)
  18. Green florist's tape 
  19. Soldering Iron and requisite accessories--solder, stand, sucker, helping hands, etc
  20. Multimeter
  21. Flush Clippers
  22. Heat gun 
  23. If you really want to finish it off, put it in a suitable encosure and drill holes for power input and output to flowers--I did not do that

Construction/testing process

Note: this project could be accomplished without soldering, but it would not be as tidy, and you would need clips, and/or solderless wire connectors and/or a larger Arduio (like an Uno) to make connections via jumber wires. Making reliable connections to neopizels without soldering is tough. It's easy soldering, though.

1st neopixel soldered
Red to power, black to ground, white to data pin, yellow to next neopixel
Neopixels wired and ready for test

  1. See Fritzing diagram above.  The circuit is really simple, but the construction has a lot of steps, so...the first thing I did was verify that the above circuit works with a 5V Trinket, external power, and one neopixel.  (Note, this requires modifying the Adafruit NeoPixel_Tiara sketch to use just 1 neopixel.  See above for other possible changes--colors and timing, for example).
    That was fine, so I added the cap and resistor and that was also fine. As expected, but it's good to start with something that has been proven to work. Note that I recommend a lot of testing as you go through the project. It's a lot easier to find and fix problems as you build, rather than trying to figure out where you went wrong after the project is all put together.
  2. Next step, build up to a pre-assembly test.
    Solder + and - leads to neopixels in the lengths we'll need to go from the flowers to the circuit. Watch the data arrows on the neopixels--take care to match output of one to input of the next.
    Solder leads to BAT, GND, and pin 4 on the Trinket, in the lengths you'll need to connect to the perma-proto when you're ready.
    Using alligator clips, connect all the + wires to the power rail, all the - wires to the GND rail, the data wire to the resistor, and the other data wires to each other, and also to connect the Trinket pins to the + and - rails and to the resistor
  3. Fire up the circuit for a test (still on the breadboard). Make sure all the neopixels light up. If you want different colors, more or less colors, or different speed, change the code (see below). If it doesn't work, there are probably some missed connections or bad soldering.connections.  Check the direction of the arrows on the neopixel data pins. Keep the Trinket connected for the next test. Here's a video of this step.
  4. Now we're ready for the flowers.I had orginally planned to put the neopixels in then corona (the trumpet part).  My wife convinced me that the flowers diffusing the light would be a better effect, so I changed the design.
    Run the power wires, and the data wire to the 1st neopixel, down the stems and secure the wires to the stems temporarily. I used plastic twist ties. Continue the wires down the pot to join together in a common location at the bottom.Twist the + wires together for a power connection and the - wires together for the GND connection.
  5. Test
    Connect the flowers to the circuit on the breadboard again using alligator clips. If you left the Trinket connected it should be all set. Power it up verify and correct as before.
  6. Final Assembly
    a) Remove the alligator clips. [Making sure to check that the out arrow from one neopixel will be wired to to the in arrow of the next, put heat shrink wrap on one side of the data connection between flowers, solder the two sides together, move the head shrink over the connection and shrink with a lighter or heat gun.  Repeat for all 5 inter-flower connections. ] Not necessary if you connect directly, per new design.
    b) Solder the barrel jack to the perma-proto board. Plug the wall wart into the barrel jack and test the pins of the jack with a multimeter to be sure a) that the connections are sound and b) that you know which pin is + and which is -. With the multimeter on DC voltage, the reading should be about +5V. If it is not, there is a bad connection. If it says -5V, the meter leads are reversed.  Solder the + pin of the jack to the + rail (the one with the red line on it) on the perma-proto, and the - to the GND rail (blue line) using a short insulated wire.  The jack should be connected to holes that are part of the rail (i.e. with vertical interconnections--the first holes are not connected to the rail. (see photo)
    c) Solder a 3-pin header to horizontally across the power rails. One pin will be +, one -, and the one to the side of the rail will be connected to a perma proto row (holes horizontally interconnected).
    d) Solder one side of the 470Ohm resistor to the row the header pin is connected to, and the other side to the row to which you will connect the data wire (pin 4) from the Trinket.
    e) Solder the 1000uf capacitor across the power rail (watch the polarity: +pin to +rail, -pin to -rail)
    f) For stability, I attached a five pin long header with the plastic stopper above the perma proto through to female headers.  The holes that the top of the perma-proto are not connected to anything, and I did not solder this--it's just to hold the Trinket in place so I can reuse it easily.
    g) Place the top row of holes on the Trinket over the header pins from the last step. Solder the Trinket leads: BAT to + rail, GND to - rail, Pin 4 to the row the resistor is on.
    h) If the 3-wire connector has plugs.jacks at two ends, cut it in two pieces. You want the jack (female) end, so it will fit over the 3-pin header. Using alligator clips, connect the data, power, and ground connections to the 3-wire connector. Plug the connector to the header, and test. If there are problems, check all connections (and that you have powered the circuit).
    i) Using heat shrink wrap as with the inter-flower connections, solder and heat shrink the flowers to the 3-wire connector (taking care that the correct wires are connected).
    Here's a video of the circuit working from the perma proto...I just need to hide the wires and position the neopixels and finish soldering.
  7. Finish
    Test
    the final connection, and correct any problems.
    Remove the temporary twist ties, or whatever, from the stems, and wrap the wires and stems together with green florists tape.
    I wanted to be able to power on/off without unplugging, so I added the in-line power switch. I also added a second 3-wire connector as an extension.
    You're done

Bottom of perma-proto
Note vertical and horizontal connections

Top of perma-proto
Notte power rails in center

Perma-proto bottom, after soldering
Top view after soldering










Code (NeoPixel_Tiara by Adafruit, as modified by Virgil Machine)


/Random Flash animation for Neopixel circuits
//by Dano Wall and Becky Stern for Adafruit Industries
//based on the Sparkle Skirt, minus the accelerometer
/*2015-05-10 vm Daffodil project
Nneopixels in 6 of 11 fake daffodils in fake pot.
Designed for "Brewster in Bloom", advised by Becky's LED Bouquet project.based on the neopixel tiara project.
Uses 5V Trinket with pixels powered directly from power rails (not 5V pin on Trinket).
Powered by 5V Regulated power supply, which can be powered by wall wart or battery.
2015-05-10 */
#include <Adafruit_NeoPixel.h>

#define PIN 4  //2015-05-11 changed from pin 1 to pin 4 for ease of connection

// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) 2015-05-10 vm we're using Flora neopixels v2
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
//2015-05-10  changed parameter 1 to 6 for 6 neopixels in daffodils
Adafruit_NeoPixel strip = Adafruit_NeoPixel(6, PIN, NEO_GRB + NEO_KHZ800);

// Here is where you can put in your favorite colors that will appear!
// just add new {nnn, nnn, nnn}, lines. They will be picked out randomly
/*2015-05-09 vm note the [][3] specifying the dimensions of this 2-D array
1st dimension (number of rows--colors in this case--is empty, which is legal
as long as the array is initialized in-line, which this is.  The second dimension, the columns,
is the RGB components. We can add a row (color) without changing anything else. I added 5 clors
to the purple, yellow, blue that were supplied in the example.
Line 40, declaring FAVCOLORS, calculates the # of colors using the size of the initialized array.
Line 58 gets a random number between 1 and FAVCOLORs do decide which color to use, at random
2015-05-09*/
//                          R   G   B
uint8_t myColors[][3] = {{232, 100, 255},  // purple
                         {200, 200, 20},   // yellow
                         {30, 200, 200},   // blue
                         {(0,255,255)},    // cyan
                         {(255,69,0)},     // orange red
                         {(0,255,0)},      // lime
                         {(255,0,255)},    // magenta
                         {(255,0,0)},      // red
                          };
                             
// don't edit the line below
#define FAVCOLORS sizeof(myColors) / 3

void setup() {
  strip.begin();
  strip.setBrightness(40);
  strip.show(); // Initialize all pixels to 'off'
}

void loop() {
flashRandom(15, 2);  // first number is 'wait' delay, shorter num == shorter twinkle 2015-05-08 vm changed this to 15 from 5--better for flowers
flashRandom(15, 4);  // second number is how many neopixels to simultaneously light up 2015-05-08 vm changed this to 2-4-3 from 1-3-2 for grins
flashRandom(15, 3);
}

void flashRandom(int wait, uint8_t howmany) {

  for(uint16_t i=0; i<howmany; i++) {
    // pick a random favorite color!
    int c = random(FAVCOLORS);
    int red = myColors[c][0];
    int green = myColors[c][1];
    int blue = myColors[c][2];

    // get a random pixel from the list
    int j = random(strip.numPixels());
 
    // now we will 'fade' it in 5 steps
    for (int x=0; x < 5; x++) {
      int r = red * (x+1); r /= 5;
      int g = green * (x+1); g /= 5;
      int b = blue * (x+1); b /= 5;
   
      strip.setPixelColor(j, strip.Color(r, g, b));
      strip.show();
      delay(wait);
    }
    // & fade out in 5 steps
    for (int x=5; x >= 0; x--) {
      int r = red * x; r /= 5;
      int g = green * x; g /= 5;
      int b = blue * x; b /= 5;
   
      strip.setPixelColor(j, strip.Color(r, g, b));
      strip.show();
      delay(wait);
    }
  }
  // LEDs will be off when done (they are faded to 0)

}

Friday, May 8, 2015

Adafruit Neopixel Tiara on a breadboard

I decided to make the Adafruit Neopixel Tiara.  I have ordered some tiara's (plural to allow for error), and will fix the gemma and neopixels to it.  When I was thinking about it my town was getting ready for the annual "Brewster in Bloom" festival, which features daffodils, so I decided to see if I could do a similar project using fake daffodils.  The same day Becky Stern has a neopixel boquet project with fake flower on Wearable Wednesday. So, I figured I was on the right track.



After I got the products, I decided to test everything on a breadboard.  I soldered headers on one of my 3V Trinkets (I'll use a Trinket for the daffodils).

Here's the video

More after I start building.

Tuesday, March 17, 2015

@MAKE Electronics Experiment 21: Game Show Button Controller

After the last experiment this one is pretty straightforward. One 74HC32 quad OR chip, 2 timers, one SPDT switch, 2 tactile buttons, 2 LEDs, 3 10K resistors, 2 330 Ohm resistors. The wiring's the thing.

I couldn't get it to work at first, but it was just a loose connection. That, and my "breadboard-friendly" SPDT slide switch wasn't so breadboard friendly. I had to bend up the tabs on the side to get it to fit the breadboard at all, and the legs still weren't long enough. But it works.

Anyway, the switch is for Art Fleming to activate and deactivate the contestants buttons.  The buttons are tied to Vcc through a pull-up resistor. A jumper from one side of the switch to the side of button 1 1 not connected to Vcc and then a second jumper from there to the corresponding button on button 2. The other side of B1 goes to OR Gate1, input 1. The same for B2, the corresponding side goes to OR Gate 2, input1.  Both input2s are connected to Gate3 output. Gate3 inputs are connected to the output pins of the 555s.

So, in order for the output of either 555 to go H, the input on trigger pin 2 must be L. The trigger pins are tied to the outputs of OR Gates 1 and 2.  OR output is H if either input is H.  One input is tied to 555 output, which is L until triggered by it's corresponding OR Gate. Button outputs are H if no action is taken, so the 555s are not triggered. When a button is pushed, the voltage from the button goes negative, making both inputs L, and the corresponding output L, thus triggering the corresponding 555 output. Both 555 outputs are connected to LEDs, so the LED lights and stays on until reset.  Once one 555 output is H, Gate 3 output is H, and neither button has any effect because the corresponding outputs will be H.

When Art Fleming activates the contestants buttons and asks a question, the first contestant to press the button lights his/her LED and locks the other contestant out.  The other side of the slide switch is connected to the 555 reset pins (4), so when Art slides back the LED turns off.  When he's ready for the next question, he flips the switch back and the cycle repeats.

Here's the video.

Saturday, February 14, 2015

Friday, February 13, 2015

Happy Valentine's Day

I've been fascinated by electroluminescent wire (EL wire) for a while. I just needed a project in which to include it.   I got the idea for heart-shaped glasses for Valentine's Day and that seemed like the perfect fit.

I bought the Adafruit EL Wire starter pack in red and I was off and running.

I convinced myself that I needed 2 sections of EL Wire, 1 for each heart, but I wised up and did it with just one. The challenge was the crafty part (cutting hearts, sewing, the hearts to the cardboard, etc.

My original plan was to hot glue the hearts to some old glasses, but I found out that they work fine as an overlay to my regular glasses.


This was fun to do. I'll use EL wire again.  Here's the video.

Monday, January 19, 2015

Mario Question Block from @adafruit - Final(?)

It's finished. See video

The final steps were:
  1. desolder the floating wire on the LED+
  2. desolder the GND wire, cut it to the same length as the + wire, resolder
  3. cut wires to go from LED1 to LED2
  4. solder LED1+ to LED2+ and LED1- to LED1-
  5. uncscrew the Piezo, drill the holes to expand, and refasten
  6. use tack to fix the backpack on the Trinket
  7. place the switch in it's holder
  8. mount the Trinket (this was not great--the screw head strips, but I got enough in to hold it)
  9. close it up (this was hard, because there's a lot of stuff in there and the cover still does not fit perfectly, but I got it)
This was not +Adafruit Industries' greatest tutorial.
  1. It says that the LEDs should be connected in series when only a parallel connection works
  2. There is no mention of the battery--where to position it, etc--the answer apparently is "stuff it in any way you can."
  3. The wiring diagram shows all wires coming out of the top of  the Trinket. Some must come out of the bottom. There is no mention of that in the text.
  4. The stuff about tolerances for 3D printing was not obvious (to me which is OK because I don't know anything, but it was also not clear to the 3D printing service I used)
But, it's done. On to the next project.

Sunday, January 18, 2015

Mario Question Block from @adafruit - Part V

I got the LEDs to work.

  • I verified all the other connections
  • I tried a 5mm LED in the circuit instead of the LED sequin I desoldered--no change
  • I put the LED sequins in series on a breadboard, powered by a 5V 1500mA wall wart--they both lit
  • I checked the datasheet for the LED sequins, Max forward current is 25mA. Average forward voltage is 3.4V at 20mA.
Trinket Pin #4 puts out 20mA.  I'm not sure there's enough juice juice to power the LED sequins in series.  Everything I've read says to put them in parallel, but I'm going by the instructions in the tutorial. I never got a response to my query on the Adafruit Support Forum.

However, I wired the LEDs in parallel as opposed to series, and they both light. I have given feedback on the tutorial.

Next: put it all back together and wear!


Friday, January 16, 2015

Mario Question Block from @adafruit - Part IV

I drilled the hole in the case for connecting the Trinket.  From the webs, I ascertained that I needed about a 1/16" bit (.0625 for a .067 screw).  That worked. I was able to attach the Trinket, but I'm holding off on the final solution until I get through some of the following issues. I got some 2-56 3/8" screws, Philips head, and they work much better (I replaced the screws for the Piezo, also).

I put my meter on the circuit (DUH--learning the obvious lesson: do this DURING assembly to assure the connections will work).

First, I verified what the switch was telling me--I did not completely remove the trace between the pads on the backpack, so the circuit is always open and the switch had no effect. It looked OK to me, but I did some more scraping and now it works.

Second, I checked the LED connections.  My meter showed continuity throughout.  Using alligator clips to jump various connections, I could get one or the other LEDs to light, but not both.  I desoldered one, and tried various combinations of connections with no luck. It occurred to me that maybe the battery did not have enough juice, but according to my meter it's putting out 3.96V, and it's rated at 3,7V. I also tried it connected via USB--no change.

Meanwhile, the Piezo wires came loose from the Trinket and I had to resolder.

I have posted a query on the Adafruit Support Forum about the LEDs. If I get an answer, I'll move on. If not, I may try it with 1 LED (which was the original design).


Sunday, January 11, 2015

Mario Question Block from @adafruit - Part III

OK. Problem 1 is that, despite +Phillip Burgess ' warning, I soldered the Piezo to the Trinket before I wired it correctly (in my defense, I did heed the warning, I just wired it wrong). I thought I knew which hole to pass the wires through, but after I did it I realized something was wrong.  Here's what that was:

  1. the tutorial is not crystal clear
  2. the hole I was supposed to used was partially obstructed by printing debris so I did not recognize it as a hole
  3. I did not pay attention closely enough
So, today's work:
  1. search local stores for shorter 2-56 screws
    I got 3/16" flat, slotted heads--the Phillips were beveled and did not provide enough thread (I would have liked more detail in the tutorial for this because I'm ignorant, but I got there)
  2. detach the Piezo and re-attach it with shorter screws (as noted in the last post, the ones I used were too long)
  3. deburr the hole for the Piezo wires
  4. cut the wires from the Piezo, string them through the newly deburred hole, and splice them to the other part of the wires connected to the Trinket
  5. tack the backpack to the Trinket
  6. cover the on-board LEDs with black tape (I know I have several rolls someplace, but in the interest of sanity I went back to the hardware store)
  7. screw the Trinket to the enclosure
  8. modify the diffuser so it will fit in the new cover  (also had to clean up the location for the diffuser--I guess I should have anticipated this, but I expected a cleaner print from the service--now I know why Charles Platt in +Make: Electronics wanted me to by a bunch of files and deburring tools)
  9. hook up the LiPo and charge it
  10. test and rework as required
However, I have some serious problems.
First, the screw hole for the Trinket is filled in and I cannot get it to screw in.  
Second, the switch does not turn the circuit off--I have to disconnect the battery. I followed the instructions on clearing the connection between the holes on the backpack--maybe I did not get it right.
Third, the Piezo chimes, but the LEDs do not flash. The connections look right to me.

So, I have more work to do.

Saturday, January 10, 2015

Mario Question Block from @adafruit - Part II

When last we saw this, I was waiting to get replacement 3D printed parts back from the service I used. The first print was missing the handle and the cover did not fit. New parts arrived yesterday.  It has the handle, and the cover fits. I'm a little disappointed because I started this about 6 weeks ago, but I'm ready to go. I'll put on my white lab coat and get to it.

The first thing I tried to do was upload the code to the Trinket (so I will have when I get the product assembled).  After I located a mini-USB cable I found that I forgot to update my Arduino IDE (I knew that because I got "PLLCSR not defined in scope" etc. on compiling).   DUH--I needed to set the board to Trinket 8MHz, but first I needed to update my hardware folder. Then, I went to upload and got my favorite avrdude messages.  DUH--I forgot to add some other changes. Of course, the Adafruit Learning System has all this spelled out here.  I'm sure I saved some frustration later on when I'll be anxious to try this out.

Later that day...
The good news is that my new soldering iron and heated solder sucker work really well. I made it mostly through the project, to get here:
I got the soldering done, following the tutorial I had one issue: the first diagram shows all the wires from the backpack coming out of the top. That's wrong: the wires to the slide switch come out the top, but the 5V, BAT, and GND wires go out the bottom. So, I got out the new solder sucker and re did them.  I am supposed to attach the backpack to the trinket with tack...I need to redo that.  I also need to fix screw the trinket to a standoff.  T

Also he only 2-56 screws my local hardware store had were too long too attach the piezo. I can make do until I get a shipment from sparkfun next week. 

The only other problem I have is that since my frindly 3D printing service did not re-print the diffuser, it doesn't fit. I'll had to do some modifications..  

I should get back to this tomorrow.









Thursday, January 1, 2015

Great things in 2014

Here are some of the great things that happened in 2014 (maybe the best year ever):
  1. I found Adafruit!
    +Adafruit has made my life better. Through this company have have learned more than I imagined I could, and watched and participated in multiple internet shows (4 appearances on Show-and-Tell, a question answered on air on Wearable Wednesday).  My questions on the support forums always get prompt, clear, informative responses. Adafruit is a community more than a company, and I am really happy to be a part of it. AND--I love their products, too.
  2. My electronics projects (and learning to solder)
    I asked for and received a bunch of electronics stuff for Christmas last year (+Arduino, books, etc.). In addition to Adafruit, I got help from +JeremyBlum 's tutorials, and Charles Platt's book "+Make: Electronics." 
    I constructed a bunch of circuits for learning purposes, and will get back to that next year. I also recruited my former (and now current) boss to teach me to solder once I could go no further without soldering.  I'm now have adequate soldering skill. I plane to learn to solder surface-mount components next year.  Some highlights:
        .  In an early success, I could not get the component I needed for Jeremy Blum's tutorial #8 involving digital potentiometers. His spec was for a quad from Analog Devices, but I could not find one.  I got 2 duals from Microchip Technologies.  I ran into trouble following the datasheet to daisy-chain the 2 devices. In the process, I learned about schematics and Eagle CAD. I sought help on the Arduino Forum , but did not get an answer.  Finally, I went to Microchip tech support, and after a phone call I got the answer I needed to get it to work.
        .  The Adafruit candle-flicker hair bow for my granddaughter. She loved it. I made one for my daughter, too. She was less impressed.    . An exhaust fan for soldering using a case fan from an old computer, scrap wood for the frame (it's what I had), some brackets and screws for mounting, a toggle switch, a potentiometer to make it variable speed, a power jack, and a 12V power adapter from a dead laptop. I use it every time I solder.    . A useless flashy thing from the Charles Platt book--taking it a step further by putting it in an enclosure and adding a toggle switch.
        . Talking Halloween Candy Cauldron (see entry on this blog)
        . The Head Move Donkey--also on this blog
  3. My granddaughters continue to be wonders
    Nora loves "playing electronics with Grandpa," including  the candle flicker hair bow, "the E is for Electronics coloring book," and the Adafruit videos (which she calls "Adabot Videos"). We made a lemon battery that she thinks is really neat.
    Frankie turned one this year.  We had the great fortune to have her here for over two months in the summer, including her birthday, and got to see her learn to walk.
  4. My daughters and their husbands are great
    I am very proud of all of them and all they have accomplished.  What a blessing!
  5. Our trip to Canada
    I have always wanted to see the Maritimes, and we were able to go to Prince Edward Island, returning through Maine with a stop in Bar Harbor, where we honeymooned 43 years ago.  It was wonderful.
    PEI was beautiful and peaceful, just the break we needed form Cape Cod in July/August.  Bar Harbor was crowded, but the hotel we stayed in kept us out of craziness, and there was good public transportation into town.

Friday, December 19, 2014

Mario Question Block from Adafruit Part I

This is my next project, from a tutorial on the Adafruit Learning System.  I enjoyed working with the Pro Trinket in the Donkey project, so I thought this could be interesting.  Also, the enclosure is 3D printed, and I am intrigued by 3D printers, so that was a draw.

I found a local 3D printing service through http://www.makexyz.com/ and this is what he produced:
It's pretty good. The top does not fit right on the body, so I'll have to do some modification, and it's not as clean as I'd like, but I'll work with it.  It cost $20 for the print, including mailing it to me, plus $3 for the service.  When I get the time, I will do the modification to the enclosure and the construction. I have the parts, so it should go OK.

Here's what I've learned so far:
  • At first I thought the print was backwards, because I was comparing what I got with the photos in the tutorial. However, when I took a photo of the print to send to the guy who printed it, I realized that the photos reverse the image...so I'm believing that it's OK.
  • In all the photos in the tutorial, it looks like the handle is part of the print. The printer said no, then I read the fine print in the tutorial and it said "attach a handle--you figure out how."  But, the handle DOES seem to be part of the print.
I have posted questions on the Adafruit Support Forum.  When I get some clarification I'll pursue this further. Meanwhile, I'm kind of stuck.

More when I get to construction.




Friday, November 28, 2014

The Head Move Donkey



In 1978, I bought a wind-up donkey for my daughter, then an infant. The donkey moved its head while playing “Donkey Serenade.”  I figured that I could replicate that with an Arduino, a motor, sound on an SD card, and a speaker.  It took me 10 weeks, but I did it. Here’s the story.

I got sidetracked for a while doing my Halloween Candy Cauldron, which came out of this one. While I was working on the donkey, learning about playing sound with an Arduino, I began seeing lots of Halloween projects on Adafruit shows, so I decided to try my hand on Halloween sounds.

This was an incredibly rewarding project that was challenging, fun, interesting, and educational—all the reasons I wanted to start with Arduino in the first place!

Here’s a video, and another pre-completion, and there are links to two appearances on Adafruit’s Show-And-Tell under “Resources” below.

Parts List (about $80 in parts done this way, assuming you have all the tools and supplies)

2.1mm power plug and jack (doesn’t matter what you get as long as they match)
Micro SD Card
Speaker (I used a 2” 8ohm speaker from an MFC printer I took apart)
Sound editing software, like Audacity
Hook-up wire (I used 22 gauge solid wire to connect the speaker, and to run from the terminal block on the PWM board to the power connector because that was easier
Adafruit silicone-coated stranded wire in various colors (very flexible--helpful for connections inside the enclosure)
Header pins (male, female, and right-angle)
Soldering iron and accessories
Heat Shrink tubing
Dremel or similar tool for cutting out the stand-offs on the enclosure
Drill and bits for making holes in the enclosure (1 for the power jack and 1 for the wires to the speaker and servo)
Electrician’s tape to keep stuffing out of the wire hole
Sewable Velcro strips for closing up the donkey
Needle and thread

Step 1:  play music
First, I located and downloaded the song from http://www.mp3olimp.net/donkey-serenade/ .
Using a Seeed Studio SD shield, the TMRpcm library and this tutorial (http://www.instructables.com/id/Playing-Wave-file-using-arduino/) I was able to play the song. Note the need for specific sound file format, that’s where Audacity came in. I also shortened the song to delete a couple of the more jazzy parts.  Nothing against the music, but this is a child’s toy. The sound needed amplification so I tried the diy amp from http://vcctoground.com/tutorials/simple-pocket-audio-amplifier/   but did not get much improvement (NPN and PMP transistors, etc.).

Step 2:  operate servo
I had a micro servo and an example from Jeremy Blum’s tutorial (http://www.jeremyblum.com/2011/01/31/arduino-tutorial-5-motors-and-transistors/) and got that to work fine.

Step 3: put it together
I could get the servo to move or the music to play, but not both. With help from Adafruit support (https://forums.adafruit.com/viewtopic.php?f=25&t=59793), buying a PWM breakout board (https://www.adafruit.com/product/815), and some soldering, I got it to work. The problem was a timer conflict.

Step 4: getting small
I asked Becky Stern, Director of Wearable Technology at Adafruit, for some advice on getting all this in a donkey. She answered my question on Wearable Wednesday (~21:30)!  I also needed to change some components. First I swapped out the Arduino Uno for a Pro Mini 5V (I thought).  Next I bought a microSD breakout to replace the shield. The Micro SD runs on 3.3V, so I thought I needed a voltage regulator and maybe something else (http://forums.adafruit.com/viewtopic.php?f=19&t=60813 ).  In the process I found out that the 5V pro mini was really a 3.3V, and figured out that that was really what I wanted (power the Pro Mini, the amplifier, the PWM board, and the servo from the battery, and power the SD from the Mini).

Step 5: refine
I figured out how to play the song in a loop without resetting the Arduino (TMRpcm.loop(1)). In the process of doing all this I cooked my Mini—it won’t put out 3.3V anymore (more like .9V) so I’m back on the Uno until my 3V Pro Trinket comes next week.  I also decided to go with a 6V coin cell holder with switch (https://www.adafruit.com/product/783 ) for power.  I gave up on the amplifier and put in an LM386 circuit.  It works OK, but I also ordered an amplifier breakout (https://www.adafruit.com/product/2130) just in case I can’t get the sound I want out of a smaller speaker.

Step 6: construction
Donkey arrived 10/4/2014.  It will accommodate a small project box, servo, speaker, and battery holder. Now I need to be sure I can get the whole circuit on a board small enough to fit into the enclosure. The Altoids tin will fit in the donkey, but I also have a project box if I can’t get the circuit in the Altoids tin.
Programming the Pro Trinket was somewhat flaky at first. I needed to install the hardware updates for the Arduino IDE so it would recognize the board. Also, had to set the programmer to USBTinyUSB. When that didn’t work (“can’t find USBTiny”) I discovered I needed the Windows drivers.  After I got that all done I was able to upload the example blink program, so I’m in business, I think. Now I need to solder the headers so I can test the circuit. I have another Pro Trinket coming tomorrow, so I will use that for the real thing, soldering directly, but I’ll need this one with the headers anyway. UPDATE:  there may be an issue with the ProTrinket and device recognition on Windows (or at least my Windows systems).  I got it to work with Ubuntu, and in the process discovered that the upload took longer than the bootloader was active, so I have to wait to press the reset button to activate the bootloader, but leave enough time in the compile process for it to initialize.  Kind of a pain, but it’s working. I never did get it working on Windows 7 (that may be my fault), but it’s working OK on Windows 8 and Ubuntu.

Step 7: more construction
I tested the 6V coin cell battery, and the power lights on the boards come on but no music and no motion.  I need find another power source. I’m considering a 9V with a voltage regulator to bring it to 5V. A 4bXAA works (6V) but it’s big. Also I got the Adafruit mono amp, and it puts out more volume than the LM386. I also takes up a lot less space. Next, I got some SMT breakout boards (https://www.adafruit.com/product/1208) so I’ll see if I can solder the TSSOP-28 PCA9685 to it and save more space. That didn’t work—not skilled enough. I will try to make a DIY breakout. I shorted something and cooked my amp, just got new amps today and will try again. The servo moves but no music…hopefully the new amp will get me back where I was. The new amp fixed the problem. I decided to stick with the Adafruit PCA9685 PWM board because my surface mount skills are not there yet.

Step 9: The enclosure
I got a 4x2x1 enclosure from Radio Shack.  I fixed an Adafruit 1/8 size Perma-Proto Board to the enclosure with a screw, and drilled a ½” hole for a power receptacle and a 3/8” hole for the servo and speaker wires. In another 3V Pro Trinket, I soldered female headers to A4&A5 and Adafruit silicone coated flexible wires to the pins I need for the circuit. I put right angle headers on the I2C pins of the PWM board, so I can slide those into the female headers and have the bigger board flat with the Trinket on its side perpendicular to the PWM board. All the power and ground connections will go to the Perma-Proto Board + and - rails, with the power connector supplying those rails.  The power supply will be an Adafruit 4xAA battery pack with switch so there is an external switch  access to batteries for changing without opening the donkey, and less space to take up inside.

Step 10: new Trinket
I tried wiring up the circuit with the new, newly soldered Trinket. It powers up, and puts out 3.3V on that
Rail, but it does not play sound or move the motor. Either I did not wire it correctly or there is something wrong with my soldering.  More testing tomorrow.
The next week:  I wired it up again.  After some fussing with connections I got the whole thing to work. I spent some design time on the enclosure, so on to soldering/enclosing.

Step 11: The enclosure, part 2
Day 1:  I discovered that I could not fit the Perma-Proto board and the other components in the enclosure.  The next size larger is too big for the donkey.  Also, the internal stand-offs in the enclosure were in the way, so it was redesign time.  I moved the power connector/receptacle from the end to the side to give more room. I used my Dremel knock-off tool to cut out the internal standoffs. Now everything fits.  Without the Perma-Proto Board, I will need to connect the wires for power and ground directly to the connector. Next I got to soldering:
1.       I connected a 2.1mm jack (to plug into the power receptacle) to the battery pack and covered the splices with heat shrink tubing.
2.       I soldered new, solid core wire leads to the speaker.  Solid core works better in the terminal blocks.
3.       I connected solid core wire to the external power terminal block on the PWM board, and ran them under the board to the power connections.
4.       I removed the jumper wires from the amplifier, and soldered wires directly to the header pins.  The A- and GND wires to go to GND, the Vin to go to power, and the A+ pin is soldered to the wire going to digital pin 9 on the Trinket (SpeakerPin).
So far, so good. Tomorrow I’ll replace the six jumper wires on the SD card with direct soldered connections, and test the audio. Assuming that works, I’ll do the 4 remaining wires on the PWM board.

Step 11: The enclosure, part 3
It works!  Without the circuit board there was a lot of soldering. I soldered all the power leads together, two at a time, adding the next one in turn until I had one lead to connect to the power connector + lead, then did the same with the grounds, to the – lead.  I left the jumper wires on the SD board because they’re pretty secure and didn’t want to risk cross-connections due to sloppy soldering.  I did solder leads to the headers for Vcc and GND on the PWM board.  For the SD board, I cut and stripped the jumpers and connected them to the correct leads:
·         GND to the GND complex
·         3.3V to the 3.3V pin on the Trinket
·         SPI pins to the leads I already had soldered to Trinket pins 10-13
I used heat shrink tubing on the splices to protect the connections from touching.
Everything fits—I can close up the enclosure and secure it with screws. The music plays and the servo moves.
Tomorrow: open up the donkey.

Step 12: the donkey 1
I used an x-acto knife to cut the donkey’s belly along a seam, and took out some stuffing.  I got the servo in the neck, and it will turn the head, but I need to fix it to something solid so the horn of the servo turns the donkey instead of the donkey holding the horn while the servo turns. Meanwhile, I stripped the plastic gears on the servo.  This is the second servo I’ve ruined.  So, I ordered two new servos, one micro and one standard, both with metal gears from Adafruit. Hopefully one of them will do the trick.

Step 13: the donkey 2
I used the standard servo. It’s substantial, and it does the trick. I was able to close up the enclosure and screw on the cover with only one mishap: the ground lead on to the power connector broke and I had to de-solder/re-solder it.  I pulled more stuffing out of the head to get the servo in closer. It moves a little, but with more stuffing, it should be even better than it is now.  There’s a little interference from the servo (actually I think it’s from the PWM board) but it’s OK.
Next: sew on the Velcro and re-stuff.

Step 14: the donkey 3
First, I sewed on strips of Velcro that I had cut to the length of the slit in the donkey’s belly.  I’m not great at sewing, so it was a little frustrating, but I got through it.  Next, I tried different positions for the servo to get it to move the head. I re-stuffed the neck to try to keep the servo in position, placed the speaker, re-stuffed the rest of the donkey put the enclosure in and closed the Velcro.  After one more iteration to get the servo better positioned, it’s done.  I’d like more range of motion on the head, but it does move.

Step 15: futures
1.       I’d like to get more movement from the Servo. I have to experiment with different horns, different positions, and different programming.  I was time-limited on this one—I needed to have it ready for Thanksgiving Dinner, so I haven’t been able to pursue more options yet.
2.       I would shorten the wires inside the enclosure, and probably move the power connector to the end of the box (rather than coming up from the bottom). 
3.       I’d also like to find a box that fits the components a little better, and to fasten the boards to the enclosure (right now, they’re loose, and any jostling by grandchildren may disconnect something). I think I could put standoffs on the end of the enclosure for the Trinket and the bottom for the PWM Board.
4.       Rather than connect the Pro Trinket to the PWM board via right-angle headers, I might want to solder wires directly from the holes on the Trinket to the holes on the PWM board.
5.       To accomplish #3 and other improvements, I would need to hold off on soldering header pins to any components until I know how I really want to wire up and solder the whole project. I soldered the headers first thinking generically, then when I got inside I found that some of the pins were in the way.
6.       I’d like to see if I can make a PCA9685 breakout on my own to save space. New Year’s Resloution #1:  get some SMT soldering skills.
7.       Investigate 60MHz vs 50MHz on the Servo (see comment in sketch)



Circuit as laid out on a breadboard



Resources

Presentation on Adafruit Show-and-Tell
In-Process https://www.youtube.com/watch?v=Y8tFcF2-klw about minute 13 to 16:30
Finished  http://www.adafruit.com/blog/2014/11/26/show-and-tell-google-live-hangout-wednesday-night-at-730pm-et-112614-video/ about 4:50 to 6:45
 
Discussion on Wearable Wednesday
http://www.adafruit.com/blog/2014/09/17/wearable-electronics-with-becky-stern-9172014-live-2pm-et/

Donkey:

Sound:

Tutorial:

Sound from SD:

Micro SD:

TMRpcm library

Power servo

PWM/Servo Breakout

Amplifier

Increase volume (LM386)

Amplifier I used

Servo I finally used

Arduino Sketch

/*September-November 2014
THE HEAD MOVE DONKEY
Uses TMRpcm library to play music from and SD card, and Adafruit_PWMServoDriver library to drive the servo.
Some comments are from example code that came with those libraries
Objective is to move the donkey's head with the servo while playing "Donkey Serenade.
When I was on the Uno and had the serial monitor, I used an led to prove that I was moving through the loop. That is now commented.
Circuit uses the Adafruit Class D mono amp, Adafruit PWM servo board driving a micro servo, a micro SD card board, an 8 ohm speaker, and a 4xAA batter holder
It now runs on an Adafruit 3V Pro Trinket, feeding 3V to the SD card and using battery power for the Trinket, Servo, PWM board, and amp
*/
/*includes*/
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>

// called this way, it uses the default address 0x40
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
// you can also call it with a different address you want
//Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x41);

#include <SD.h> // need to include the SD library
#include <TMRpcm.h>           //  also need to include this library...

/*constants*/

// Depending on your servo make, the pulse width min and max may vary, you
// want these to be as small/large as possible without hitting the hard stop
// for max range. You'll have to tweak them as necessary to match the servos you
// have!
#define SERVOMIN  200 // this is the 'minimum' pulse length count (out of 4096)
#define SERVOMAX  350 // this is the 'maximum' pulse length count (out of 4096)
/*SERVOMAX reduced from 600 in example to 500 to save the servo (I stripped the gears on one already).  That gave me ~160 degrees. 
I reduced it again to 350, so it goes ~90 degrees: 45 to left and 45 to right if I have the motor and horn positioned properly. That's what I want
*/

// our servo # counter

#define SD_ChipSelectPin 10  //using digital pin 4 on arduino nano 328 2014-09-03 changed to 10 to match datalogger
//#define ledPin 5   //pin to control led   2014-10-25 testing
/*variables*/
int angle = 0;   // servo position in degrees
uint8_t servonum = 0;
/*objects*/
TMRpcm speaker;   // create an object for use in this sketch


void setup(){

 
  speaker.speakerPin = 9; //11 on Mega, 9 on Uno, Nano, etc
  speaker.loop(1); //2014-10-03 play repeatedly
  Serial.begin(9600);
  if (!SD.begin(SD_ChipSelectPin))
     {  // see if the card is present and can be initialized:
     Serial.println("SD not initialized");
      return;   // don't do anything more if not
      }
   else
      {
       Serial.println("SD initialized");
     }    
  speaker.volume(1);
  speaker.play("hmd.wav"); //play Donkey Serenade each time the arduino powers up, or is reset (as of 2014-10-03, plays repeatedly)
  pwm.begin();
  pwm.setPWMFreq(50);  // Analog servos run at ~60 Hz updates (says Adafruit--I found that 50 worked better with my servo from Radio Shack—never set it back for the Adafruit servo)
}

void loop()

{
//blink led to show arduino is looping through this whether servo moves or not
//  digitalWrite(ledPin, LOW); // 2014-10-25 testing only
  delay(1000);
//  digitalWrite(ledPin, HIGH); //testing
    for (uint16_t pulselen = SERVOMIN; pulselen < SERVOMAX; pulselen++) {
    pwm.setPWM(servonum, 0, pulselen);
    delay (100); //was 50, doubling the delay to move the head more slowly
  }
  delay(1000); //pause when limit is reached
  for (uint16_t pulselen = SERVOMAX; pulselen > SERVOMIN; pulselen--) {
    pwm.setPWM(servonum, 0, pulselen);
    delay (100);
  }
  delay(1000); //pause when limit is reached

}