REEF2REEF Saltwater and Reef Aquarium Forum

    Arduino powered diy sea sweep! Oscillating wavemaker diy!, Feb 25, 2018
  1. Kikko2775

    to move the servant I was helped by "mstockmaster" finding the codes to use. I opted for a code with a temp of 600 ms trying to keep the movement quite fluid and constant.

    #include <Servo.h>

    Servo myservo; // create servo object to control a servo
    // twelve servo objects can be created on most boards

    int pos = 0; // variable to store the servo position

    void setup() {
    myservo.attach(9); // attaches the servo on pin 9 to the servo object

    void loop() {
    for (pos = 50; pos <= 140; pos += 1) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    myservo.write(pos); // tell servo to go to position in variable 'pos'
    delay(600); // waits 15ms for the servo to reach the position
    for (pos = 140; pos >=50
    ; pos -= 1) { // goes from 150 degrees to 90 degrees
    myservo.write(pos); // tell servo to go to position in variable 'pos'
    delay(600); // waits 15ms for the servo to reach the position

    for now it seems good to me as a result.
  2. reef angel vs jarduino poll and opinions please help!!, Jan 3, 2014
  3. Meldrath

    The code by far is not easy, especially if you have to go low level and write the libraries. Sure it's relatively easy once you got a library. Just instantiate the object, and call its methods with the appropriate logic. What most people can't do is the logic part, or making sense of the methods and how to use them. What makes it hard as I said, is when you gotta go to a binary/assembly level and talk to the device.

    Further coding in c++ is a PITA when you start dealing with pointers and dereferencing, passing by value/reference etc... plus the arduino has a limited subset of c++ commands and libraries. I can't #include iostream.h or iomanip or string etc to make things like atoi or itoa for outputs. Or maybe I can and I just don't know it yet. Anyways I'm digressing, the point is, the code "can" be zombified, but a good program takes skill. I program for a living, I know :p

    PS C string character arrays suck almost as bad as pointers.
  4. DIY arduino aquarium controller, Jun 11, 2013
  5. bct15

    Here is the code...

    Code to montior the value of a potentiometer to digitally control
    any component, in this case it will be controlling the digital
    pwm signal sent to a LED driver

    Author: Rykstar (BCT15)

    Pot connections
    pin 1 - +5v
    pin 2 - A1 (analog in)
    pin 3 - ground

    LCD is used to monitor the value of the pot
    LCD connections (digital pins)
    d4 - 6
    d5 - 5
    d6 - 4
    d7 - 3
    BL+ - +5v
    Ground - ground
    VCC - +5v
    RS - 12
    RW - 11
    E - ground

    #include <Wire.h>
    #include <LiquidCrystal.h>
    #include <stdlib.h>

    LiquidCrystal lcd(12, 11, 6, 5, 4, 3);
    //Set the dimmer pin channel
    const int LEDdim01 = 8;

    //initialize pot variable and brightness variable
    int pot01 = 0;
    int brightness01 = 0;

    void setup()

    //Set the knob input mode
    pinMode(A1, INPUT);

    //LED fade pin
    // declare pin 8 to be an output:
    pinMode(LEDdim01, OUTPUT);

    // initialize the lcd

    lcd.home ();

    void loop()

    lcd.print(" Pot Example ");
    lcd.print(" By: Rykstar ");

    //Get the pot value
    pot01 = analogRead(A1);

    //Set the brightness to a proper pwm value
    brightness01 = pot01/4;

    //Output brightness on respective LED channel
    analogWrite(LEDdim01, brightness01);

    //Printvalues to LCD
    lcd.print("Pot01: ");
    lcd.print("Brightness: ");
    lcd.setCursor(14 ,2);


    The arduino gets a value for the position of the pot, and I can use it to control anything I want.
  6. Build your own Controller: By ModAquatics, Oct 22, 2012
  7. revhtree

    Build your own Controller: By ModAquatics

    Many people purchase a controller to handle the daily mundane tasks of monitoring and adjusting parameters of a reef aquarium. However, if you are a DIY kind of Reefer, then perhaps you would prefer to build your own! It is not as difficult as you may think. All you need is a controller, software and an interface to input and output information or control signals. There are many controllers on the market but the "Arduino" controller is, by far, the most commonly used and supported controller for reefkeeping. Just google (in the verb sense) "Arduino and Reef" and you will see many examples of this.
    The Arduino software is simple to use. There are tutorials on the website and many examples of code that come with the free download. The most basic thing is that the programs are called "Sketches." The programming language is based on "C" language which is fairly simple once you understand the syntax. The sketch simply defines what actions to take when certain inputs happen. The inputs can be a temperature sensor, potentiometer, PH probe, switch, etc. The outputs can be a display, sending power to a relay to turn on a pump, dim an LED, etc. The outputs and inputs can either be digital (On or off) or analog (0v to 5v).

    Here is a partial list of things you can do with an Arduino along with what you would need to accomplish the task (there are many, many more).

    Auto Top-Off - (See 120v relay below to turn the pump on and off) just add float switches
    LED light dimming - The Arduino can produce PWM (Pulse Width Modulation) signals and that will be demonstrated below.
    PH checking - with a BNC sheild or a PH stamp and Probe. A kit for the Arduino can be purchased here -> pH Sensor Kit - SparkFun Electronics
    Salinity checking - by using an EC (Electrical Conductivity) Probe. A lit can be purchased here -> Store
    Temperature monitoring - You just need a temp sensor like -> DS18S20 1-Wire Parasite-Power Digital Thermometer - Overview
    Control 120v power to turn things on and off - You would need a 5v relay such as - SainIC 2-Channel 5V Relay Module for Arduino DSP AVR PIC ARM and hook it up to a power socket. This is important because, for example, if the temperature gets to high because the heater fails to an "On state", then the Arduino can shut off power to the heater. Another example might be, if the dissolved oxygen gets too low, you can have the Arduino power on an air pump, etc.

    You would also want to have some method of "seeing" what is happening. A simple way is to add some indicator LED's (such as power-on lights), an LCD character display (which can display current temp, PH, etc.) or you can add networking capabilities and report via the web.

    There are devices called "Shields" which are PCB's (Printed Circuit Boards) that simply plug into the base Arduino. There is even a Reef shield that has almost everything you would want for controlling a reef called the "Arduarium"... Arduarium Controller Ultimate (Assembled) | Practical Maker

    I recently posted a video on Youtube illustrating how to interface an Arduino with our light engines. You can also use it with any PWM ready device as long as the PWM input voltage can be 5v. Meanwell drivers use 10v but you can still use an Arduino but it will interface a little diferently. Check ot the video and you can see how simple it is. The code that was used in the video example and all other hardware is listed below.

    The Items used in the video are;

    Arduino board - you can use almost any but I use the Arduino UNO SMD
    Arduino Uno SMD - SparkFun Electronics

    Breadboard - such as..
    Breadboard Arduino Compatible Parts Kit - SparkFun Electronics

    LCD display - 16x2 Character Parallel display
    Basic 16x2 Character LCD - Black on Green 5V - SparkFun Electronics

    Potentiometer -
    10K-Ohm Audio-Taper Potentiometer -
    Arduino software -
    Arduino - HomePage

    For the purposes of this demonstration we will have analog input from a potentiometer (like a volume knob thing) and the digital outputs will be an LCD display and the LEDs.

    All of the pin connections are listed in the Arduino sketch.

    Here is a link to the video
    LED PWM Dimming Demo for Aquarium - YouTube
    Here is the Sketch

    [TABLE="align: center"]
    [TD="class: code"]/*
    ModAquatics Light Engine PWM Demo

    Demonstrates the use a PWM Controller interfaced with the 6x12
    light engine sold by ModAquatics. It also uses 16x2 LCD display.

    This sketch prints "Brightness Level" to the LCD on the first line
    then the Brightness percentage on the second.

    The circuit:
    * LCD RS pin to digital pin 12
    * LCD Enable pin to digital pin 11
    * LCD D4 pin to digital pin 5
    * LCD D5 pin to digital pin 4
    * LCD D6 pin to digital pin 3
    * LCD D7 pin to digital pin 2
    * LCD R/W pin to ground
    * PWM + to Digital pin 9
    * PWM Ground to Analog Ground
    * Potentiometer wiper to Analog pin 3
    * Potentiometer ends to +5V and ground

    Example Code from ModAquatics
    modified 8-21-2011

    This example code is in the public domain.


    // include the library code for the LCD:
    #include <LiquidCrystal.h>

    int analogPin = 3; // potentiometer connected to analog pin 3
    int val = 0; // variable to store the read value
    int ledPin = 9; // LED connected to digital pin 9

    LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // initialize the library with the numbers of the interface pins

    void setup() {
    lcd.begin(16, 2); // set up the LCD's number of columns and rows:
    lcd.print("Brightness Level"); // Print Brightness Level to the LCD.

    lcd.setCursor(0, 1); // Move cursor to the next line

    pinMode(9, OUTPUT); // Set the Digital Pin 9 to OUTPUT

    void loop() {
    val = analogRead(analogPin); // read the input Analog pin 3 values go from 0 to 1023,
    analogWrite(ledPin, val / 4); // analogWrite values from 0 to 255 so divide by 4
    lcd.print(" "); //Clear the previous percentage
    lcd.setCursor(0, 1);
    lcd.print((val / 4) / 2.55); //Print the Brightness Percentage
    delay(100); // Wait 100 milliseconds


    Some terminology and other things that you may need to understand when working with Arduino....

    PWM - Pulse Width Modulation. This is a method for turning an electronic device on and off so rapidly that we don't perceive it. It can be used for dimming lights or controlling fan speed, etc. In the case of dimming LED lighting the "On" times will be greater or less than the "Off" times and we perceive it as dimming. PWM is available on certain Arduino Pins. With more advanced programming, any of the digital pins can be used for PWM control. A good article is available on the Arduino website.. Arduino - PWM

    Digital Pins - These are pins on the Arduino that will either be on or off. The Arduino can either read each pin to see if it is on or off (for example if a pushbutton is attached) or it can write to a digital pin to turn it on (For example if the Arduino activates an external relay attached to the pin).

    Analog Pins - These are pins on the Arduino that can range from 0v to 5v. The Arduino can read the voltage. The Arduino picks up the voltage and reports a corresponding value from 0 to 1023. For example, if an input potentiometer is connected to an analog pin (and also connected to the 5v and ground pins), when turned all of the way down the Arduino would read 0. If the Pot was turned all the way to max the Arduino would read the 5v and represent it as 1023. If the Pot was turned to halfway the Arduino would read 2.5v and represent it as 512.

    Arduino power - There are several Arduino boards. Most of them can be powered by 6v to 12v because they have internal voltage regulation. The Arduino power output supplies either 5v or 3.3v or both (depending on the model).

    Arduino Programming - Most Arduino models are programmed via USB. The software is downloadable from . While programming the Arduino can be powered by the USB cable.

    As you can see the Arduino environment can be pretty simple when it is broken down to small steps. But it can appear to be quite complex when implementing a full monitoring solution that requires interfacing many sensors for reefkeeping. But there is so many fully documented examples and so much friendly support via the web. So again, if you are the type that gets enjoyment for creating things like this for yourself, give the Arduino a try!