Sunday, April 02, 2017

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 bot coding.

So I decided to bring the two together; with the goal of pressing a button to summon a bot to my channel to play a sound effect(s). This would be similar to the famous button, but would play a sound to everyone I am in a Discord channel with.

Since I was already working with Darkside's SoundBoard bot for Discord; I decided to utilize the API. That way I'd be creating a simple web hook that could later be used for other purposes; like having Jenkins run a build/deploy.

You can see the completed work in action:

This comes from this source code:

1:  // This #include statement was automatically added by the Particle IDE.  
2:  #include <HttpClient.h>  
4:  // This #include statement was automatically added by the Particle IDE.  
5:  #include <InternetButton.h>  
7:  /**  
8:   * George Frick  
9:   *   
10:   * This application will play a certain sound effect in a voice channel  
11:   * when the button is pressed.  
12:   *   
13:   * A simple http post when a button is pressed.  
14:   * You don't have to go through the particle API.  
15:   *   
16:   * In this example, we post to a Discord sound effect bot.   
17:   * @see  
18:   *   
19:   * You also need the above two libraries, HttpClient and InternetButton  
20:   *  
21:   *  
22:   *  
23:   * To use the Serial output, have your internet button connected via usb  
24:   * and type 'particle serial monitor'  
25:   */  
27:  HttpClient http;  
28:  InternetButton b = InternetButton();  
29:  bool mashBlocker = false;  
31:  // Headers currently need to be set at init, useful for API keys etc.  
32:  http_header_t headers[] = {  
33:    { "Content-Type", "application/x-www-form-urlencoded" },  
34:    // { "Accept" , "application/json" },  
35:    { "Accept" , "*/*"},  
36:    { NULL, NULL } // NOTE: Always terminate headers will NULL  
37:  };  
39:  http_request_t request;  
40:  http_response_t response;  
42:  void setup() {  
43:    b.begin(); // pass 1 for older buttons (no shield)  
44:    b.setBrightness(50); // limit overall brightness.  
45:    Serial.begin(9600);  
46:  }  
48:  void loop(){  
50:    if(b.buttonOn(2) && mashBlocker == false) {  
51:      b.ledOn(3, 255, 255, 255);  
52:      mashBlocker = true;  
54:      Serial.println();  
55:      Serial.println("Making web request...");  
57:      request.hostname = "";  
58:      request.port = 8080;  
59:      request.path = "/soundsApi/playFile";  
60:      request.body = "soundFileId=sms1&username=gfrick-test";  
62:      // Post request, it blocks. (blocking i/o)  
63:, response, headers);  
65:      Serial.print("Application>\tResponse status: ");  
66:      Serial.println(response.status);  
68:      Serial.print("Application>\tHTTP Response Body: ");  
69:      Serial.println(response.body);  
71:      b.ledOff(3);  
72:      mashBlocker = false;  
73:    }  
75:  }  

This was a quick and fun little project, and it gets me started on doing IOT based dev ops and more!

Wednesday, September 19, 2012

Upgrading The 3D Printer And Hexy Build Notes (Prusa RepRap)

What a busy couple of weeks I have had. Many upgrades for the printer have arrived, and work continues on understanding and possibly building Hexy before my Kickstarter version arrives from Arcbotics. In this post I will cover the upgrades I have made to the printer; why I made the upgrades, their cost; and finally show some updated Hexy prints to show off the new accuracy.

First; I was printing the Seej Starter Set, in preparation for taking my printer to work on my last day. While doing so, the printer gave up the ghost. Badly. First, the z-axis was homing and went right down through the printer bed. So after a break and calming down, I put the z-axis back together, calibrated; and went to home it again. Same thing, it went right down through the printer bed; which was saved by being spring loaded. This time though; the z-axis couple snapped in half.

So, because of this complete printer failure and needing to order new parts anyway; I decided to do the upgrades that are suggested to get good accuracy. Mainly, G2 pulleys. So I ordered:

 So that is $63.00 plus shipping came out to around $75.00 all said. I also ended up buying a new metric hex set for ~$10.00 because I stripped a set working with the Motor Shaft Coupling. I purchased all of this from Ultimachine which is where I get all my parts/PLA.

 Moving along... I rebuilt with my new drive belts. The nice thing about the GT2 is that they are meant for this type of machine instead of the old T5 belts which aren't. It is also nice to go from a printed pulley to an aluminum one. So at the end of the day, the change is getting rid of printed parts (vitamins), lowering how much of the printer can be re-printed. I wouldn't suggest anyone build one of these without this immediate upgrade. In a moment, you'll see the stark contrast in quality.

