Introduction: Controlling a Neon Light With an Arduino
Most neon lights have one job: to stay on, all the time. But I've been working on some art pieces where I need to be able to control when and how a neon light is on or off. It turns out that with the use of a micro-controller like the Arduino, this isn't that difficult to do.
This instructable will show you how to use an Arduino, node.js, and a tiny bit of code to be able to strobe a neon light from your computer.
(Note: this tutorial assumes that you already have made or have access to a neon light at your disposal.)
Step 1: Tools and Software
- a neon light + transformer
- a microcontroller (I'm using an Arduino Uno, but any other one will do as well)
- an LED
- USB A/B cable (for connecting your Arduino to your laptop)
- computer (I'm using a macbook pro running OSX)
Things you should already have installed on your computer:
Step 2: Set Up Your Neon Light
If your light is already connected to the transformer, you can skip this step. If not, it's important to make sure that the light is properly connected to its power source.
Your neon light should have cables at both ends. These cables need to connect with each of the thicker cables coming from the transformer. Intertwine each thick cable with one end of the neon light. Be very careful at this step! Make sure that your transformer is not plugged in while you are connecting the cables.
Step 3: Set Up Your Arduino
The basic rule of neon lights and Arduinos is that almost anything you can do with an LED, you can do with a neon light. So the first thing we'll want to do is test our Arduino to make sure that it's working fine through the JohnnyFive platform, with our LED.
Grab your LED and make sure that the cathode side (the longer leg) is inserted into pin 11, and the ground side (the shorter leg) is inserted into the ground pin.
Use the A/B cable to connect your Arduino to your laptop.
Step 4: Test Your Arduino
Now we want to make sure our Arduino works well with the Johnny-Five platform. Head over the Johnny-Five website and copy the demo code for a pulsing LED to your text editor. Save the file as "led-pulse.js"
Over in your terminal, navigate to the directory where you saved the file, type "node led-pulse.js", and run it by pressing the "enter" key.
Your LED should pulse. Success!
(If you get an error message, check to make sure that you're in the right directory, your LED is plugged in correctly, your computer is recognizing the port that your Arduino is connected to, and that node.js is updated. If that doesn't help, check the documentation for both libraries.)
Step 5: Update Your Code for the Neon Light
Now that we know that everything works, we can change our code to make it slightly more complicated. We want a program that will connect to our LED, but when we run our code through terminal, we want to be able to press a key (1, 2, or 3) and control whether our light is on, off, or pulsing.
The code in this gist does all of these things, and has comments to explain what is happening at each step. Grab the code from here, and paste or clone it into your text editor. Save it as "neon-keypress.js"
Step 6: Connect Your Light and Arduino
Now that our light is connected to the transformer, we can connect our transformer to the Arduino. Modern neon transformers come with two smaller cables, one that's ground (usually black or brown) and one that's power (usually red). You can treat these just like the legs of the LED: plug the ground into the ground pin on the Arduino and insert the power one into pin 11.
Make sure that the USB A/B cable is plugged into your laptop and the Arduino.
Step 7: Run Your Code!
Now everything should be ready to go. Your computer is connected to the Arduino, which is connected to the transformer, which is connected to the light. Plug the other end of your transformer into an outlet (your light will automatically turn on, but don't worry about it).
Jump back into terminal. Make sure that you are in the directory where you saved your file. Now type "node neon_keypress.js" and press enter. You should be prompted with a screen that tells you to press keys 1, 2, or 3 depending on what result you want to see. Type 3 and wait for a minute, and voila! You should have a blinking neon light!
Aliciakking made it!