The Author on Twitter Visit Blog View on Github

0 to Nodebots 2017 Links

Links to accompany "0 to Nodebots" presentations from 2017.

Installs

Demos

Blinky

Diagram: diagram-blinky.png

blinky.js:

var five = require("johnny-five");
var board = new five.Board();
board.on("ready", function() {
  var led = new five.Led(11)
  led.strobe(500);
  this.repl.inject({
    led: led
  });
});

REPL:

led.stop();
led.strobe(3000);
led.off();
led.on();

Flashlight

Diagram: diagram-flashlight.png

flashlight.js

var five = require("johnny-five"), board, photoresistor;
var board = new five.Board();

board.on("ready", function(){

  var led1 = new five.Led(10);

  photoresistor = new five.Sensor({
    pin: "A2",
    freq: 500
  });

  maxLight = 800
  minLight = 250
  lightRange = (maxLight - minLight)
  ledRange = 255

  photoresistor.on("data", function() {

    currentLight = this.value;
    ledValue = (((currentLight - minLight) * ledRange) / lightRange);
    ledValue = Math.max(ledValue, 0);
    ledValue = Math.min(ledValue, 255);

    console.log("Photosensor: " + this.value)"     ledValue: " + ledValue); 
    led1.fade(ledValue, 500);

  });

});

Tessel 2 Blinky

blinky.js

var Tessel = require("tessel-io");
var five = require("johnny-five");
var board = new five.Board({
  io: new Tessel()
});
board.on("ready", () => {  
  var led, led2;
  led = new five.Led("L2");
  led.blink(500);
  led2 = new five.Led("L3");
  led2.blink(500);
});

CLI:

t2 push blinky.js

Tweetbot

Diagram: diagram-tweetbot.png

tweetbot.js:

Code on Github: https://github.com/KatieK2/tt-sumo
Original Nodesash by nodebotanist

var Tessel = require("tessel-io");
var five = require("johnny-five");
var twit = require("twitter"), request = require("request");
secrets = require('./secrets');

var board = new five.Board({
  io: new Tessel()
});

var leftWheel = new five.Servo({ pin: "A5", type: 'continuous' }).stop();
var rightWheel = new five.Servo({ pin: "A6", type: 'continuous' }).stop();

var twitter_api = new twit(secrets);
var tweets_shown = [];
var hashtag = "nodebotUJS"

function mvForward() {
  leftWheel.ccw();
  rightWheel.cw();
  setTimeout(function() {
    leftWheel.stop();
    rightWheel.stop();
  }, 800);
}

function mvBackward() {
  leftWheel.cw();
  rightWheel.ccw();
  setTimeout(function() {
    leftWheel.stop();
    rightWheel.stop();
  }, 800);
}

function mvLeft() {
  console.log('Left');
  leftWheel.ccw();
  rightWheel.ccw();
  setTimeout(function() {
    leftWheel.stop();
    rightWheel.stop();
  }, 700);
  setTimeout(function() {
    mvForward();
  }, 750);
}

function mvRight() {
  leftWheel.ccw();
  rightWheel.ccw();
  setTimeout(function() {
    leftWheel.stop();
    rightWheel.stop();
  }, 700);
  setTimeout(function() {
    mvForward();
  }, 750);
}

function getNewHashtagTweets(){
  twitter_api.get('search/tweets.json', { q: '#' + hashtag }, function(err, tweets, resp){
    // console.log(err, tweets);

    var newTweets = tweets.statuses;

    newTweets.forEach(function(tweet){
      if(new Date(tweet.created_at).getTime() > (new Date().getTime() - 3600000)){ // Just tweets from the last 60 minutes

        if(tweets_shown.indexOf(tweet.id) == -1){
          tweets_shown.push(tweet.id);
          console.log(tweet.text);
          
          result = tweet.text;
          result = result.replace("#" + hashtag, "");
          result = result.match(/[u|d|l|r]/i); // Matches first instance of character only; including the hashtag. Because JS regexes don't support lookbehinds. 
          if ( result ) {
              result = result[0].toLowerCase();
            if(result == "d") {
              mvBackward();
            } else if(result == "l") {
              mvLeft();
            } else if(result == "r") {
              mvRight();
            } else {
              mvForward();
            }
          }
          else {
            console.log("  udlr not found");
          }

        } 
      }

    });
  });
}

board.on("ready", () => {
  setInterval(getNewHashtagTweets, 1000); //every 1 second
});

CLI:

t2 push tweetbot.js

Buying

Buying - Nifty Accessories:

Getting Started

Johnny-Five:

Tessel 2:

Raspberry Pi:

Particle Photon / Core

Circuit Playground

Espruino:

or

Robots

Sumobot Jr:

Simplebot:

Chassis - Buy:

Chassis - Make:

More Bots:

Laser Cutting / 3D Printing

Halloween Builds

Hallowe’en tombstone (lights co-ordinated to music)

Christmas Builds

Light-up Tree Topper

The Texting Tree

Home Builds

Web-controlled Thermostat

Weather Stick

Blender Defender

Motion Activated Sprinkler

Automated Cat Laser

WarKitteh

Office Builds

Illumigami - Paper lantern meeting room status indicator

Make Art

Hack a Toy

WarSting:

Bright New RC:

Even More Potent Potables

Brewfactory:

Heising-330

Cocktail Mixing Robot

Johnny Five Builds

More Builds

Inspirational Builds

Build Collections

Books

Soldering

APIs / Cloud Data

Going Wireless

Where to Get Help

Learning Node

Learning Electronics / Nodebots

Other