So first, the change to the coupler:

On the left, the printed coupler, on the right, the new aluminum one.

On the left, the printed pulley, on the right, the new aluminum one.

With the upgrades installed, it's like a new printer!

Printer, with new pulley/belt and new shaft coupling.

So with an upgraded printer, it was timing to do a comparison print and produce a part for Hexy. This part should hold two small servos; which I just happen to have received from Hobby King today. My apologies for the following photo being upside down. What you see if a servo measured with a caliper compared to the Hexy piece it should fit it. The problem being the hole is the exact size of the servo, so it doesn't fit! Either does the screw, as predicted by the guys at Arcbotics.

One thing we can note in the picture below though; is the Hexy part on the left (right if the picture was flipped). That part was produced under the old belt/pulley/coupling system by the exact same STL file, and as you can see is obviously way too big.

So the current plan is to work a bit from on calibrating the printer to see if that resolves the issue of the Hexy piece now being slightly too small; unless the error is in the STL file. Regardless, I am very happy with the prints being produced; especially with so little changes to configuration. I'll be posting in the Arcbotics forum to see if the STL can be resolved further and to provide them more feedback. Next chance I get, I'll be reproducing an entire leg of parts for Hexy, and trying to print the Seej set again.

Monday, September 03, 2012

RepRap Rebuilt! A 3D Printer Story

So it has been a long time since I made a real post; but we won't dwell on it. Instead, let us get to the good stuff and share some information!

This post regards my long term rebuild of my Prusa Mendel Reprap, which I decided to do back in March. If you saw my previous blog posts, you will have seen the state of the printer. It worked, but it didn't print well and there were wires everywhere. I even used some CAT5 as motor wire.

Because of the setup, the printer experienced many problems:
  1. Wires would catch during the printing run.
  2. The printer could not be moved.
  3. The RAMPS (Arduino Mega + Shield) kept getting bumped around, etc.
So, I took the entire thing apart and took the following steps:
  1. All wires now use connectors (pictured below).  These are available at Ultamachine:
  2. The power supply and RAMPS are mounted on a small piece of wood, which is mounted to the reprap (pictured below)
  3. The thermistor, print head, and extruder motor now share the ribbon cable, instead of 3 wires handing intermingled in the machine.
With the changes in place, the printer actually printed really well with no calibration. The controller computer was also updated; (1ghz/512MB -> Core i3 + 2GB). Going forward, I don't recommend hooking a reprap up to an older machine like that unless you are going to "slice" on a different machine. I consider the connectors to be a big upgrade, it should be easy to swap out, adjust and generally maintain all of the connections.

Here are a couple pictures:

Well, that is the 3D printer post. I've been printing some Hexy parts to calibrate it; and I'm very happy. It prints better than it ever did before!

I have a post coming up with some code in it that is pretty exciting, and I'm continuing to experiment with the printer while waiting for my Hexy. Don't forget about my little tracked bot! A model is needed for the sensor mount to make the line following more smooth!

That is all for now!

Sunday, September 02, 2012

Quick Post About Hexy

Hello, just a quick post about Hexy the robot.

I was recalibrating the printer after finishing up the rebuild and wanted to do some printing. Since I was curious about the sizing of Hexy and also my ability to print parts for it; I decided to grab the STL files and get printing.

There was trouble; not all of the stl files were ready, some of them needed to be run through first. It took me a while to figure this out; but once I found it everything went smoothly.

You may be curious; so here are some leg pieces for Hexy; printed in blue PLA.

That's all for now. I'm prepping a full post on the rebuild reprap; my robot progress, and another project that is coming along very nicely.

Sunday, January 08, 2012

3D Printer Build Post 2 (RepRap Prusa Mendel)

My long journey concerning this printer has turned out to be a glorious one. With objects coming off the printer with a pretty high quality; and my ability to design objects starting to form, it became time to share the progress and information. I will answer my own questions from the end of the previous post; outline more of the printer build, and share the general experience. Also, I will address the budget with an update.

Alright, so let's see it!

Above is my RepRap (Prusa) as it sits today. It is half converted over to version 2. I chose to do this conversion to understand the printer better, and more importantly to improve the prints. The original build calls for using printed clamps on the axis; and the plastic simply slides. This is fine; but the clamps have to be replaced periodically and you just don't get accurate movement. So I printed a new X-axis, new Z-axis, some stabilizers and purchased a set of LM8UU shaft bearings to mount the new parts. Here are closeups of the new X-axis and Z-axis.

You can see the role of the LM8UU bearing. The Y-axis still uses the old printed clips. You can see them in this picture for comparison.

Obviously the shaft bearing works way better. although the clip design is really good and it works surprisingly well as a printable solution. To complete this tour of the upgrades, we can compare the old Z-axis to the new one, and show the Dremel work I did on the z-axis coupler at the top. I cut out the center so I could separately tighten the two ends. Here are the pictures.

The last upgrade to talk about is visible at the top of the first picture. I printed a mount for a large Ultimachine spool of PLA. I haven't gotten to the spool yet (finishing up the clear PLA), but it's ready to 'spin' now.

With all of that said, it would be wise to update the budget. The budget previously stood at $782.00, and I did some upgrades and had to purchase the LM8UU bearings.
  • Upgrades - Free. Printed on my printer.
  • LM8UU bearings - $15.00 w/shipping (Ebay)
  • Additional PLA - $76.95 w/shipping (Ultimachine Blue PLA Spool)
  • Razor blades and Miscellaneous like zip ties.
This brings the total for the current setup to ~$900.00. This is a ready to print state with a full spool of blue PLA.

The next topic to cover are notes from my build. A LOT of work goes into getting the printer 'correct'; once it is built there are a whole new set of challenges ahead.
  • Do the axis move correctly? Does telling each of them to move 10cm move them exactly 10cm? This will be adjusted in firmware until it is as correct as you have patience for.
  • Do the axis move smoothly, or do they jerk? You'll end up printing tension mounts for your belts and converting over to LM8UU so that your prints don't start 'shifting' mid print when something skips.
  • Is the whole thing rigid enough and on a rigid base? Get a good print going and a bad table or weak frame tightening will cause the frame, the table or both to shake.
  • Is the bed level and is the print head setup to be the correct distance from the print bed when home? Instructions say 1 or 2 sheets of paper; yep. Easy :-(
  • Does the Z-axis wobble? This is why I did the work on the z-axis couplers and added the stabilizers at the bottom. Without that work the rods wobble and the print wobbles as it goes up.
  • Does the extruder push through 10cm of plastic when told to? This has to be adjusted physically (is your hobbed bolt working properly?) and in firmware.
  • Are the motor steppers AC adjusted correctly? Too high; they'll overheat (and burn you!), too low and they'll miss steps. I added heat sinks; but ended up not needing them.
  • Is your software configured correctly? Correct filament width; correct temperature settings for your filament? Correct fill settings? Correct layer height/width? I spent weeks on this.
Finally, we do want to print things. Where do these magical things come from? Well, I'm not going to really cover the printer firmware/software except to provide some links. I use Sprinter for firmware with Pronterface/Skeinforge for my software; it is running on Windows Tablet Edition (2001). This is because I'm using an ancient computer I had in the basement for printing.

The best place to find things to print is Thingiverse. The software uses STL files that are representations of 3d models. The software then cuts the model into layers and modifies as needed in order to print. Frequently you will have to add supports that you cut away/etc; in order to make a print work. Here are some objects on Thingiverse that I really like:
You can see my thingiverse profile here:
If you follow it; you can see what I've printed (some) and what I like. I haven't uploaded anything(yet).

To take it further, you will want to design your own objects. I have been using OpenSCAD to design things. Although I use the term 'use' lightly, I'm still learning. OpenSCAD is a programmer's design tool; you write scripts that generate objects. Once done, you can export them to STL, have them sliced and run them off the printer.

To wrap this up; here is an object I designed in OpenSCAD and printed. Just a small business card holder. I hope to parametrize it and print a larger one as a stand from my Kindle DX.

If you are looking for some good videos of the reprap in action, checkout this guys channel on Youtube. He has filming setup, where as I don't.

A great video of his:

That wraps up this post; and hopefully opens the door for many more. Feel free to send me questions or feedback. I hope everyone had a great holiday and came into the new year with a sense of renewal and determination!

Tuesday, October 25, 2011

3D Printer Build Post 1 (RepRap Prusa Mendel)

The long journey to building a 3D printer has been underway for quite a while now. With the complete set of parts ordered and much of the construction finished I decided to share the progress; outline my frustrations, and post about how you can benefit from my mistakes.

I have been building the printer for over a month; and the last batch of parts arrived early this week. What can clearly be said about this project is that you will underestimate it. The original plan was to get this working in six months. Once construction was underway; it seemed more like a month. It now looks like this could really take up to six months (to produce a quality 3D printed part). In this part of the coverage; I hope to outline the budget and basic build so far; finally going over some problems and warning points.

The budget for this printer is quite high. It is a mid-range open source 3D printer known as a Prusa Mendel. You can find the wiki for it here. I chose to start with the basics (more on this later). So here is the budget:
  • The starter kit $195.00 (from this ebay auction)
  • Rods - Threaded and Smooth, $68.17 (
  • Motors - Pololu Nema 17 x 5 $104.70 (, item link)
  • Hot End and Ramps 1.4  $364.00 (
  • Wire, digital caliper, etc. ~50.00
So the total budget so far for the printer is ~$782.00

Here are the basic pictures; showing various steps of the frame building process. I cut the rods myself; making a jig according to this page. I then used the electric saw to get through them quickly.


At this point I lost my memory card; so there is a gap of missing pictures. They weren't very interesting anyways. The pictures resume with motors in place and the y-axis completed.

The extruder which feeds plastic into the hot end has to be 'hobbed'; basically you give it teeth so that it grips the plastic. The extruder can then force plastic into the hot end which acts as a glue gun (but for plastic). I hobbed by hand. Following that sparks are some pictures of the extruder; which came together easily.

With the extruder completed, tested, and mounted - the basic build was complete. I didn't want to start wiring things up until I got some chores out of the way. So the second picture below is my converted ATX power supply. I may do a complete post on this; as it is very useful for anyone doing robotics/arduino. The short and sweet? Connect the green to ground; then all of the orange (3.3v), red (5v), and yellow (12v) become easy power. The other wires can be removed.

Before putting the top back on.

At this point I have begun working on the wiring and getting everything to the final setup. There is still a ton of work to do however and I do not think that my carriages move as freely as they should. That said; I did want to share some of my sticking points in case you are considering this venture for yourself. So; consider these points before you start and you can benefit from my troubles.
  1. A dremel is NOT an optional tool. You will need to correct parts, cut parts; etc.
  2. Have a large work area available; I am using both my full desk; a table I purchased and a couple shelves.
  3. Have something to organize parts; similar to component bins. There are a LOT of nuts, bolts and washers.
  4. Have a small enough level; if your level is too big; it doesn't fit against the rods and you will have trouble leveling. You could also have a spacer ready; but remember you need to level various parts.
  5. A digital caliper is highly recommended for accuracy.
  6. Plan for the 'breaks'; you will have two glue steps where you glue and walk away. You will also apply ceramic to the hot-end and it should sit overnight.
  7. Have your PSU ready before you attempt to build your hot-end; you will need the +12v for curing.
 There are also various problems I'm running into that I can't seem to find resources for. Be wary of these; or if you know the answer - let me know!
  1. How does the hot end attach to the extruder? I really cannot find this!
  2. Preparing the default bed; do I just put aluminum foil on it? All documentation seems to simply skip this and references the 'prepared print bed'.
  3. I will know more tonight; but you apparently need a linux box to build and upgrade the firmware. I will update this entry based on my findings.
  4. How should the Arduino Mega be powered; usb?
That wraps up this post. Hopefully my next post about this will include a first print and more information to help you build your printer.

Saturday, October 15, 2011

Arduino Robot 3 - Part 1 - Reflectance Sensor

This is the first part of my post covering my creation of the line following Arduino robot. In this post I will talk about the costs; setup and preparation for creating the robot. I will also discuss a few different approaches to line following that I explored. We will get the sensor attached to the robot and retrieving data. In the next part, we will cover the final approach used; tour the code, and see the full video.

The budget for this tank is quite low, because we start with Robot 1. I chose to add a single reflectance sensor to the bottom of Wandering Tank; and remove the wall avoidance equipment. So, the budget:
So Line Following Tank has an estimated budget of $105.00 to build.

Since there is no need for the parts from Robot 2, the cost is very low. I would suggest coming up with a few other things to order so that you don't pay more in shipping and handling than for the sensor. I ordered a couple sensors and of course, more of these. Time to build!

Building this robot is not as simple as ordering the parts. I could find no reliable way to attach the sensor to the bottom front of the robot. I ended cutting a strip of double sided tape up into squares and stacking them to a desired height. Wiring the robot is simple; I used digital pin 5; which is pin 19 on the Arduino. Here are some pictures as a guide:

Soldering the wires to the sensor is easy. You are simply giving it 5V to operate with, grounding it, and giving it somewhere to send data. You must add the Arduino Library For Pololu QTR Sensors to your Arduino IDE before working with the sensor.

In preparing to create the line follower; I had to do a lot of research and of course make sure I was ready to use the sensor in code. Using the sensor in code is easy. I will show the code to use the robot as a color detector. The speaker will make noise to reflect (get it?) the color seen by the sensor. As I wave the robot over a dark line; the frequency will change.

 * George Frick (
 * October 2011.
 * Arduino Robot 3 - Sensor Wave Test
 * This isn't a robot; but uses the build line following robot to test the reflectance
 * sensor. The robot starts up and beeps to notify the user to calibrate (wave robot
 * back and forth over line), then beeps again before starting. Once started the robot
 * calls buzz with the detected color value as the frequency.
 * This tests runs continuously. The user may choose to view Serial output.
#include <PololuQTRSensors.h>

const int qtrPin = 19; // pin 5 as digital is pin 19
const int buzzerPin = 14;

// create an object for your type of sensor (RC or Analog)
// in this example there is one sensor on qtrPin
PololuQTRSensorsRC qtr(( unsigned char[]) {qtrPin}, 1);

void setup() {
  Serial.begin(9600);           // set up Serial library at 9600 bps  
  pinMode(buzzerPin, OUTPUT);
  buzz(buzzerPin, 1000, 100);
  calibrateQTR(); // Wave the sensor accross the color specture during this time!!!
  buzz(buzzerPin, 2000, 200);

void loop() {
  unsigned int a[] = { 0 }; // One sensor!
  qtr.readCalibrated(a);    // It will fill the array from the sensor array.
  Serial.println(a[0]);     // Use a[0] to get the only entry.
  buzz(buzzerPin, a[0] - 50, 100); // the minus 50 is arbitrary.

void calibrateQTR() {
  // start calibration phase and move the sensors over both
  // reflectance extremes they will encounter in your application:
  int i;
  for (i = 0; i < 250; i++) {

void buzz(int targetPin, long frequency, long length) {
  long delayValue = 1000000/frequency/2; // calculate the delay value between transitions
  // 1 second's worth of microseconds, divided by the frequency, then split in half since
  // there are two phases to each cycle
  long numCycles = frequency * length/ 1000; // calculate the number of cycles for proper timing
  // multiply frequency, which is really cycles per second, by the number of seconds to 
  // get the total number of cycles to produce
  for (long i=0; i < numCycles; i++){ // for the calculated length of time...
    digitalWrite(targetPin,HIGH); // write the buzzer pin high to push out the diaphram
    delayMicroseconds(delayValue); // wait for the calculated delay value
    digitalWrite(targetPin,LOW); // write the buzzer pin low to pull back the diaphram
    delayMicroseconds(delayValue); // wait againf or the calculated delay value
/* EOF */ 

In the video; you will notice me waving the robot in the beginning with no sound. This is during the calibration phase when you want to show the sensor different colors. Once calibrated another beep announces the 'wand' is ready.

The final discussion is the approach to line following. With only one sensor; it gets tricky. If you have more than one sensor; you can find the line and keep it between two sensors; etc. With one; you have to make an effort to say on the line. As of writing this; I am aware of a few approaches:
  1. Drive forward if on the line. When the robot leaves the line, sweep left and right until the line is found again; then continue forward. This has several problems; the largest of which is a simple 90 degree turn; in which the robot may end up going back along the line.
  2. Constantly sweep back and forth. I have seen this implemented on Youtube and other places. I don't like it and I don't think the robot should have to 'dance' in this way.
  3. I am working on this :-) Depending on how it turns out; it will be the next post. Otherwise I may settle for one of the other two approaches.
So; the robot is built and the code works. It's time to implement approaches to line following and see what kind of results I can get. The follow up post to this will share the finished robot and code!

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...