Pew Pew Laser Blog

Code. Glass art. Games. Baking. Cats. From Seattle, Washington and various sundry satellite locations.

Blogs about maker

Inkscape - Using Path > Difference With Text.

3.3.2018

It turns out that Inkscape's error messages will appear in the status bar at the bottom of the application.

Part of getting my Glowforge laser cutter has been learning to use a new piece of software, Inkscape. I was having problems using Inkscape's "Path > Difference" option to combine (well, cut out) shapes and text elements. Here's what I had to do to get the elements merged:

  1. Optional: Disable any stroke styles on both objects. Use fills instead.
  2. Optional: Make sure the first element - the non-text - is a path. Select it and choose "Path > Object to Path".
  3. Turn the text into a path. Select it and choose "Path > Object to Path".
  4. Ungroup that new path. Right click it and choose "Ungroup".
  5. Bring the "top" element to the top layer (Home). This is what will be removed from the other element.
  6. Position / align the elements as desired.
  7. Select both of the elements.
  8. Choose "Path > Difference".

tinylab Flashlight.

8.2.2017

Photograph of a tinylab - an all-in-one arduino-compatible prototyping board. I've been fiddling around with my tinylab - an all-in-one prototyping board with an embedded Leonardo and a fair selection of components. I'd already got it working with Node and Johnny-Five. Next I wanted to do something which demonstrated interaction between the software and some real-world conditions.

Note that my tinylab (perhaps because it's an early crowd-funded version) doesn't have the breadboard shown in the current production versions of the tinylab. No worries - a mini breadboard (without the connector tabs) fits in there perfectly.

I made a "flashlight" - where an LED gets brighter when the hardware detects less ambient light. Since all the components on the tinylab are already built in, I didn't have to do any wiring. It's pretty easy to test by covering the photoresistor with your finger. Here is the code:

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 // Data is polled every half second
  });

  maxLight = 750 // Set this to the "high" value of light in your room.
  minLight = 250 // Set this to the "low" value of light in your room.
  lightRange = (maxLight - minLight) // Will change for different rooms.

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

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

    console.log("Photosensor: " + this.value + "     ledValue: " + ledValue); 
    led1.fade(ledValue, 500); // Smooth transition of LED brightness

  });

});

You'll need to set the maxLight and minLight values for your environment.

With this experiment, you now have a way to read a value from your environment, report it to a computer, and act on it.

The STEMTera Breadboard and Johnny-Five's five.Leds.

4.7.2017

The STEMTera Breadboard is a nifty combination Ardunio (Uno R3) / breadboard. It has a Lego-compatible backside and it's available in black, white, and pink. When I got mine, of course the first thing I did was get it set up to run with Johnny Five. The StemTERA breadboard with some resistors and LEDs installed.

Basic Functionality / Hello world

Making an LED blink is the Hello world! of hardware. It's common to just use an Arduino's onboard LED on pin 13. Here's what you do to get up and running from scratch:

Red and Green LEDs

Fritzing diagram of StemTERA breadboard with LEDs and resistors installed. Now let's add external LEDs (and protective resistors of course). Build your circuit as shown here, using 2 330? resistors, two 3mm LEDs, and two jumper wires. This is the magic of the StemTERA breadboard - the circuit doesn't need to hop back and forth between the breadboard and the external Arduino.

Here's the code - store it in a file and run it as with the first block of code.

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

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

  // We can address them separately, or together in leds
  var red = new five.Led(6);
  var green = new five.Led(5);
  var leds = new five.Leds([red, green]);

  green.off();
  red.on();
  leds.blink(1000);

  this.repl.inject({
    leds: leds
    // leds.stop() // Stop the strobing
    // leds.off // Turn them both off
    // leds.stop().off(); // Combine!
  });

});

You should see the red and green LEDs alternating between on and off every second, and only one of the LEDs will be on at a time.

The interesting thing about this code is that it uses the Leds class - which allows us to control all the LEDs at the same time. At first, the green LED is off, and the red one is on. Then we blink the leds class; flipping the on/off state of each LED at the same time. You could use this to easily control many more LEDs.

Johnny-Five on tinylab.

8.17.2016

I got my tinylab last week; it's a nifty little prototyping board with an Arduino Leonardo and a bunch of embedded components that was funded on IndieGoGo. So naturally I wanted to get Johnny-Five working and start fiddling with the tinylab as soon as possible. Unfortunately, it seems like the hardest part of every hardware project is the grand upgrading of the softwares that must proceed fiddling. Here's the process that worked for me.

  1. Re-install Node. My Node installation was a few versions old, and somehow npm was missing. So I went ahead and installed Node.js from https://nodejs.org/en/download/. I decided to live dangerously and install the "Current" version rather than the Stable one.
  2. Upgrade Arduino.app. My Arduino install was older than the Leonardo, so I needed to upgrade it too. I got version 1.6.10 from https://www.arduino.cc/en/Main/Software.
  3. Upgrade npm packages. npm outdated showed that several packages (including Johnny Five) were out of date. This required a few rounds of npm update.
  4. Write the Johnny Five code. I checked the excellent Johnny Five docs and wrote this code for the first LED on the tinylab.
    var five = require("johnny-five");
    var board = new five.Board();
    
    board.on("ready", function(){
      var led = new five.Led(13);
      led.pulse(1000);
    });
    This should make LED1 (on pin D13) pulse on an off. At first I tried using "D13" to address the LED (since that's what's silk-screened on the board) but it was just 13 that worked.

Success!

Here is some tinylab documentation that might come in handy next time:

How to Make a Pee-Wee Runt Rover with Johnny-Five.

2.10.2016

A small two-wheeled robot powered with an Arduino, on top of a laptop with many stickers. Way back in May of 2015, I attended JSConf US to help with Bocoup's JS IRL Nodebots event. The robot kit was designed by Rick Waldron, and Rick and Francis Gullota soldered pin headers to all the the motor controllers before the event. We helped around 100 attendees build a nice little Nodebot, and everyone got to take home their kit. If you want to build your own, here's what you need:

Once you've got the bot running, there are a number of ways to extend it. Here's one that's controlled with an Xbox 360 controller (code).

More blogs about maker: