Comparing blank string definition in Python3

In python3 using

or

Produces the same result for the programmer. Which one is faster? Using the python module timeit, it’s really easy to find out!

Using string="" is WAY faster.

Here’s the source code for my tests:

StripPi – Software Demo, Roadkill Electronics

I’m constantly loosing the remote for my RGB LED strip lights, and I have a few days for spring break, time to get hacking. Here’s a demo and explanation video:

I don’t mention it in the video, but the cool part of this project is how the different processes communicate with each other. Rather than interacting with the different processes through pipes, or something like stdin, I’ve decided to use a TCP websocket server:

StripPi High Level Diagram

Processes on the device send RGB values to the Strip Server via a TCP packet. This very very easy to implement, and almost all of the hard work is taken care of via the socketserver  module included in python3. This also allows for interactions with that main process (the StripPi Server process) to take place off of the Raspberry Pi as well. I plan on writing an Alexa integration for this project moving forward, and this should make that a lot easier.

The analog to digital conversion is handled by an MCP3008, exactly the same way as I did it here.

Thanks for reading, more soon.

Singer Parts Drawer Holder

I use these Akro-Mils 10144 D sets of drawers to keep my various electronics components organized. They’re cheap, reasonable quality, but most importantly inexpensive.


drawer

Something that I find myself doing a lot is transferring individual drawers around. For example, I have a specific drawer that holds short jumper wires for breadboards. Sometimes I bring this drawer up to campus for working in the lab. Same goes for my misc-resistor drawer. It’s much easier to move the drawer rather than re-packing it.

The problem is that these are open drawers! They don’t have lids, so what I’ll do is put it in a ziplog bag and throw it into my backpack. This is a bad solution, I have a 3D printer, time to get CADing.

I wanted the drawer to be able to lock in place, so it wouldn’t slide out of the holder while in transit, here is a video of the locking mechanism in action:

As I iterated on this design, it became clear that I could get away with a pretty thin wall thickness, and that extending the slot cut made it much much easier to flex the locking mechanism, so the grab point on the outer surface became unnecessary.

Annoyingly, I couldn’t figure out a good solution to be able to use this part without having to use supports.

Here is the Thingiverse Link

If you’re interested, I’m keeping a page of all of my prints. You can find it here.

Tiny Apartment Improvement Project – Wire Shelf Keyboard Holder

I recently purchased a Prusa i3 MK2 and it is glorious. The price was right, the assembly was straightforward and the print quality is probably better than I will ever need. After printing the requisite amount of dogs and other figurines, it’s time to start using this tool to improve my life.

Keyboard Shelf

I store a lot of my equipment on wire shelves. They’re cheap, easy to move around, and pretty strong. They can hold a lot of stuff, which means I keep a lot on them, and space, much like in the rest of my apartment, is limited. The server that is hosting this webpage lives on one of these shelves, and sometimes I have to manually work on it with a keyboard and monitor. It is a pain to have to dig out a keyboard, but it’s also not worth it to have a keyboard permanently on the shelf taking up space. That desire to maximize space is the motivation behind this project.

Here is the thingiverse page for this project with the parts, if you end up building or modifying it, let me know!

I’ve also added a page on this blog for holding more of my work with 3D printing, this will get fleshed out more as time goes on.

Multiplexing Composite NTSC Video

This was one of those rare times where I had a hunch, followed it, and had a great result.

So for a project I’m working on for school, we have a robot with multiple composite video cameras onboard. We will be using those cameras seen on DIY drones or in simple security systems. We will be transmitting this video feed via a 5.8GHz video transmitter meant for a drone. We want the operator to be able to switch which feed they’re viewing at a given time, but we don’t want to have to use 3 transmitters and receivers. So to get around this, I thought we might just connect video feeds to a simple analog multiplexer I had laying around from a previous project and see if you could switch the feed that way. Turns out, you totally can. Here’s the eventual block diagram of this part of our project if you’re interested:

The following is the code running on the arduino. Remember, this isn’t doing anything special other than driving the mux:

