Figures 8-3 and 8-4 show the pair of Photons with their tempting lengths of string to be pulled. One is in a wooden box, adding to the mystery.

This project is excerpted from Make: Getting Started with the Photon.
On sale now.

The Magic Rope project, which utilizes a Photon, was inspired by Leena Ventä-Olkkonen, Tobi Stockinger, Claudia Zuniga, and Graham Dean, who showed how a public installation could be made that would allow large maps of the world to be positioned in various public spaces in a city.

These maps would have short lengths of rope sticking out of holes on the map corresponding to other cities around the world. The idea is that the public at any one of these cities (let’s say London) could walk up to a rope at their map, pull on it, and the paired rope in the other city (say, New York) would be pulled into the map, attracting the attention of people near the installation. A gentle exchange of rope pulling could then occur across the world.

The original project was developed only as a concept and not actually implemented as a real installation. In this project, you will make a pair of “entangled” ropes that could be positioned in different cities. This could be used as a nice way of staying in touch with distant relatives.



To build this project, you need two sets of each of the parts listed in Table 8-1 in addition to two Photons/Cores.

table 8-1

The sliding pots (potentiometers) used in this project are variable resistors intended for use in automated music-mixing desks. You can adjust the resistance by sliding the “slider” up and down the length of the pot, but there is also a little motor that will move the slider by using a toothed belt drive.

These motorized pots do not have leads attached to the pins, so this is one project where you will need to use a soldering iron and attach some leads to the pins.


Both ends of this project have exactly the same software running on them, and you can find it in the file p_15_Magic_Rope in the PHOTON_BOOK library; code examples are available for download here.


The original version of this file has some extra commands commented out that can be used to debug the project if the events don’t seem to be getting through. See the comments in the original program if you need to use them.

The program starts by defining the two pins to be used. A0 is for the voltage output of the potentiometer, which will be 0V if the rope is fully pulled out, and 3.3V if the rope is fully pulled in.

The boolean variable myTurn is used to keep track of whose turn it is to pull on the rope. If myTurn is set to true, then it is this device’s turn to have its rope pulled.

Both ends of this project both publish and subscribe to the same event, so the variable thisID is needed so that the device knows its own ID and can disregard its own publish events, reacting only to events coming from the other Photon/Core.

The constant maxPosn is the analog input reading at which the sliding pot is at the position where the rope is fully pulled in. This is set slightly lower than the theoretical maximum analog input value of 4095 to allow for any inaccuracy in the analog readings.

The second constant, minPosn, is equivalent to about three quarters of the way pulled in, and this is the threshold at which a “pulled” event will be published.

The setup function makes the necessary subscription to “pulled” associating it with the function remoteRopePulled. It also calls the function moveSliderTo to position the slider at its fully pulled-in position, ready to be pulled out.

The loop function reads the analog input to find the newLocalPosition. If this is less than the minPosn constant and it’s this device’s turn to move, then the “pulled” event is published with this device’s ID as its parameter.

In the situation where the rope has been pulled on the other Photon/Core, the function remoteRopePulled will be called. This function will be supplied with the ID of the device where the rope was pulled, so that it can be compared with thisID, the ID of the receiving Photon, by searching for the string of characters in thisID within the ID passed in data.

If the event has come from a remote Photon/Core, the slider is pulled fully in, and myTurn is flipped over to true.

The function moveSliderTo handles all automated movement of the slider. In fact, it can only pull the slider in. But you can’t push rope, so that’s fine. The function takes the new position as a parameter and keeps power supplied to the motor until such time as the measured position is no longer less than the desired position.


The breadboard layout for this project is shown in Figure 8-5.

The motorized pots are actually stereo devices, but we need only one channel for this project. This means that there are some pins that you do not need to connect leads to. Figure 8-6 shows the underside of the motorized pot. You can see the motor at the bottom right.


Before assembling the breadboard, you will need to solder some wires to the motorized pot legs. The motor leads are easily identified. If you are using the same motorized pot as I am, attach a red lead to the bottommost motor lead (as shown in Figure 8-6) and a black lead to the other motor lead. All leads need to be about 6 inches long to comfortably reach the breadboard.

At the far end of the motor, attach a red lead to the rightmost lead. This is the lead that will go to 3.3V on the breadboard. Attach a yellow or orange lead to the rightmost pin at the motor end of the pot. This lead is the slider of the pot that will connect to A0 on the Photon/Core. Finally, connect a brown or blue lead next to this yellow lead. This will connect to GND on the breadboard.


Finally, connect everything as shown in Figure 8-5, paying special attention to the transistor and diode, to make sure they are the right way around. The diode has a stripe at one end that should be toward the top of the breadboard, and the transistor has one curved side.

Driving motors can result in voltage spikes, and the diode protects the Photon/Core from accidental damage resulting from these spikes.

Using the Project

To use the project, power up both ends of the magic rope. After the Photon/Core has finished starting up (flashing green light), the motor should activate on both ends of the project, pulling the slide up to one end of the track.

Pull on one of the strings and then the other. When you pull on the second string, the first string should be pulled back automatically.

You could find a nice wooden box for this project, drilling a hole for the string to emerge at one end and a hole for the USB lead at the other.


Use of publish and subscribe is very powerful, and opens up all sorts of possibilities for collaborative projects where people can interact physically over the Internet.

Dr. Simon Monk has a degree in Cybernetics and Computer Science and a Ph.D. in Software Engineering. Simon spent several years as an academic before he returned to industry, co-founding the mobile software company Momote Ltd. He has been an active electronics hobbyist since his early teens. Simon is now a full-time author; his books include 30 Arduino Projects for the Evil Genius, 15 Dangerously Mad Projects for the Evil Genius, and Arduino + Android Projects for the Evil Genius.

Note: This project is excerpted, with permission, from Dr. Simon Monk’s new book, Getting Started with Photon. The $19 microcontroller from Particle, the Photon, is open source, WiFi-enabled, and the successor to the original Spark Core.