Introduction: How to Make a 'Glowing Crosswalk' Urban Prototype
A “Glowing Crosswalk” is a traffic-calming mechanism that creates a path of light across an intersection in order to improve the visibility of pedestrians to oncoming traffic as they cross through the path. I created and exhibited a prototype of this urban design concept for the San Francisco Urban Prototyping Festival in October, 2012. This Instructable describes how to make such a prototype. Please note that this prototype was designed and built for a temporary installation only. Some modifications will be necessary to create a more permanent installation (not to mention various city permits and other legal approval).
This Glowing Crosswalk prototype consists of four, free-standing “light poles” that are to be placed in pairs on the sidewalk on either side of an intersection. Each light pole features three high-powered LED lights and a “push-to-cross” button switch. When a pedestrian approaches the intersection and pushes the switch on any of the poles, a radio frequency signal is sent to the other three poles and they all run an identical program in unison. The program cycles the lights through an “on”, “blinking” and “off” phase (similar to existing crosswalk light sequences). The following steps will describe the process for making one of these light poles.
The effect of the Glowing Crosswalk is a temporary field of light that not only illuminates the crossing path but, most importantly, illuminates anyone moving through the crossing path as the light reflects off their body, making the pedestrian more visible to oncoming traffic.
This Glowing Crosswalk prototype consists of four, free-standing “light poles” that are to be placed in pairs on the sidewalk on either side of an intersection. Each light pole features three high-powered LED lights and a “push-to-cross” button switch. When a pedestrian approaches the intersection and pushes the switch on any of the poles, a radio frequency signal is sent to the other three poles and they all run an identical program in unison. The program cycles the lights through an “on”, “blinking” and “off” phase (similar to existing crosswalk light sequences). The following steps will describe the process for making one of these light poles.
The effect of the Glowing Crosswalk is a temporary field of light that not only illuminates the crossing path but, most importantly, illuminates anyone moving through the crossing path as the light reflects off their body, making the pedestrian more visible to oncoming traffic.
Step 1: Step 1: Bill of Materials
When I created this project for the Urban Prototyping Festival I was operating under a number of constraints, most significantly money and time. I had only a few weeks to pull this whole project together, working during weeknight evenings and weekends so I tried to use as few custom components as possible. As for the budget, the whole project was supposed to be able to be prototyped for under $1000.00 (I ended up exceeding it by about $50).
Here are the components I used to create all four "light poles" used to create the Glowing Crosswalk:
[12x] Light bulb (Ultrafire Cree Xm-l T6 LED 1mode 1000 Lumens 3.7-18v) (from Amazon)
[12x] 18650 3000mah li-ion battery (from Amazon)
[4x] 18650 battery holder (from Digi-Key)
[4x] Umbrella stand (from Pottery Barn)
[4x] Arduino Uno (from Jameco)
[4x] Grove RF- Base Shield (from Epic Tinker)
[4x] Grove - 433MHz Simple RF Link Kit (including a transmitter and a receiver) (from Epic Tinker)
[8x] Grove - Universal 4 Pin 20cm Cable (to connect the transmitter/receiver to the Base Shield) (from Epic Tinker)
[4x] 4” Dia. x 47” Aluminum pipe (ordered cut-to-size from a 20' stock piece at Bayshore Metals)
[4x] 1-1/2” Dia. x 5’ PVC pipe (from any hardware store)
[1x] 1-1/4” Dia. x 2’ PVC pipe (from any hardware store)
[1x] 3” x 2’ ABS DWV Pipe (from any hardware store)
[1x] spool of 20ga galvanized steel strip (from any hardware store)
[1x] 4” Dia. x 12” Acrylic tube (from TAP Plastics)
[4x] 4” Dia. x 1/8” thick acrylic circle (or [1x] 12” x 12”, 1/8” thick acrylic sheet)(from TAP Plastics)
[1x] scrap plywood
[1x] Assorted package of rigid jumper wire (for breadboard)(from Radioshack)
[1x] Assorted spools of 18ga. solid hookup wire (from Radioshack)
[4x] 9V battery
[4x] Breadboard (from Jameco)
[4x] Button momentary switch (from Radioshack)
[4x] Heat sink, TO-220, 1 HOLE (from Jameco)
[4x] TIP 120 NPN Darlington Transistor (from Jameco or Radioshack)
[4x] 2.2K Ohm resistor (from Jameco or Radioshack)
[4x] 10K Ohm resistor (from Jameco or Radioshack)
Tools:
I used a variety of tools, both hand-held and stationary. I try to specify a recommended means of manufacture though most of my build process could be performed using alternative approaches. I relied heavily on the local TechShop for most of the build. It was very helpful to have all the tools I needed in one location along with the space to spread out and work continuously.
Here are the components I used to create all four "light poles" used to create the Glowing Crosswalk:
[12x] Light bulb (Ultrafire Cree Xm-l T6 LED 1mode 1000 Lumens 3.7-18v) (from Amazon)
[12x] 18650 3000mah li-ion battery (from Amazon)
[4x] 18650 battery holder (from Digi-Key)
[4x] Umbrella stand (from Pottery Barn)
[4x] Arduino Uno (from Jameco)
[4x] Grove RF- Base Shield (from Epic Tinker)
[4x] Grove - 433MHz Simple RF Link Kit (including a transmitter and a receiver) (from Epic Tinker)
[8x] Grove - Universal 4 Pin 20cm Cable (to connect the transmitter/receiver to the Base Shield) (from Epic Tinker)
[4x] 4” Dia. x 47” Aluminum pipe (ordered cut-to-size from a 20' stock piece at Bayshore Metals)
[4x] 1-1/2” Dia. x 5’ PVC pipe (from any hardware store)
[1x] 1-1/4” Dia. x 2’ PVC pipe (from any hardware store)
[1x] 3” x 2’ ABS DWV Pipe (from any hardware store)
[1x] spool of 20ga galvanized steel strip (from any hardware store)
[1x] 4” Dia. x 12” Acrylic tube (from TAP Plastics)
[4x] 4” Dia. x 1/8” thick acrylic circle (or [1x] 12” x 12”, 1/8” thick acrylic sheet)(from TAP Plastics)
[1x] scrap plywood
[1x] Assorted package of rigid jumper wire (for breadboard)(from Radioshack)
[1x] Assorted spools of 18ga. solid hookup wire (from Radioshack)
[4x] 9V battery
[4x] Breadboard (from Jameco)
[4x] Button momentary switch (from Radioshack)
[4x] Heat sink, TO-220, 1 HOLE (from Jameco)
[4x] TIP 120 NPN Darlington Transistor (from Jameco or Radioshack)
[4x] 2.2K Ohm resistor (from Jameco or Radioshack)
[4x] 10K Ohm resistor (from Jameco or Radioshack)
Tools:
I used a variety of tools, both hand-held and stationary. I try to specify a recommended means of manufacture though most of my build process could be performed using alternative approaches. I relied heavily on the local TechShop for most of the build. It was very helpful to have all the tools I needed in one location along with the space to spread out and work continuously.
Step 2: Step 2: Test the Lights
• wire batteries in series
• wire lights in parallel
• connect lights to batteries
The most important component of this project is the lights. They need to be bright enough to compete with the surrounding ambient light (from overhead street lamps, storefront displays, and car headlights). It can be hard to visually distinguish a pedestrian from their surroundings when they are crossing a street at night, particularly at an intersection without a marked crossing path. Flooding the crossing path with light that is brighter than the immediate surroundings creates an area of high contrast which our eyes are naturally drawn to. When a pedestrian crosses through this light they become more visible to oncoming motorists and cyclists.
For this prototype I used high-powered LED flashlight bulbs (Cree XM-L Ultrafire single-mode 1000 lumen output). These were the best lights I could find that met all my constraints: super-bright, shipped from the U.S. (I needed them fast), compact, affordable (I needed to keep within a $1000 budget for the whole project), plug-n-play form factor (built-in heat sink and reflector housing for the LED saved time and effort), already setup to run off battery power.
[CAUTION: These lights really are bright. Very bright. Do NOT stare at them directly. In an ideal installation the lights for the Glowing Crosswalk would be positioned and enclosed in such a way that the LEDs would not be directly visible (under most circumstances).]
So the first step is to make sure the lights work. To do this we’ll need to connect them to a power supply. Normally each of these light bulbs is paired with one 18650 li-ion battery in a flashlight. I thought it would be best to use three lights per pole in order to get a sufficient spread of light across the street. Therefore I used three batteries per pole. I purchased a 3-cell battery holder from Digi-Key (part # BK-18650-PC6-ND). The three 18650 batteries need to operate in “series” so we need to solder wire between a few of the PC mounts and at the ends so that we have wired (+) and (-) connection points. Be sure to keep track of which side is positive and which side is negative. I tried to use red wire for (+) and black wire for (-) whenever possible.
[CAUTION: Do not connect the (+) terminal of a battery to the (-) terminal. This can destroy the battery, create a mess, and possibly catch fire and harm you or others]
Next we need to connect wires to the light bulbs. Initially you can just use alligator clip leads and/or small amounts of wire tied to the terminals of the light bulb. We’ll get the appropriate lengths later. Each of the light bulbs should have two wires attached, one to the negative (-) terminal (the outer coil) and one to the positive (+) terminal (the inner coil). We want the lights to operate in “parallel” so we need to connect all the (+) ends of the wires together into one connection point and do the same for the (-) ends. To accomplish this I used needle-nose pliers to "braid" the exposed ends of the wires together.
Then connect the (+) end of the light set to the (+) end of the battery pack. Do the same for the (-) ends and the lights should turn on.
• wire lights in parallel
• connect lights to batteries
The most important component of this project is the lights. They need to be bright enough to compete with the surrounding ambient light (from overhead street lamps, storefront displays, and car headlights). It can be hard to visually distinguish a pedestrian from their surroundings when they are crossing a street at night, particularly at an intersection without a marked crossing path. Flooding the crossing path with light that is brighter than the immediate surroundings creates an area of high contrast which our eyes are naturally drawn to. When a pedestrian crosses through this light they become more visible to oncoming motorists and cyclists.
For this prototype I used high-powered LED flashlight bulbs (Cree XM-L Ultrafire single-mode 1000 lumen output). These were the best lights I could find that met all my constraints: super-bright, shipped from the U.S. (I needed them fast), compact, affordable (I needed to keep within a $1000 budget for the whole project), plug-n-play form factor (built-in heat sink and reflector housing for the LED saved time and effort), already setup to run off battery power.
[CAUTION: These lights really are bright. Very bright. Do NOT stare at them directly. In an ideal installation the lights for the Glowing Crosswalk would be positioned and enclosed in such a way that the LEDs would not be directly visible (under most circumstances).]
So the first step is to make sure the lights work. To do this we’ll need to connect them to a power supply. Normally each of these light bulbs is paired with one 18650 li-ion battery in a flashlight. I thought it would be best to use three lights per pole in order to get a sufficient spread of light across the street. Therefore I used three batteries per pole. I purchased a 3-cell battery holder from Digi-Key (part # BK-18650-PC6-ND). The three 18650 batteries need to operate in “series” so we need to solder wire between a few of the PC mounts and at the ends so that we have wired (+) and (-) connection points. Be sure to keep track of which side is positive and which side is negative. I tried to use red wire for (+) and black wire for (-) whenever possible.
[CAUTION: Do not connect the (+) terminal of a battery to the (-) terminal. This can destroy the battery, create a mess, and possibly catch fire and harm you or others]
Next we need to connect wires to the light bulbs. Initially you can just use alligator clip leads and/or small amounts of wire tied to the terminals of the light bulb. We’ll get the appropriate lengths later. Each of the light bulbs should have two wires attached, one to the negative (-) terminal (the outer coil) and one to the positive (+) terminal (the inner coil). We want the lights to operate in “parallel” so we need to connect all the (+) ends of the wires together into one connection point and do the same for the (-) ends. To accomplish this I used needle-nose pliers to "braid" the exposed ends of the wires together.
Then connect the (+) end of the light set to the (+) end of the battery pack. Do the same for the (-) ends and the lights should turn on.
Step 3: Step 3: Calculate Light Position
• take light set and battery pack out to the street
• find the desired light position and take note
Once the lights are working the next step is to take them to an intersection at night and figure out what position they should be at inside the light poles. I recommend taping the lights to a tall ruler (yard stick) so that you can easily identify the appropriate height.
My goal was to have the spread of light from each of the three bulbs in each light pole cover the area starting from the adjacent curb to almost touching the far curb (the curvature of the roadway makes this hard to detect in the photo). I ended up selecting to place the lowest light at approximately 20” up from the sidewalk pavement, the middle light at 27” and the top light at 34”. I also used a protractor and level to measure the angle of the light bulbs. Each was angled down approximately 10° from the horizontal.
• find the desired light position and take note
Once the lights are working the next step is to take them to an intersection at night and figure out what position they should be at inside the light poles. I recommend taping the lights to a tall ruler (yard stick) so that you can easily identify the appropriate height.
My goal was to have the spread of light from each of the three bulbs in each light pole cover the area starting from the adjacent curb to almost touching the far curb (the curvature of the roadway makes this hard to detect in the photo). I ended up selecting to place the lowest light at approximately 20” up from the sidewalk pavement, the middle light at 27” and the top light at 34”. I also used a protractor and level to measure the angle of the light bulbs. Each was angled down approximately 10° from the horizontal.
Step 4: Step 4: Assemble Base
• find something heavy to keep the light pole from tipping over
• assemble or modify the base so that it will securely support the exterior and inner piping
The light poles will need a sturdy base to keep from tipping over when someone pushes the button to cross. It is also important that the light poles do not rotate for it will disrupt the appearance of the illuminated crossing path. For this prototype I used an off-the-shelf umbrella stand from Pottery Barn. While this contributed heavily to the cost of construction ($80/piece, on sale) it was an immediately available solution (time was of the essence) and it was an almost ideal fit, functionally and aesthetically.
The stand came with a few loose pieces that needed to be assembled. I chose to use 4” dia. aluminum pipe for the exterior housing of the light pole. In order to make this a snug fit around the 2” dia. I created a “donut” out of scrap plywood. The donut slides snugly over the pole of the umbrella stand and fits snugly within the 4” diameter aluminum pipe. I cut a bunch of these out on a laser cutter using a simple tool path created in Illustrator. I had to create a notch in the inner circle so the donuts could slide over the bump-out in the umbrella stand pole (for a tightening screw that is not used in this assembly). To improve stability and minimize materials I cut a section of 3” dia. plastic pipe to use as a space between a lower and upper set of donuts.
• assemble or modify the base so that it will securely support the exterior and inner piping
The light poles will need a sturdy base to keep from tipping over when someone pushes the button to cross. It is also important that the light poles do not rotate for it will disrupt the appearance of the illuminated crossing path. For this prototype I used an off-the-shelf umbrella stand from Pottery Barn. While this contributed heavily to the cost of construction ($80/piece, on sale) it was an immediately available solution (time was of the essence) and it was an almost ideal fit, functionally and aesthetically.
The stand came with a few loose pieces that needed to be assembled. I chose to use 4” dia. aluminum pipe for the exterior housing of the light pole. In order to make this a snug fit around the 2” dia. I created a “donut” out of scrap plywood. The donut slides snugly over the pole of the umbrella stand and fits snugly within the 4” diameter aluminum pipe. I cut a bunch of these out on a laser cutter using a simple tool path created in Illustrator. I had to create a notch in the inner circle so the donuts could slide over the bump-out in the umbrella stand pole (for a tightening screw that is not used in this assembly). To improve stability and minimize materials I cut a section of 3” dia. plastic pipe to use as a space between a lower and upper set of donuts.
Step 5: Step 5: Cut Holes in Tubes
• mark hole locations
• cut holes in exterior aluminum pipe
• cut holes in interior "spine" pipe (on both sides)
• cut inner tube down to size
Take note of the resting height of the aluminum pipe. In this scenario the aluminum sits 4" above the ground (important to note when marking the locations of the lights). I ordered the aluminum from Bayshore Metals in San Francisco. They provided 5 pieces, cut at 47" in length from 20' stock for about $140.
Using the ruler as a straight edge, mark the locations of the lights in a consistent line along the length of the pipe. Use a 1-1/4" hole-saw bit to drill the holes in the aluminum. I used a hand-held drill to cut the aluminum but I highly recommend using a drill press.
Once you've cut the aluminum, place it on the base and insert the "spine" (1-1/2" PVC pipe) into the center of the base, making sure it slides all the way to the bottom. Mark the centers of the holes on the "spine" and then drill holes on both sides with a 7/8" hole-saw bit. The reason for drilling a hole on the back side is so you can run the wires from the light straight though the "spine" and have them accessible on the outside.
• cut holes in exterior aluminum pipe
• cut holes in interior "spine" pipe (on both sides)
• cut inner tube down to size
Take note of the resting height of the aluminum pipe. In this scenario the aluminum sits 4" above the ground (important to note when marking the locations of the lights). I ordered the aluminum from Bayshore Metals in San Francisco. They provided 5 pieces, cut at 47" in length from 20' stock for about $140.
Using the ruler as a straight edge, mark the locations of the lights in a consistent line along the length of the pipe. Use a 1-1/4" hole-saw bit to drill the holes in the aluminum. I used a hand-held drill to cut the aluminum but I highly recommend using a drill press.
Once you've cut the aluminum, place it on the base and insert the "spine" (1-1/2" PVC pipe) into the center of the base, making sure it slides all the way to the bottom. Mark the centers of the holes on the "spine" and then drill holes on both sides with a 7/8" hole-saw bit. The reason for drilling a hole on the back side is so you can run the wires from the light straight though the "spine" and have them accessible on the outside.
Step 6: Step 6: Top It Off
• cut acrylic tube for top cap
• combine acrylic tube section and disc
• trim height of "spine"
I found 4" dia. clear acrylic tubing at TAP plastics and cut this into approximately 1-1/2" sections. I used a piece of scrap acrylic (1/8" thick) to create a top plate by cutting the sheet out using a laser cutter. You can also buy pre-made, 4" dia. discs from TAP. Alternatively, TAP sells 4" dia. clear acrylic domes but these required several weeks of lead time to order so I did not use them. Glue the top plate to the tube section using acrylic cement.
Once the top cap is complete, hold it up to the top of the aluminum tube (with "spine inserted) and mark a termination point for the "spine". I recommend having the "spine" protrude a little above the aluminum but stopping short (about 3/4" below the top plate). This allows room to position the RF transmitter and receiver in the upper region of the top cap. It is important that the receiver and transmitter are above the line of the aluminum pipe otherwise they may not successfully transmit to the other poles (metal interferes with the signal).
• combine acrylic tube section and disc
• trim height of "spine"
I found 4" dia. clear acrylic tubing at TAP plastics and cut this into approximately 1-1/2" sections. I used a piece of scrap acrylic (1/8" thick) to create a top plate by cutting the sheet out using a laser cutter. You can also buy pre-made, 4" dia. discs from TAP. Alternatively, TAP sells 4" dia. clear acrylic domes but these required several weeks of lead time to order so I did not use them. Glue the top plate to the tube section using acrylic cement.
Once the top cap is complete, hold it up to the top of the aluminum tube (with "spine inserted) and mark a termination point for the "spine". I recommend having the "spine" protrude a little above the aluminum but stopping short (about 3/4" below the top plate). This allows room to position the RF transmitter and receiver in the upper region of the top cap. It is important that the receiver and transmitter are above the line of the aluminum pipe otherwise they may not successfully transmit to the other poles (metal interferes with the signal).
Step 7: Step 7: Paint Poles (optional)
• prime and paint exterior poles
While not entirely necessary, painting the poles (in this case using an OSHA yellow) provides some delightful flair to the final product. I primed the aluminum pole with an undercoat of white paint and then, once dry, masked off a band at each light opening before applying the final two coats of OSHA yellow paint. Be sure to paint in a well-ventilated space using adequate protection (goggles, dust mask, etc.).
While not entirely necessary, painting the poles (in this case using an OSHA yellow) provides some delightful flair to the final product. I primed the aluminum pole with an undercoat of white paint and then, once dry, masked off a band at each light opening before applying the final two coats of OSHA yellow paint. Be sure to paint in a well-ventilated space using adequate protection (goggles, dust mask, etc.).
Step 8: Step 8: Upload Arduino Code
• upload Arduino program
I've attached the code as a .zip file. Here is the text:
/*
As of 3:00AM on 20 October 2012 this is the most working version with everything in it!
This version can be uploaded to 2 devices configured with a wireless receiver on pin 4
and a wireless transmitter on pin 3 (and as of this time is currently on both my test devices)
Turns on and off a powered light output system connected to digital
pin 9 when pressing a pushbutton attached to pin 2.
Sends an RF signal (a message of the letter "A" via VirtualWire) to other device(s) running same program,
causing them to behave as if their pushbutton was pressed.
Polls for RF messages (using the VirtualWire library); receipt of any message on the channel causes unit
to behave as if pushbutton was pressed.
TO DO: Poll for a specific message
The circuit:
* LED attached from pin 13 to ground (for debugging)
* External lights circuit attached to pin 9
* pushbutton attached to pin 2 from +5V
* 10K resistor attached to pin 2 from ground
See JT's sketchy OmniGraffle diagram for a mashup of the above with the lighting circuit (sans RF devices)
http://bildr.org/2011/03/high-power-control-with-arduino-and-tip120/
created 2005
by DojoDave <http://www.0j0.org>
modified 30 Aug 2011
by Tom Igoe
modified 20 Oct 2012
by Jason Taylor
modified 08 Nov 2012
by Thomas Deckert
Original example code is in the public domain, including button example code from
http://www.arduino.cc/en/Tutorial/Button
and transmit/receive examples from VirtualWire project site
*/
#include <VirtualWire.h>
// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 9; // the number of the light output pin - remember "ledPin" here means "external lights"
const int RF_TX_PIN = 3; // the number of the pin for the transmitter
const int RF_RX_PIN = 4; // the number of the pin for the receiver
const int debugLED = 13; // the number of the pin for the (default) debugging LED on the shield
// variables will change:
boolean buttonState = false; // variable for reading the pushbutton status
boolean oldButtonState = buttonState;
boolean ledState = false;
boolean started = false; // starts a sequence
//long waitUntil=0;
long startTime=0;
long flashStartTime=0;
int holdTime=12000; // duration of hold sequence
int flashTime=15000; // duration of full flash sequence
int strobe=500; // duration of one flash
//int runtime=0;
void setup() {
Serial.begin(9600);
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
vw_setup(2000); // Bits per sec
vw_set_tx_pin(RF_TX_PIN); // Setup transmit pin
vw_set_rx_pin(RF_RX_PIN); // Setup receive pin.
vw_rx_start(); // Start the receiver PLL running
}
void loop() {
// Each time through loop(), set Pin 9 to the same value as the state variable
digitalWrite(ledPin, ledState);
// read button value at start of loop, before doing anything
buttonState = digitalRead(buttonPin);
// triggers more light time every time button is pressed -- add debounce if time permits
if (buttonState != oldButtonState) startSeq(); // any time button state changes we add time to lights on
// stuff to handle receipt of message from another device
// right now also extends time even if button was pressed locally and across street at same time!
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)) { // Non-blocking
int i;
Serial.print("Got: ");
for (i = 0; i < buflen; i++) {
digitalWrite(debugLED, HIGH); //test LED
Serial.println(buf[i], HEX);
}
digitalWrite(debugLED, LOW);
startSeq(); // any time we get a message we add time to lights on
}
if (started) { // the button was pushed, so
// previous working flasher code
if (millis() >= (flashStartTime)) { // if LED has been on more than the hold time...
if (millis() <= (flashStartTime+flashTime)) { // enter flash sequence if it hasn't entered yet
if ( ( (millis() - flashStartTime) % strobe ) == 0){ // toggle every strobe duration. PROBLEM LINE! (says Jake)
ledState = !ledState;
Serial.println(millis() - flashStartTime, DEC);
}
}
else { (ledState = false); started=false; } // turn off after flash sequence
}
}
// read button value at end of loop to see if it changes
oldButtonState = buttonState;
}
void startSeq () { // so currently if button state changes in either direction we get another seq start...?
// code for sending a message off to another light kit
const char *msg = "A";
digitalWrite(debugLED, true); // turn on the debug LED
Serial.println("ss");
vw_send((uint8_t *)msg, strlen(msg));
vw_wait_tx(); // Wait until the whole message is gone
Serial.println("es");
digitalWrite(debugLED, false); // turn off the debug LED
// end code for sending message off to another light kit
//now let's get the lights on this pole blinking!
started=true;
startTime=millis(); //records when in the program the button was pressed
flashStartTime=startTime+holdTime; // flashing sequence will start after holding sequence
//waitUntil=startMillis;
ledState = true; //turn LED on and start sequence every time button is pressed
}
I've attached the code as a .zip file. Here is the text:
/*
As of 3:00AM on 20 October 2012 this is the most working version with everything in it!
This version can be uploaded to 2 devices configured with a wireless receiver on pin 4
and a wireless transmitter on pin 3 (and as of this time is currently on both my test devices)
Turns on and off a powered light output system connected to digital
pin 9 when pressing a pushbutton attached to pin 2.
Sends an RF signal (a message of the letter "A" via VirtualWire) to other device(s) running same program,
causing them to behave as if their pushbutton was pressed.
Polls for RF messages (using the VirtualWire library); receipt of any message on the channel causes unit
to behave as if pushbutton was pressed.
TO DO: Poll for a specific message
The circuit:
* LED attached from pin 13 to ground (for debugging)
* External lights circuit attached to pin 9
* pushbutton attached to pin 2 from +5V
* 10K resistor attached to pin 2 from ground
See JT's sketchy OmniGraffle diagram for a mashup of the above with the lighting circuit (sans RF devices)
http://bildr.org/2011/03/high-power-control-with-arduino-and-tip120/
created 2005
by DojoDave <http://www.0j0.org>
modified 30 Aug 2011
by Tom Igoe
modified 20 Oct 2012
by Jason Taylor
modified 08 Nov 2012
by Thomas Deckert
Original example code is in the public domain, including button example code from
http://www.arduino.cc/en/Tutorial/Button
and transmit/receive examples from VirtualWire project site
*/
#include <VirtualWire.h>
// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 9; // the number of the light output pin - remember "ledPin" here means "external lights"
const int RF_TX_PIN = 3; // the number of the pin for the transmitter
const int RF_RX_PIN = 4; // the number of the pin for the receiver
const int debugLED = 13; // the number of the pin for the (default) debugging LED on the shield
// variables will change:
boolean buttonState = false; // variable for reading the pushbutton status
boolean oldButtonState = buttonState;
boolean ledState = false;
boolean started = false; // starts a sequence
//long waitUntil=0;
long startTime=0;
long flashStartTime=0;
int holdTime=12000; // duration of hold sequence
int flashTime=15000; // duration of full flash sequence
int strobe=500; // duration of one flash
//int runtime=0;
void setup() {
Serial.begin(9600);
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
vw_setup(2000); // Bits per sec
vw_set_tx_pin(RF_TX_PIN); // Setup transmit pin
vw_set_rx_pin(RF_RX_PIN); // Setup receive pin.
vw_rx_start(); // Start the receiver PLL running
}
void loop() {
// Each time through loop(), set Pin 9 to the same value as the state variable
digitalWrite(ledPin, ledState);
// read button value at start of loop, before doing anything
buttonState = digitalRead(buttonPin);
// triggers more light time every time button is pressed -- add debounce if time permits
if (buttonState != oldButtonState) startSeq(); // any time button state changes we add time to lights on
// stuff to handle receipt of message from another device
// right now also extends time even if button was pressed locally and across street at same time!
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)) { // Non-blocking
int i;
Serial.print("Got: ");
for (i = 0; i < buflen; i++) {
digitalWrite(debugLED, HIGH); //test LED
Serial.println(buf[i], HEX);
}
digitalWrite(debugLED, LOW);
startSeq(); // any time we get a message we add time to lights on
}
if (started) { // the button was pushed, so
// previous working flasher code
if (millis() >= (flashStartTime)) { // if LED has been on more than the hold time...
if (millis() <= (flashStartTime+flashTime)) { // enter flash sequence if it hasn't entered yet
if ( ( (millis() - flashStartTime) % strobe ) == 0){ // toggle every strobe duration. PROBLEM LINE! (says Jake)
ledState = !ledState;
Serial.println(millis() - flashStartTime, DEC);
}
}
else { (ledState = false); started=false; } // turn off after flash sequence
}
}
// read button value at end of loop to see if it changes
oldButtonState = buttonState;
}
void startSeq () { // so currently if button state changes in either direction we get another seq start...?
// code for sending a message off to another light kit
const char *msg = "A";
digitalWrite(debugLED, true); // turn on the debug LED
Serial.println("ss");
vw_send((uint8_t *)msg, strlen(msg));
vw_wait_tx(); // Wait until the whole message is gone
Serial.println("es");
digitalWrite(debugLED, false); // turn off the debug LED
// end code for sending message off to another light kit
//now let's get the lights on this pole blinking!
started=true;
startTime=millis(); //records when in the program the button was pressed
flashStartTime=startTime+holdTime; // flashing sequence will start after holding sequence
//waitUntil=startMillis;
ledState = true; //turn LED on and start sequence every time button is pressed
}
Step 9: Step 9: Test Complete Electronic Assembly
• connect all electrical components
Assemble the electronics using the attached PDF wiring diagram (sketched by the amazing Jason Taylor who was a tremendous help in the eleventh hour). Note that this assembly includes a Grove Base Shield that fits on top of the Arduino Uno to enable plug-n-play connections between the RF Transmitter and Receivers. It is through this pair of transmitter and receiver that each light pole is able to operate in synchronicity with the other light poles.
Assemble the electronics using the attached PDF wiring diagram (sketched by the amazing Jason Taylor who was a tremendous help in the eleventh hour). Note that this assembly includes a Grove Base Shield that fits on top of the Arduino Uno to enable plug-n-play connections between the RF Transmitter and Receivers. It is through this pair of transmitter and receiver that each light pole is able to operate in synchronicity with the other light poles.
Attachments
Step 10: Step 10: Attach "Brains" to Spine
• cut space in spine for elec. components
• attach elec. components to spine
The battery pack, breadboard, and Arduino (with Grove Base Shield) can all be attached to the "spine" by sawing out cavities in the PVC. Position these openings in the "spine" as close to the top of the PVC while still leaving a complete portion of the PVC pipe at the very top (for structural integrity).
Secure all three of these components using electrical tape. Ensure that all of the wired connections are secure using electrical tape as needed.
• attach elec. components to spine
The battery pack, breadboard, and Arduino (with Grove Base Shield) can all be attached to the "spine" by sawing out cavities in the PVC. Position these openings in the "spine" as close to the top of the PVC while still leaving a complete portion of the PVC pipe at the very top (for structural integrity).
Secure all three of these components using electrical tape. Ensure that all of the wired connections are secure using electrical tape as needed.
Step 11: Step 11: Attach Lights to Spine
• cut appropriate lengths of wire for lights
• solder wire to lights
• create collar for lights
Before cutting a bunch of wire to connect to your lights make sure you cut a long enough segment. Based on the positions of the lights within the poles you should be able to calculate how long to cut the wire by spooling it from the openings to the top of the pole. I would allow an extra couple inches more than you think you need just to be safe (you can always cut it back).
Solder the wires to the light bulb. The inner coil is (+) and the outer coil is (-).
Create a collar for the light bulb using thin strips of sheet metal (I found a coil of perforated metal (20ga I believe) at the hardware store). Cut this into strips just long enough to wrap around the bulb and bend it into a cylindrical shape using pliers. Slip the collar onto the back of the bulb to provide some stability when you slide the bulb and collar into the holes in the "spine". This provided sufficient (crude) adjustability to allow the lights to sit at an angle within the "spine".
Once all three lights (and collars) are placed in the "spine" run the wires through the holes on the other side of the spine and use electrical tape to secure the wires along the length of the "spine".
• solder wire to lights
• create collar for lights
Before cutting a bunch of wire to connect to your lights make sure you cut a long enough segment. Based on the positions of the lights within the poles you should be able to calculate how long to cut the wire by spooling it from the openings to the top of the pole. I would allow an extra couple inches more than you think you need just to be safe (you can always cut it back).
Solder the wires to the light bulb. The inner coil is (+) and the outer coil is (-).
Create a collar for the light bulb using thin strips of sheet metal (I found a coil of perforated metal (20ga I believe) at the hardware store). Cut this into strips just long enough to wrap around the bulb and bend it into a cylindrical shape using pliers. Slip the collar onto the back of the bulb to provide some stability when you slide the bulb and collar into the holes in the "spine". This provided sufficient (crude) adjustability to allow the lights to sit at an angle within the "spine".
Once all three lights (and collars) are placed in the "spine" run the wires through the holes on the other side of the spine and use electrical tape to secure the wires along the length of the "spine".
Step 12: Step 12: Attach Button Switch to Aluminum Pipe
• attach button to aluminum pipe
Connect wires to each end of the button switch. Make sure they are long enough to access from the top of the aluminum. Unscrew the nut from the button switch and slip it through the small hole in the side. Then connect an alligator-clip lead to each end of the wires and leave this dangling outside the top of the aluminum.
Connect wires to each end of the button switch. Make sure they are long enough to access from the top of the aluminum. Unscrew the nut from the button switch and slip it through the small hole in the side. Then connect an alligator-clip lead to each end of the wires and leave this dangling outside the top of the aluminum.
Step 13: Step 13: Light Covers
Create light covers out of 1-1/4" PVC by cutting into sections at an angle. These can be adhered in place using hot glue, though make sure they do not protrude much into the aluminum pipe otherwise they will prevent the removal of the "spine".
Step 14: Step 14: Final Assembly
Once all the electrical components (except for the switch) are connected and secured to the "spine", connect the circuitry to the switch using alligator-clip leads and slide the "spine" carefully into the aluminum pipe. Place the acrylic cap on top and secure in place using "plumbers tape" (the adjustable metal band in the picture).
Press the button to turn it on.
Make three more of these and get them out to the street to show off the power of urban prototyping!
Press the button to turn it on.
Make three more of these and get them out to the street to show off the power of urban prototyping!