Use Photon to Make a Mysterious Interactive Magic Rope Box

Internet of Things Technology
Use Photon to Make a Mysterious Interactive Magic Rope Box
8-3
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.

8-4

Parts

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.

Software

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.

code1code2

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.

Hardware

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.

8-58-6

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.

transistors

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.

Summary

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.

YouTube player

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.

Tagged
Discuss this article with the rest of the community on our Discord server!

ADVERTISEMENT

FEEDBACK