Skip to main content

Solenoid Machines

Solenoid Machines
replace this text

A solenoid is a type of electromagnet which does a push or pull motion. I used to think controlling a solenoid would be complicated because it would require an advanced micro controller such as Arduino, jump wires, breadboard, soldering, text based coding, etc. 

But when we hosted an artist-in-residence Maywa Denki, Tosa-san, the leader of the group, showed us how easy it is now to control the solenoids.  He showed us a 5v solenoid that you could simply plug into a USB port and program with Scratch via micro:bit. All of this was made possible by a micro:bit shield called "Solekit" made by a company Takaha in collaboration with Maywa Denki. I was very excited. 

Earlier this month, when we hosted a BAME meetup (a gathering of local maker educators: Bay Area Maker Educators meetups), we took the opportunity to try out this new idea and tools. This blog post recaps what we shared and learned during the BAME event. There is lots of information here: 1) Preparing for the workshop, 2) During the workshop, and 3) Reflections. Bear with me :)


1. Preparing for the workshop

1.1 Collect the materials

Here is the minimum* list of electronic components. *One set was used for each group of 1 to 3 people. Since you can connect up to three solenoids with one Solekit controller, we prepared this 8 sets for the event (each with 3 solenoids).


1.2 Connect Solekit and micro:bit

Next connect a micro:bit with a Solekit with #4 machine screws. The pictures below show the orientation and which pins to connect. You will need a tiny screw driver, 4 screws, 4 nuts, and 4 spacers for this step. The Solekit board was designed to have hole positioned perfectly to make the connections from the miro:bit’s Pins 0, 1, and 2 and GND (Ground).


1.3 Download a hex file and Scratch Link: 

1) To download a hex file to your micro:bit, connect a micro:bit to your computer with a USB cable. 

Go to this page:

Click the purple “Edit” button. After the project has loaded, Click the purple “Download” button. (See screenshots below.)


replace this text

Download "Micro:bit more" HEX file onto your computer. Then drag and drop the HEX file onto your micro:bit. Your micro:bit will ask you to "Tilt to fill the screen." Tilt your micro:bit in all directions until the LED screen is filled. When done, a smiley face will be displayed. Your micro:bit is ready!

2) To download Scratch Link:

3) Go to a Scratch extension site to get started!

We used an experimental Scratch extension “Micro:bit more” created by Koji Yokokawa.


In addition to the standard Micro:bit extension blocks, these blocks are available for the Micro:bit More extension. For the push-pull motion of the solenoids, we used the block “Set digital 0/1/2 Low/High” enclosed in the red box in the picture.  Each digital pin 0, 1, and 2 corresponds to a different solenoid that you will be connecting to the Solekit.

2. During the workshop:

We had done all the steps above in preparation for the BAME event, so the participants actually started from here: connecting each component.

2.1 Connect the components:

1) Connect the solenoid to the Solekit. Insert the USB cord into the USB port adjacent to the red, yellow, or green button (blue* is not addressable in this interface). *It is addressable with other micro-controllers such as Arduino and RaspberryPi.

2) Provide power to the solenoid control board by connecting one of the two mini USB power connectors to a USB power source. It could be a computer or a USB hub. A green LED on the Solekit board will light up. 

3) Micro:bit also needs power. Flip over the Solekit board and plug a 2-AA battery pack into the micro:bit board to power it. You will see the five-character micro:bit name scroll across the LED array (e.g. 'zutiz’).

4) Pair up your computer with your micro:bit via bluetooth. Click on the orange icon next to the “micro:bit more” header (Make sure your Scratch Link is running when doing this). In the pop-up window, you will see your micro:bit name listed. The orange icon will turn into a green circle with a white check mark when it is connected. 


2.2 Prepare other materials:

We prepared these materials and tools so that the participants could build all kinds of whimsical machines using the linear push-pull motion of solenoids, such as marble machines or sound machines. 

For Building:

Cardboard sheets and scraps

 - Wooden blocks/dowels

 - Glue guns

 - Saws

 - Power drills

replace this text

For Sound Explorations:

- Bells

 - Xylophones

 - Shakers

 - Drums

 - Percussive beads / balls / marbles

 - Any sound makers​​​​​

replace this text



We also prepared several housings or structures for solenoids to support a specific movement that each sound maker would require: (left) an up & down motion for a mallet, (center) a vertical linear motion for pounding a drum, (right) a horizontal linear motion to ring a bell. Making some solenoids available in secure housings allowed a few participants to get started immediately with sound play and coding. 

To secure solenoids:

replace this text

But of course, for some parcitipants who wanted to build their own solenoid mechanisms from scratch, we also had many "bare" solenoids available. When building a solenoid machine, it was critical to secure the solenoid so it wouldn't move, but at the same time you'd want it to be able to tweak and modify the position many times. For that purpose, we found 3M 4910 VHB Double-Sided Tape worked pretty well. The tape is super strong and yet it peels very neatly to allow for easy repositioning.


3. Reflections:

Participants created many more different kinds of solenoid machines than I expected. Some people decided to build their own structure to hold a solenoid, others started playing the instruments immediately using the solenoid housing that we had prepared. Participants all appreciated that solenoids were able to perform such a precise and fast push-pull motion, and such instanteneous motion made it possible to play musical instruments such as bells, drums, and xylophones very nicely, with greater precision than with motors or servos.  

One teacher thought that solenoids could offer a good conceptual bridge for her robotics students. Motors, she shared, are easy for students to use because whether they attach them one way or another, the motor spins. If the rotation is in an unexpected direction, the students switch the wires. She recalled the difficulty her students face using servos, because it has not just two but three wires. The solenoids in the Solekit would be a convenient step between motors and servos as the students explore different kinds of motion.

We also noticed that the solenoids we used could push but they couldn’t pull back. In order to return the plunger to the initial position, we needed to introduce a returning force, using a spring or a rubber band. In some cases, we could just rely on gravity to reset the plunger.



Here is my favorite instrument that came out during the event. A simple & delightful shaker :)


Ryan decided to create a marble release mechanism using the push motion of the solenoid. It was very interesting to think about what could be the input since many different sensors were available with the Micro:bit More extension (in this video, Ryan was using a "Shake" sensor)


Another great thing about these solenoids is that they come with a little switch that you can use to activate the push-pull motion. It allowed us to work with the movement of the solenoid without programming, which felt like very rich tinkering time for us, especially when figuring out the mechanism. 


All in all, working with solenoids was really fun. You can think of many different forms of output: various musical instruments, simple moving toys, and marble machine mechanisms. It will be even more fun if we think of some interesting inputs using the micro:bit sensors. I'm excited to imagine how we may further develop this activity. 

replace this text

This work was supported by a grant from Science Sandbox, an initiative of the Simons Foundation