Jump to content

WAMAS Waves v3

Sign in to follow this  
  • entries
  • comments
  • views

Mixed Reef - Expanding Your DIY Horizons

Sign in to follow this  


6145131987_65fcd7086d_b.jpgA picture of an Arduino (mega 2560) card. Reefers seem to be almost any age, come from diverse backgrounds, and you might find one in any given professional field. One thing that we all seem to have in common is occasionally finding ourselves in a position where the ideal solution we are looking for cannot be found on store shelves. Of course, there also seems to be a desire to "just tinker with it" that we also seem to share.About six months ago I was researching do-it-yourself LED options to supplement and perhaps eventually replace my existing metal halide setups. I also figured as long I was going to use LEDs, it would be nice if I could simulate dusk and dawn. It was about this time that I ran across the mention of a little object called an Arduino. Now if you are like I was at the time, you are thinking "what the heck is that?" Well, it is a small electronic device that can use to accomplish just about anything you want using a combination of physically connecting things together and basic commands.Since I wanted something that I could use to more closely simulate a day, I set off on a quest to make an LED lighting controller.For full disclosure, when I started working with Arduinos, the concept and idea was beyond anything that I had attempted in my DIY career before, but by attacking it a little at a time, I found that it was not terribly difficult. If you are looking to expand your DIY repertoire, understand the basics of electrical components, then the potential for what you can accomplish is virtually unlimited.So with that, here are the basics:For my project, I chose to use an Arduino Mega, which has a lot of outputs and will cover just about any project you would ever want to do. There are smaller cards, from just the arduino bootloader uploaded onto a chip that you can integrate into your own integrated circuit card (a few dollars each, but lots of effort on your part) to some smaller, standalone chips like the Arduino Uno and Arduino Pro. The Arduino Uno (or older, but equivalent Duemilanove) is a good starting point and will run most things you will want to do.The little card may look intimidating, but really it breaks down to four main things: 1) either sensing or changing the position of a switch (digital inputs or outputs - the pins on the right) 2) measurement of sensors, such as temperature (analog inputs - the pins on the bottom) and 3) outputting a varied signal, like that used to dim an LED (PWM, outputs - the pins on the top left) and 4) some communication stuff that we won't use for this project (useful for running multiple devices).Setting the Arduino up to do the things that you want is accomplished by connecting it to your computer via a USB cable (the connector is under my index finger in the above picture). Free software provides a development environment for you to provide commands to the Arduino. For me, considering the programming part was the most intimidating part of the project, but if you break it down to the basics, it really is very simple. You just have to remember, it does EXACTLY what you tell it to. Nothing less. Nothing more.With that, let's talk about an example of how I would tell the Arduino to light an LED when a button is pressed.First, we need to set up the circuit (as an aside, I find that using a breadboard to set up a circuit is easiest to start). For this circuit, we need some wire, a button, a resistor, and we will use an LED that is already mounted on the Arduino board (at pin 13).gallery_2632346_867_24596.jpgThe circuit:The resistor is just there to prevent a short directly from a voltage to ground and can be of any high value. I used 10 k ohm resisters I found at Radio Shack. OK, if you look at the circuit, you will see that normally, digital pin 22 is connected to ground (through the resistor), which means that normally, the Arduino will sense a low. However, if the switch is closed, then the pin will sense a high which will be used to turn the LED on. Notice how I said that: IF normal condition is true, LED is off. THEN... condition is true, LED is on.Lets look at how that would look in "Arduino language" (for the techies, Arudino language is loosely based on the programming language C). And don't worry... most of the text is my explanations.
// Anytime the double slash (//) is used, // it means the stuff after it and on this  line // will not read by the computer.// It is very useful for making notes to myself // about what my code does.// (so I can remember later!)// The first thing we need to do is some basic setup.// It is useful to use noun names for the pins we use.// If we name a pin, it is a constant that will not change.const int buttonPin = 22;  // We just defined a variable (an integer or int in Arduino-ese)// the term const means we cannot change it later// the semi-colon needs to end most lines.// now, let's do it again for the LED pin const int LEDPin = 13;// Now we need a variable that will change, something// where we store the state of the button when we check it.// I initially stored it as a LOW since that is the normal // state for the LEDint buttonState = LOW;// OK, now we need to do some setup to tell the Arduino// what everything in the circuit is using the stardard // terminology.  Everything inside the squiggly brackets {}// is run once when the arduino turns on.void setup(){  // First initialize the LEDpin as an output  pinMode (LEDPin, OUTPUT);  // Next initialize the buttonPin as an input  pinMode (buttonPin, INPUT);}// Next we define the loop, or what the Arduino will do, // line by line, while it is onvoid loop(){  // First find out the state of the switch and assign it  // to the variable we created for that purpose  buttonState = digitalRead(buttonPin);  // Now, based on the input, do something (note the   // double equals (==) means "is it equal to" as opposed  // to the single equals (=) which means "assign as"  // if you accidentally use = in place of ==, the condition will  // ALWAYS be true, because you just told it to be  if (buttonPin == HIGH)  {	// this means the switch is closed, so the LED should be on	digitalWrite (LEDPin, HIGH);  }  // And finally, we need to tell the Arduino what to do   // with the LED if the switch is not closed.  else  {  digitalWrite (LEDPin, LOW);  }}

See, that wasn't that bad, right?With just a few more commands you can connect a clock, a digital display and dim your LEDs however you see fit. Or if you want to get really fancy, you can add weather, seasonal day lengths, temperature based fan controllers or really anything else you want.6145683692_ee5809a1ed_b.jpgTesting a six channel LED controller using a breadboard to simulate the LED array.6145683020_a34e1886e4_b.jpgA picture of the Arduino board and circuit soldered underneath a prototyping board that plugs directly into the Arduino and can be used to set up any type of circuit you can imagine.Intimidated, but a little intrigued, like I was? Read more, you can do it. Before you know it you will be using Arduino controllers for all kinds of household projects! Some reef projects that the arduino would be good for are: A DIY doser, light controller, reef controller, automatic feeder, and many more. If your mind isn't thinking about all the fun things that you can do with this, the website Hack N Mod has a list of 40 popular (non-reef) Arduino projects.Further information on Arduino can be found on their website www.arduino.cc, which contains a lot of tutorial, hardware, basic information, and forums that can be very useful in making your next project a reality! Also, don't be shy with asking me, I have completed a few of these projects now.

Sign in to follow this  


Recommended Comments

Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...