RS485 Hardware Network 2 – Multi-Byte Communication

Edit: I don’t really make a point of saying it, but the common ground between the modules isn’t nesesarry.

Here’s a video of the software running on the boards.

So for this example,  there are 4 bytes being transmitted from the master to the slaves.

  1. Start of Transmission (0xDB)
  2. ID of the slave to talk to
  3. The type of command
  4. The data that is transmitted

A transmission to set the pwm value of the green led on the slave with the ID 1 to 100 would be:

This is the schematic of the circuit for this example:

This is the code running on the master Arduino:

This is the code running on the slave Arduinos:

RS485 Hardware Network 1 – Getting Started

For another project I’m currently working on, I need a way to control multiple microcontrollers in a multi-point, multi-drop network configuration. Luckily, we live in amazing times. As I write this, you you can buy a fully assembled breakout board for the MAX485 chip from Maxim Integrated for a mere $0.45 USD shipped from China.

I bought a 5 pack, here are some of the boards:

RS485 is an old protocol, but is the logical next step for devices I’m already communicating with via RS232. For this example, I’m using 4 Arduino boards of various types.

  • An Arduino Micro as the master
  • 2 Slave Arduino Leonardos
  • 1 Slave Arduino Pro Mini (5v)

Here is a video of the setup:

The schematic is really straightforward as well. The only tricky bit is that I’m using a software serial port on each of the Arduinos for ease of debugging. Here’s a schematic:

The code to acomplish this is really intuitive as well.

Here is the code for the master Arduino:

This is the code for the slave Arduinos:

In subsequent posts, things will start getting more advanced. For now however this should be enough to start from scratch.

Thanks for reading.

Raspberry Pi Digital Hourglass

Trying to get the most out of a day has been big theme of my life lately, as I’m sure it is for many people. I’ve found that I always manage my time better when things are urgent; I’m considerably more productive when I have to be.

I want an ascetically pleasing way to be able to represent how much time is left in the day at a granular scale, like an hourglass. Watching individual seconds disappear will look cool and (hopefully) create that sense of urgency that I want to induce.

Technically, this is a really simple thing to accomplish thanks to python and pygame. Here’s a video of a proof of concept running on my laptop:

At the start of each day, the display is filled with squares at random locations, with a random color. As each second elapses, a square will vanish.

To make it easier to see for the video, I’ve made the squares much bigger than they will actually be for the final build. This is what the display looks like with the squares at their actual size:

The code really really simple, like less than 100 lines simple. Here’s how it works:

Here’s the version of the code running on my computer in the video:

Let’s walk through some of the design decisions of this code. The first thing that’s worth talking about is how the data for the squares is handled:

It’s just an object with no methods, and on initialization, all the parameters of the square (location and color) are generated randomly as opposed to just floating the raw numbers in arrays around (even though that’s basically what is happening). This let’s us fill the squares array very easily later on in the file here:

and here:

When it comes time to draw these squares, it also makes that pretty intuitive:

Again, very simple stuff, but worth it to talk about.

I’ll be back at my place that has the Raspberry Pi and display I would like to use for this project, so more on this then.

Thanks for reading!

UV Resin Curing Cabinet | Final Code, Schematic, Bill Of Materials and Demo

Here’s a demo of the finished system:

In the end, it all turned out really well. Painting it white and using a white print stand was a good insight, the light reflects around the box pretty well for how few LEDs are in use.

The software flow chart has changed slightly. I removed the speaker as it wasn’t loud enough and added software debouching for the pushbutton interrupt service routine. Here’s that most recent version:

 

The interesting parts of the code are the cookResin function as well as the main loop of the Arduino:

Again, this all should all be explained by the flow chart. The full source can be found at the bottom of this post.

The circuit schematic hasn’t changed at all since this post, here’s a fritzing of what’s going on:

Super simple, basically a screen and a button. The parts to make this are here:

Assembly is super straight forward, if you’re trying to build one and have any questions, let me know!

All of the files necessary to make this project can be found here.

Thanks for reading!