Bryce Kahle
Published © Apache-2.0

Gongbot

Spark Core controlled gong, triggered via hubot. Delivering zen to the Spark office.

IntermediateFull instructions provided1,651
Gongbot

Things used in this project

Hardware components

Spark Core
Particle Spark Core
×1
GWS S03T Servo
×1
Barrel Jack
×1
6V Power Supply
×1
#8-32 Machine Screw
×1
#8-32 Nut
×2
#10-24 Machine Screw
×1
#10 Nut
×1
Corner Brace
×1
Cable Ties
×2
Wuhan 22 Inch Wind Gong
×1
Wuhan Gong Stand
×1
Gong Mallet
×1

Story

Read more

Schematics

Gongbot Breadboard

Wiring diagram for the breadboard

Code

gongbot.ino

C/C++
Spark code to ring the gong
Servo myservo;

int pos = 0;
int holdpos = 90;
int recoilpos = 45;
int hitpos = 110;

int servodelay = 1500;

void setup() {
    Spark.function("gong", hitthegong);
    myservo.attach(A7);
    myservo.write(holdpos);
    delay(servodelay);
    myservo.detach();
}

void loop() {
}

int hitthegong(String command) {
    myservo.attach(A7);
    myservo.write(recoilpos);
    delay(servodelay);
    myservo.write(hitpos);
    delay(500);
    myservo.write(holdpos);
    delay(servodelay);
    myservo.detach();
    return 1;
}

gong.coffee

CoffeeScript
Hubot script to trigger the gongbot, while also providing a bit of code zen.
Spark = require('spark')

config = {
  access_token: 'abcdefghijkl1234567890'
}

module.exports = (robot) ->
  robot.respond /gong/i, (msg) ->
    Spark.login { accessToken: config.access_token }, (err) ->
      if err
        return msg.send 'Error logging in'

      Spark.callFunction 'gongbot', 'gong', '', (err) ->
        if err
          return msg.send "Function error: #{err}"

        robot.http('https://api.github.com/zen')
          .get() (err, res, body) =>
            if err or res.statusCode isnt 200
              return msg.send "Error achieving zen"

            msg.send "#{body}"

Credits

Bryce Kahle

Bryce Kahle

1 project • 1 follower
Thanks to Stripe Gongbot.

Comments