Wednesday, January 20, 2010

Arduino Robot 1 - The Basic Tank

What you see below is the result of my first attempt at building a robot. The goal was to build something Arduino based. It would move forward, turn around, come back; and then turn around again to be in its original position. Finally, I wanted to try multiple part selling web sites, to get experience with who to buy from. Fortunately; they were all better than expected experiences. My Arduino was a Christmas present; but I will be factoring 32.00 into the cost of the project to account for it.

The first phase was an order from Tank treads, a double motored gear box, and some plastic to build a chassis came in at $40.00. The second order was from, for a continuous rotation servo and an Arduino Motor Shield. The Adafruit order also came in at $40.00. Subtracting the cost of the unused Servo, this robot is built for just under $100.00. You can see the initial parts order below.

I started by building the motor shield, this is the motor shield kit when taken out of the anti-static bag.

This is the completed Arduino Motor Shield after soldering everything into the board. The pins coming out of the bottom are the interface to the Arduino. You will notice two jumpers near the bottom middle of the picture. This is the motor power jumper, and is used in conjunction with the external power supply input; which is the block of two screw terminals just to the left of the jumper. You can see it says "EXT_PWR".

I moved on to building the "tank", this would be the chassis to hold the gearbox and Arduino + Motor Shield. I would later realize it had to hold two battery packs; one for the Arduino and one to power the motors via EXT_PWR. Getting the little plastic treads together wasn't fun, but everything came together.

 I had to solder two lines to the motors for them to work, then wire everything up. The wiring is supplying 6V from a battery pack to the motors, and there is the standard Arduino 9V battery pack powering it. Both packs are held to the chassis by velcro. You can see the Motor Shield stacked on the Arduino. Here is the final bot with source.

#include <AFMotor.h>

AF_DCMotor motor1(1, MOTOR12_64KHZ); // create motor #2, 64KHz pwm
AF_DCMotor motor2(2, MOTOR12_64KHZ); // create motor #2, 64KHz pwm

unsigned long tCnt = 0;
unsigned long tStart = 0;
unsigned long tDelta = 0;

void setup() {
  Serial.begin(9600);           // set up Serial library at 9600 bps  
  motor1.setSpeed(255);     // set the speed to 200/255
  motor2.setSpeed(255);     // set the speed to 200/255
  tStart = millis();

void loop() {
   tDelta = millis() - tStart;
   tCnt += tDelta;
   tStart += tDelta;
   // run motors for 5 seconds.
   if( tCnt <= 5000) {;      // turn it on going forward;      // turn it on going forward
   } else if ( tCnt <= 6300 ) {;      // turn it on going forward;      // turn it on going forward
   } else if ( tCnt <= 11300 ) {;      // turn it on going forward;      // turn it on going forward
   } else if ( tCnt <= 12600 ) {;      // turn it on going forward;      // turn it on going forward
   };      // stopped;      // stopped

Finally, it all gets put into motion. I made some mistakes that others should watch out for. The motors that come with the Tamiya gearbox don't work well with the Motor Shield. Their stall rating is too high. If not for this, the code above would simply use a 'delay'; but with the Tamiya motors; the delay keeps the motors from ever getting past stall. Also, the battery pack isn't needed. In this simple case the 9V + setting the jumper would power the two motors just fine. It was fun! I have ordered my first sensor; so I'll be starting Robot 2 - Wandering Tank. Here is Robot 1 in action:

Sunday, January 17, 2010

Fixing a dead Sansa MP3 player (Versions e200 e260 e280)

First, here is the player we are discussing, or at least your average version:

Although if you are here, you probably don't see the nice shiny interface above. That's a shame, but we'll try to fix it. This all started for me when a friend got a bag of crap from Woot! Among the loot, were quite a few dead Sansa e2XX players. You have to use the e200 tool to reflash them, it works better under Linux, and I run Linux (Ubuntu if you must know). So I ended up in a deal where I would try to fix all three. They were all fixed, and below I share how I eventually got all three working.

There are many posts on the web about how to fix these. They involve going into factory mode and flashing the firmware. Unfortunately a measurable percentage of people find that to be completely useless because if you can't get the device into factory mode then you can't update the firmware.

Let's troubleshoot a Sansa MP3 e2XX player. Keep following these steps, if you make it to the end, your player is beyond my help.

  1. Is it simply locked up? Hold the power button 30 seconds. The player should reboot.
  2. That didn't work, your player turns on, but isn't responsive. Remove the cover and take out the battery for 30 minutes.
  3. You removed the battery, and it didn't help. Now we'll try to get into factory/recovery mode. There are a couple ways of doing this depending on your version. They all start by turning the hold button on so you see orange. You then either hold the middle button, or the record button (and keep holding) while turning the player on. If you can get into factory mode, cool; go here: Fixing a Sansa in Recovery Mode 
  4. You can't get into recovery mode, the player turns on; but all you get is a blue ring. This is the ridiculous problem happening to a lot of people. They end up throwing away the player if it is too late to return it. The short answer is; your memory probably came loose. Here is an illustration of the problem: 

It makes me upset with Sansa that the memory for their MP3 players is attached with no locking mechanism at all. Here is what this should look like:

Fixing this is simple, and NO; you don't have to take the player apart as in the above pictures. I took a player apart, and had the memory fall on the floor; and here we are! Simply remove the battery cover (4 screws), remove the battery; and then find the big black square of plastic:

 You are going to need to remove that, it is easiest to push in the middle; forcing an edge to pop up, and then removing it. It's just lightly glued in place. You should then see your memory:

 Give the memory a firm push; if you hear a 'click', you probably just fixed your player. I know, this whole blog for that?!?! I spent hours reading forum after forum telling me to just 'be persistent trying to put it into recovery mode'. No; your memory may have come loose. I fixed two different players this way, and one other by flashing it. If this didn't help; you may be out of luck. Keep googling!

Create a "GG Button" With an IOT Button on Discord

I was having some fun with my internet button (found here:, and also working on some...