Building a TWANG32

ESP32 Programming

The first step is to program your ESP32. The kit I sell on Tindie requires the use of the NodeMCU-32s. It needs to match this footprint and pinout. Note: Some version of my kits include a pre-programmed ESP32.

Arduino IDE Setup

You need to compile and upload the firmware using the Arduino IDE. Get the latest version here. You need to add some additional software.

  • Install Arduino Core for ESP32. This gets the files require to program an ESP32 There are instructions here.
  • Install FastLED Library. The FastLED library is used to control the LED strip. Go to this page and download the latest version as a zip file. In the Arduino IDE select the SketchInclude LibraryAdd Zip Library. Then select the zip file you just downloaded.
  • Install RunningMedian Library: This library is used to filter (reduce noise) the accelerometer sensor using a 5 point median filter. You can get the library here.
  • Download the TWANG32 Sketch Source files. All of the files should be placed in a folder called TWANG32.

Programming

Open the TWANG32.ino sketch in the Arduino IDE you will see this near the beginning of the file…

// what type of LED Strip....uncomment only one
#define USE_APA102
//#define USE_NEOPIXEL

You need to uncomment (remove //) in front of the line for the strip type you have. In the case above the program will compile for the APA102 type strips. Make sure only one of the #define lines is uncommented.

Open the settings.h file in the same folder as TWANG32.ino. Change the #define NUM_LEDS  144 to the LED count you plan to use. This sets the default number of LEDs in your strip.

Next to the following steps to compile and upload the firmware. This could take several minutes to compile.

  • Under the ToolsBoards menu, select the NodeMCU-32S board
  • Connect the ESP32 to your computer.
  • Select the correct com port from the ToolsPort menu.
  • Click on the Upload button.

Install the ESP32 in the PCB.

The ESP32 should be installed with the USB connector aligned with the edge of the PCB. See the image below.

Print the plastic parts

The STL files are here. If you don’t have a printed, reply in the comments and I can get you some for a reasonable price.

All of the files can be printed in high speed mode. No fine details are required. They can all be printed with no support, except for the cover which has a small pocket on the bed side. I use PLA with 2 perimeters and 20% in fill. All of the screws self tap into the plastic.

Note: I made a recent change to eliminate the use of hot glue, some of the pictures are from earlier versions.

Attach the Adhesive Rubber Feet to the Chassis.

Attach the feet into the pockets on the bottom of the chassis.

Install the PCB into the chassis.

The PCB mounts directly on the bosses on the bottom of the chassis. Use flat head M3 x 12mm screw installed inserted the chassis bottom, through the PCB and into M3 x 12mm plastic spacers. Spacers are easier to use than nuts because they are easier to hold during installation.

Assemble Joystick.

Place clamp ring over door spring. It is important to do this first because it is difficult to do later. Next screw on the the lower part of the knob.

Slide the accelerometer module wires through the lower knob and spring. Push the accelerometer module into the pocket. I have recently made changes to remove the need for hot glue. This uses M3 x 10mm (button or pan head) to hold on the cap. I use a little piece of anti-static foam (in kits) to hold the MPU-6050 accelerometer module down. If you don’t have the foam use 2 dots of hot glue in the corners with the mounting holes.

 

Attach the cap. Align the hollow arrow side of the cap with the little notch at the top of the lower knob. This hollow arrow will show you which side points forward in a later step.

Attach the metal cap to the bottom of the spring. This cap allows the spring end to sit flat on the cover. It should be screwed on about as much as shown in the image.

Attach the joystick to the cover. Make sure the hollow arrow is pointed forward (the closer edge). Before it is fully tightened twang it a few times. This will relax  the spring so you can see if it still points forward. Do this a few times and adjust to make sure it points forward. It does not need to be perfect… +/- a few degrees is OK.

Attach the speaker using M3 x 10mm screws.  If you angle the wires a little, it makes the wiring a little easier later.

 

Attach the LED cable. Your LED strip should have come with a mating connector. Some types have 3 wires and some have 4. Mate it to the LED strip. See what colors do what functions by looking at the strip labels. The strips have an arrow pointing the ways go from zero up.  Most strips have connectors on both ends. Us the connector on the base of arrow side.

All LED strips should have a + and -. These could be labeled 5V and Gnd. Do not rely on the traditional red+ and black- wire coloring. The strips are often not wired that way. Attach the wires to the terminal block. I like to add a cable tie behind the wall to act as a strain relief. I also label my wires, but you need a heat shrink printer for that.

Attach the rest of the wires from the cover. Attach the speaker connector and the accelerometer wires.

Attach the cover.

At this point you should be able to power up and play.

Reference

 

 

 

 

 

 

 

 

 

 

 

 

 

Share and Enjoy:
  • Print
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Yahoo! Buzz
  • Twitter
  • Google Bookmarks

6 Responses to “Building a TWANG32”


  1. Florian Bednarz

    I can’t get the mpu6050 to work…
    Pin 21 and 22 are the standard i2c pins for the esp32?

    Or do you use other pins, which i haven’t figured out yet…

    Thanks for your answer!
    Flow86

  2. bdring

    I use 21 and 22. I update this post with a link to the schematic.

    See the reference section at the end of the post.

  3. Florian Bednarz

    I always get these errors:

    In file included from D:floarduinoTWANG32-masterTWANG32TWANG32.ino:35:0:

    C:UserssimonAppDataLocalArduino15packagesesp32hardwareesp321.0.0librariesWiresrc/Wire.h: In member function ‘bool Twang_MPU::verify()’:

    C:UserssimonAppDataLocalArduino15packagesesp32hardwareesp321.0.0librariesWiresrc/Wire.h:98:13: note: candidate 1: uint8_t TwoWire::requestFrom(int, int, int)

    uint8_t requestFrom(int address, int size, int sendStop);

    ^

    C:UserssimonAppDataLocalArduino15packagesesp32hardwareesp321.0.0librariesWiresrc/Wire.h:96:13: note: candidate 2: uint8_t TwoWire::requestFrom(uint8_t, uint8_t, uint8_t)

    uint8_t requestFrom(uint8_t address, uint8_t size, uint8_t sendStop);

  4. bdring

    It is hard to tell from that output. It looks like there might be an issue with the Wire library.

    Do you have the latest Arduino IDE and ESP32 Core?

  5. Florian Bednarz

    i found the solution.
    the esp32 core loaded via Arduino-Board manager was the problem…

    i loaded the esp32 core manually in the arduino IDE and it worked…

    thems there is a i2c problem in the stable release of esp32 core…

  6. Chris Rogers

    I found the original line wobbler a while ago and have longed for a DIY version so was so happy to see the original TWANG implementation and your even more interesting derivatives!

    I put this together last weekend using a Adafruit Feather Huzzuh32 but I could never start the game (MPU6050 isn’t working) and the sound is very scratchy with very loud ticking sound. Pulled out my Arduino Mega 2650 and used same hardware (minus sound board) to build the original TWANG with original sketch and it worked perfectly. Realized the Huzzuh is not 100% the same as your board so I purchased a ESP32 board from Amazon (https://www.amazon.com/gp/product/B0718T232Z/ref=oh_aui_detailpage_o03_s00?ie=UTF8&psc=1) but now I am getting EXACTLY the same behavior as when I tried the Huzzuh.

    Anyone have a clue what is wrong with my setup or why this Twang32 sketch won’t run on either ESP32 boards?

*