After months of waiting, the long-awaited Arduino Two is finally here 🙂
I have not yet had the opportunity to have it in my hands, but looking around in the network and specially in the official site, in this article i want to highlight the main news of this system compared to its predecessor Arduino UNO.
Well, what to say!
On the paper, the news are actually many and all derives from the new Atmel SAM3X8E CPU Cortex M3 with 32bits ARM architecture that replaces the old 8bits AVR:
1 – CPU Clock at 84Mhz (16Mhz compared to the previous version)
2 – 96Kb of RAM (compared to 2Kb)
3 – 512Kb of Flash (UNO had 32Kb)
4 – 12bits PWM and analog inputs (compared to 8bits)
5 – Output DAC – New for Arduino
6 – Higher number of PIN
7 – USB Host
Tis means an extremely higher processing speed, accuracy greatly improved and new possibilities thanks to the DAC and the USB host.
Performances are mainly related to the clock speed coupled with the 32bits (and of course more RAM).
With 32bit we are able to perform a 4bytes operation (8 x 4 = 32) with a single CPU clock. This means in an empirical way, that Arduino TWO might be about 20 times faster than Arduino UNO.
The most accuracy is related to the 12-bits analog inputs and PWM outputs: we have 16 times the old resolution, that means we have 4096 levels of conversion from analog to digital and vice versa compared to the 256 of the previous version. This allows a higher density of input data and a greater control on the PWM output.
The new features mainly concern the DAC pin (analog outputs, that is linear from 0 to 3.3 V) allowing for example to perform a MP3 file and hear it on the speakers connected to these outputs.
The only negative notes in my opinion (you have to be really picky though!), are the lack of an ethernet port – now essential in any application, and the fact that the TTL is 3.3V and not compatible 5V; with the wrong voltage you will fry pin or microcontroller itself. This leads to an incomplete compatibility with the existing shield or with third-party hardware.
Regarding consumption theoretically should be similar Arduino Mega although I did not find anything specific about it.
The programming instead always work through our Arduino IDE, updated to version 1.5 for the occasion, which contains additional libraries for the management of the new capabilities of the board. The programming mode is very similar to the old procedure.
Obviously, in this article we talked about a version out a few days ago and still in the testing phase. Time will tell if this card will completely replace the old Arduino, or if there will be a parallel market that will adapt depending on the final application. Surely those news lead further innovation in this field, such as to suggest that now the Arduino product may encroach further from the world of “geeks home” in the electronics professional.
Certainly a product like Arduino DUE, in terms of performance and precision is a product that is well suited for applications beyond entertainment home at a very attractive price (Arduino Store official price: Euro 39).
On the other hand, with this platform, it will be difficult to create embedded designs similar to those achieved with ATtiny85 or ATmega328 in standalone mode, but you can of course continue to use the old AVRs: as I said before, depending on the final application, you will find the best solution.
Finally after a long absence, in which I was immersed in the final realization of this project, I did it!
After months of planning, studies, research and other obstacles, the RGB LED Lamp 1.0 by Toggio is reality.
Here’s the video showing the final result obtained:
And now a brief history.
One of the things that attracted me the most when I first heard of Arduino, was light, and in particular I have always dreamed of achieving an LED lamp RGB.
Nothing difficult, you might think … Except that along this route I found several obstacles.
First of all, I did not find complete projects on the net … There is something, but, in my opinion, with bad algorithms, with little explanation or with complicated methods.
I wanted a simple present to give to the person who I love and that gave me a beautiful daughter …
I wanted something that had a powerful enough light, without too much heat. I wanted something that had a chance to choose the color and not a simple “color cycler.” I wanted something that would serve also as a standard lamp. And finally, I wanted something that was modular and upgradeable in the future.
After these reflections, I began to study the hardware first. I did not want to use the Arduino UNO because it seemed too big for my project. So I decided (and this could open up a huge parentheses) to use a board not so common, but in my opinion awesome (so much that I bought 4 or 5 piece): The Arduino Mini Pro.
(It is understood that in the project of this post, it can easily be replaced by an Arduino UNO or any other board.)
It ‘a very small board (18mm x 33mm), 100% compatible with Arduino Dumilanove, and low power consumption. It is available in four versions: with Atmega328 or with ATmega168, both with 3.3V or 5V.
So I opted in this project for the 5V version with ATmega168. In short it is a very economic solution (it costs about half of the Arduino UNO), very compact and beautiful to see.
I then thought of using the useful LED RGB strips, which offer many advantages over using 1W or 3W power LEDs: they do not heat up, they are powered with 12V and they offer a power up to 13-14W per meter.
Each channel can be powered by a PWM output of the Arduino using a simple transistor (in my case I used the BC337, but for higher power you can use other transistor, or even the MOSFET).
I then proceeded to build a kind of shield for my board. Practically I made a circuit in which the Arduino Pro Mini would fit with strip connectors and with the ability to be removed to upgrade the firmware. Everything has been designed with Fritzing and built by Fritzing Fab.
The final result of the printed circuit is as follows:
You can see the two rows of holes where the Mini Pro will be mounted… Basically, it’s the opposite of a shield 🙂
But let’s step back and see the circuit schematic:
I hope it is clear enough even if I have not drawn just fine!
In any case, the operation principle is as follows: The two 10k potentiometers connected between +5 V and ground, are the two analog inputs that allow to adjust the brightness and other parameters set by the software. The 3-position switch SW2 allows you to select three different functions for the lamp. The digital outputs 3,5,6 go through a resistor to drive the 3 BC337 transistors that will give negative voltage to the 3 channels (R, G, B) of the LED strip. The common positive goes to +12 V, while the Arduino is powered by RAW port (input from 7V to 13V) via a diode that in addition to providing reverse polarity protection, slightly lowers the voltage. SW1 is simply the bridge where will be connected a standard power switch.
Once soldered the components, connectors, potentiometers, mounted the circuit, encapsulated the Arduino board, and assembled it all in a electrician box, the result is as in the following picture:
The size of the box is approximately 10cmx10cmx7cm.
For the top, I used about 70cm of RGB led strip, for a total power of about 10W. To fit the whole strip I rolled it around the support of a “50 CD-R set”. I cut with a utility knife and I glued all with spacers on the box. I then glued with hot glue the wrapping strip led… In short, the job is a little rough but the end result is as follows:
The glass you see on the desk, is the final piece: the glass cover of a IKEA lamp, properly cut ​​by a local glazier, so that it remains empty on both sides. This coverage will finally resting on the box and glued, obtaining the following results:
Not bad right?
Of course there is still the icing on the cake, a not less important part: the software.
The self-explanatory code is as follows:
/*
RGB Led Lamp 1.0a
by Luca Soltoggio
15/03/2012
http://arduinoelettronica.wordpress.com/
*/
int rpin = 3; // red pin
int gpin = 5; // green pin
int bpin = 6; // blue pin
unsigned int r=0, g=0, b=0,bm=0; // r,g,b, value and blue coefficient
unsigned int valh=0, vals=0, valv=0; // hue, saturation, value
unsigned int sensorValue; // analog sensor value
const int analogInPin = A0; // potentiometer pins
const int analogInPin2 = A1;
const int digitalInPin = 10; // switch pins
const int digitalInPin2= 11;
int red[]={255,255,135}; // predefined arrays for RGB / White
int green[]={157,255,158};
int blue[]={51,255,255};
boolean DIG1, DIG2;
long previousMillis = 0;
int i=0,j=0;
int dl=0; // delay
void setup()
{
pinMode(digitalInPin,INPUT);
pinMode(digitalInPin2,INPUT);
}
void loop()
{
DIG1=digitalRead(digitalInPin);
DIG2=digitalRead(digitalInPin2);
if (DIG1) {
bm=1.1;
HSV_Game();
}
else if (DIG2) {
bm=1.9;
RAINBOW_Game();
}
else {
bm=2.4;
LIGHT_Game();
}
analogWrite(rpin, r/1.09); // write RED PIN
analogWrite(gpin, g/1); // write GREEN PIN
analogWrite(bpin, b/bm); // write BLUE PIN
}
// analog input smoothing function
int SensorSmooth (int pin) {
sensorValue=0;
for (int i = 0; i<10; i++) {
sensorValue+= analogRead(pin);
}
return int ((float)sensorValue/10+0.5);
}
// first light game: modify HUE and VALUE with potentiometer
void HSV_Game() {
valh = SensorSmooth(analogInPin);
vals = 255;
valv = SensorSmooth(analogInPin2);
valh = map(valh,0,1023,0,359);
valv = map(valv,0,1023,32,255);
hsv2rgb(valh,vals,valv,r,g,b);
}
// second light game: three positions for Warm White, White and Cold White
void LIGHT_Game() {
valv = SensorSmooth(analogInPin2);
valv = map(valv,0,1023,16,255);
valh = SensorSmooth(analogInPin);
if (valh<=281) valh=0;
if (valh>=742) valh=2;
if (valh>2) valh=1;
r=red[valh]*valv/255;
g=green[valh]*valv/255;
b=blue[valh]*valv/255;
}
// color cycler
void RAINBOW_Game() {
dl = SensorSmooth(analogInPin); // delay time
dl = map(dl,0,1023,1,100);
valv = SensorSmooth(analogInPin2);
valv = map(valv,0,1023,64,255);
unsigned long currentMillis = millis();
switch (j) {
case 0:
r=255*valv/255;
g=i*valv/255;
b=0*valv/255;
break;
case 1:
r=(255-i)*valv/255;
g=255*valv/255;
b=0*valv/255;
break;
case 2:
r=0*valv/255;
g=255*valv/255;
b=i*valv/255;
break;
case 3:
r=0*valv/255;
g=(255-i)*valv/255;
b=255*valv/255;
break;
case 4:
r=i*valv/255;
g=0*valv/255;
b=255*valv/255;
break;
case 5:
r=255*valv/255;
g=0*valv/255;
b=(255-i)*valv/255;
}
if (currentMillis-previousMillis > (long)(100-dl)) { // use millis instead of delay
previousMillis=currentMillis;
i=i+1;
if (i==256) {
i=1;
j=j+1;
if (j==6) j=0;
}
}
}
/* HSV2RGB function
(c) Elco Jacobs, E-atelier Industrial Design TU/e, July 2011
http://code.google.com/p/shiftpwm/source/browse/trunk/examples/ShiftPWM_Example1/hsv2rgb.cpp?r=3
*/
void hsv2rgb(int hue, int sat, int val, unsigned int& r, unsigned int& g, unsigned int& b)
{
int H_accent = hue/60;
int bottom = ((255 - sat) * val)>>8;
int top = val;
int rising = ((top-bottom) *(hue%60 ) ) / 60 + bottom;
int falling = ((top-bottom) *(60-hue%60) ) / 60 + bottom;
switch(H_accent) {
case 0:
r = top;
g = rising;
b = bottom;
break;
case 1:
r = falling;
g = top;
b = bottom;
break;
case 2:
r = bottom;
g = top;
b = rising;
break;
case 3:
r = bottom;
g = falling;
b = top;
break;
case 4:
r = rising;
g = bottom;
b = top;
break;
case 5:
r = top;
g = bottom;
b = falling;
break;
}
}
In the previous post we saw a simple LED driver based on integrated LM317, but as explained one of the faults of the circuit is the high dropout.
Thus we see today a scheme based on a single transistor (in our case a BC337, but any NPN is fine as long as we know all the electronics characteristics), which has a dropout of about 1.25V.
The circuit is as follows:
In this case we have to slightly decrease the value of resistance R2, due to the fact that the Q1 driving voltage is not 12V but 5V.
The important thing as always is to experiment, experiment, experiment!
We had to change the value of the resistance R1 because introducing R2, the reference value is brought to 1.75V approx. It should be tested and measured with an current meter.
In this circuit VCC, that is the TTL input of our circuit (PWM output of an Arduino, rather than the logic output of a NE555), when is at a high value (+5V), the transistor Q1 conducts and the ADJ pin of the LM317 goes to ground, inhibiting the flowing of current in R1 and then in the LED. Conversely, if I bring the logic input to a low value (0V) the transistor does not conduct allowing the flowing of current: the LED lights up as in the previous example. Obviously logic works in reverse and then in microcontroller programming this should be taken into account, or at least you can add an additional transistor to invert the logic again.
In a future post, we’ll create another circuit that has the same function, but using a transistor instead of the LM317.