# A Card Magic Trick Explained

## Interesting simple math behind

I just saw a fun card magic trick by MLT Magic Tricks (on youtube). The trick itself was well executed and explained, but I still screwed up on my first try. And there are other people in the comment area experiencing issues as well.

First of all, my problem was that I used a 54-card deck, instead of a 52-card deck.

If that doesn’t quickly fix your issue, please allow me to explain the math behind the magic trick. …

# NeoPixel Assisted String Art Weaving

## a semi-automatic method

One interesting form of string art starts from a circular or square canvas with nails on its perimeter. The strings/yarns are only wound around nails on the perimeter. The repeated straight lines can sketch out a portrait nicely(link to Petros Vrellis).

Here are bunch of other examples on Hackaday.

This is a cool algorithm implemented in Processing language (github link). Basically, you input an image, the program will output a list of sequential nail locations that the string needs to traverse, which is also called a weaving pattern.

(Additional Hough transformation may reduce the thread count, to be explored https://rosettacode.org/wiki/Hough_transform#J)

# DIY Electronics Enclosure

## Electronics are cheap

Electronic modules are getting smaller and ever more powerful. For example, modern MCUs are packed with capabilities, and at a very low cost. In addition, making a custom PCB (via JLCPCB for example) is often more time/cost efficient than breadboarding. These are all good news for DIY electronics fans.

I still remember the old times when I had to save lunch money to buy a single transistor, and then went sad for days after unknowingly damaged it, probably due to ESD.

Although you can now DIY electronics cheap and easy, one thing still remains costly.

# Electronics PCB Mount on LEGO

## A Useful Hack

In Electronics PCB world, `0.1"` is a standard spacing or pitch for ICs, connectors etc. for many, many years.

In LEGO world, `8mm` pitch and `4.8mm` diameter hole is its gold standard. (LEGO brick dimension drawing link)

Here is a useful trick to unite the two together with LEDs.

You simply spread several `0.1"` through-hole LEDs (5mm OD LED on LCSC) on your PCB, with `8mm` spacing center-to-center.

Once you solder the through-hole LEDs, the PCB can plug into any LEGO piece or technic beam very tightly.

After that, it’s only limited by your LEGO imaginations to e.g. …

# Origami Electronics Enclosure

## Custom Design Modula Origami Box

In an effort to make a minimalist digital clock, I was looking for an easy to construct enclosure for all the small electronics modules, such as AAA battery, display modules, and MCU boards etc.

Yes, 3D printing is still outside of my skill set.

Interestingly, I’ve seen origami paper boxes, as introduced in this youtube video (link), which can be traced back to Tomoko Fuse’s earlier books (Amazon link). In her recent 2018 book, she used the term “modular origami”, which roughly speaking is a technique of stacking cleverly multiple identical origami pieces, called modules, to form a complex 3D…

# FT232H with HT16K33

## Rust Jupyter and Display Module

HT16K33 (datasheet link) is very similar to TM1637. It is also widely used in display modules such as Adafruit 8x8 LED matrix (schematic link and LED hardware link), or this 4-letter pHAT module (link).

Again Adafruit provides nice Arduino/Python language support (link) for its modules and HT16K33. But we can certainly experiment on HT16K33 with a FT232H module as well.

Comparing with TM1637, in terms of its I2C interface and digital commands, HT16K33 has the two main differences: the opcodes and that its I2C byte order is MSB first. …

# Rust on STM32F103 Blue Pill with Probe-run tooling

## quick start

Rust embedded software tooling is always an interesting alternative to MCU vendor specific IDE software, such as those provided by TI, Microchip, STM32, Nordic, etc.

With the advent of probe-rs and subsequently probe-run software, Rust for embedded coding can take a different path from `openocd + gdb`, and it is getting more convenient.

There are already lots of cortex-m quick-start guides, especially of STM32F103 “Blue Pill”. Unfortunately, Rust library such as `stm32f1xx_hal` is changing fast. For example, the `Timer` now is initiated differently from the past.

Here is my latest try get it up and running:

1. get hardware: STM32F103C8T6 module…

# Comments on Dr. Middlebrook’s Differential Amplifiers Book

## Answers to my earlier questions

In my earlier article two years ago, I mentioned Bob Peace’s comment of Dr. Middlebrook’s “differential amplifier” book. (link)

Here is my answer to four of my own questions. (Sorry for the long delay in between.)

## local and global constraints of circuit analysis

Electrical circuit analysis for human designer is a bit like solving Sudoku puzzle.

In Sudoku, there is the local rule or constraint: no duplicates in each 3x3 square. Then there is the global constraint: rows, and columns across multiple squares can not have duplicate numbers. You have to satisfy both the local and global constraints.

In circuits, the local constraint is the device/component f(I,V)…

# Middlebrook’s input/output impedance theorem

## a simple example

A “low-entropy” equation that depicts the circuit behavior can help analog designers work backwards, finding values of the circuit elements in order to meet the specification.

Let’s start from the output impedance of a simple linear circuit.

A common procedure of determining the output impedance is by: shorting input to ground, and look into the output port, to “see” the output impedance. In this simple case (Fig. 1), we can “see” R₁ ∥ R₂

When the circuit becomes more complicated, it is difficult to “see” the output impedance directly. One way is to inject a current and calculate the resulting…

# FT232H with IS31FL3731

## Charlieplexing

Charlieplexing is an interesting technique to drive lots of LEDs with smaller number of output lines. The idea is very simple, given two output lines, you can drive two anti-parallel LEDs, in a circuit like the following.

X1 = positive and X2 = negative lights up LED1; X1 = negative and X2 = positive lights up LED2. If you need both LEDs to light up, just time-division multiplexing the positive and negative signals on X1 and X2, which flashes LED1 and LED2 fast.

Given N output lines, pick any pair of two lines to place two anti-parallel LEDs, you can…

## circuit4u

Get the Medium app