ModAquatics
Supporting Member
While at FJW's anniversary I told folks about how our lights can do PWM dimming and how they can use an Arduino. Many people didn't know what an Arduino is and others had questions about how it can be used. I just uploaded a video of how to do this with our light engines so I thought that y'all may be interested in the example. Even though I have it plugged into our light engine, y'all can plug it into your PWM drivers such as the Meanwell P series.
The Items used are;
Arduino board - you can use almost any but I use the Arduino UNO SMD
http://www.sparkfun.com/products/10356
Breadboard - such as..
http://www.sparkfun.com/products/112
LCD display - 16x2 Character Parallel display
http://www.sparkfun.com/products/255
Potentiometer -
http://www.radioshack.com/product/index.jsp?productId=2062357
Arduino software -
http://arduino.cc/
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"(Italians ). The programming language is fairly simple once you understand the syntax. The sketch just 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 or analog.
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
http://youtu.be/zbBv7UizGTE
Here is the Sketch
[/url]
The Items used are;
Arduino board - you can use almost any but I use the Arduino UNO SMD
http://www.sparkfun.com/products/10356
Breadboard - such as..
http://www.sparkfun.com/products/112
LCD display - 16x2 Character Parallel display
http://www.sparkfun.com/products/255
Potentiometer -
http://www.radioshack.com/product/index.jsp?productId=2062357
Arduino software -
http://arduino.cc/
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"(Italians ). The programming language is fairly simple once you understand the syntax. The sketch just 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 or analog.
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
http://youtu.be/zbBv7UizGTE
Here is the Sketch
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.com
modified 8-21-2011
by Robert Hughes
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
}