RGB luminaires, printed in 3D, controlled by Arduino
RGB luminaires, printed in 3D, controlled by Arduino
0
Components
Hardware componentsLED (generic)
x 30
Resistor 330 ohm
x 90
Google Android Things
x 1
MIT App Investor
x 1
Thinkercad Autodesk
x 1
Project description
- Aluminum tubes of 13mm diameter to make the body of the luminaires
- 4 13x300mm aluminum tubes
- 2 13x100mm aluminum tubes
- 6 Screws M3 X 40mm
#include <SPI.h>
#include <Ethernet.h>
String leString;
char c;
String acao;
EthernetServer server(80);
int redPin ??= 3; //PWM
int greenPin = 5; //PWM
int bluePin ?= 6; //PWM
int R,G,B;
void setup() {
?byte mac[] = { 0xDE, 0xAD, 0xBE, 0xDA, 0xFE, 0xEE };
?byte ip[] = { 192, 168, 0, 100 };
?Ethernet.begin(mac, ip);
?server.begin();
?pinMode(redPin, ??OUTPUT);
?pinMode(greenPin, OUTPUT);
?pinMode(bluePin, ?OUTPUT);
?
?Serial.begin(9600);
?Serial.println("RED ???GREEN ???BLUE");
}
void loop() {
?// ?exemplo de parametros ?http://192.168.0.100/?R200G50B40f
?EthernetClient client = server.available();
?if (client) {
???while (client.connected()){
?????if (client.available()){
???????char c = client.read();
???????if (leString.length() < 100) {
?????????leString += c;
???????}
???????
???????if (c == 'n') {
????????????????
?????????if (leString.indexOf("?") > 0) {
???????????int inicioR = leString.indexOf("r") + 1;
???????????int fimR ???= leString.indexOf("g");
???????????acao = leString.substring(inicioR, fimR);
???????????R = acao.toInt();
???????????Serial.print(R);
???????????Serial.print(" ??");
???????????int inicioG = leString.indexOf("g") + 1;
???????????int fimG ???= leString.indexOf("b");
???????????acao = leString.substring(inicioG, fimG);
???????????G = acao.toInt();
???????????Serial.print(G);
???????????Serial.print(" ??");
???????????int inicioB = leString.indexOf("b") + 1;
???????????int fimB ???= leString.indexOf("f");
???????????acao = leString.substring(inicioB, fimB);
???????????B = acao.toInt();
???????????Serial.println(B); ?????
???????????client.println("HTTP/1.1 200 OK");
???????????client.println("Content-Type: text/html");
???????????client.println();
???????????client.println("<HTML>");
???????????client.println("<HEAD>");
???????????client.println("</head>");
???????????client.println("<body>");
???????????client.println("RED = ");
???????????client.println(R);
???????????client.println("<p>");
???????????client.println("GREEN = ");
???????????client.println(G);
???????????client.println("<p>");
???????????client.println("BLUE = ");
???????????client.println(B);
???????????client.println("<p>");
???????????analogWrite(redPin ?, R);
???????????analogWrite(greenPin, G);
???????????analogWrite(bluePin , B);
???????????client.println("</font><br>");
???????????client.println("</body>");
???????????client.println("</html>");
???????????client.flush();
???????????client.stop();
???????????leString = "";
?????????}
???????}
?????}
???}
?}
} ?//fim do loop
Programming AppInventor:
The Android app was scheduled on appinventor?2.
A tool created by the Massachusetts Institute of Technology (MIT) that allows you to visually program (drag, drop, connect blocks of code) applications for devices with Android operating system.
The usability of the App is extremely simple, just tap the "color wheel" the desired color and the luminaire "magically" will copy is color! Woooohhhhooouuwww!!!
There are also buttons with preset colors for easy interaction.
In the final version of the App, an extra button was added to set up an IP other than the default (192.168.0.100).
So if this IP is being used on your local network, you can exchange it for another one and it will be stored in a small local "database" so that you do not need to reconfigure the IP with each use of the App. You can even set up a DDNS service and have control of your luminaires over the Internet from anywhere in the world.
Below, check out the video of printing, painting, assembly, testing and installation of our luminaires.
CODE
Code snippet #1Plain text
#include <SPI.h> #include <Ethernet.h> String leString; char c; String acao; EthernetServer server(80); int redPin ??= 3; //PWM int greenPin = 5; //PWM int bluePin ?= 6; //PWM int R,G,B; void setup() { ?byte mac[] = { 0xDE, 0xAD, 0xBE, 0xDA, 0xFE, 0xEE }; ?byte ip[] = { 192, 168, 0, 100 }; ?Ethernet.begin(mac, ip); ?server.begin(); ?pinMode(redPin, ??OUTPUT); ?pinMode(greenPin, OUTPUT); ?pinMode(bluePin, ?OUTPUT); ? ?Serial.begin(9600); ?Serial.println("RED ???GREEN ???BLUE"); } void loop() { ?// ?exemplo de parametros ?http://192.168.0.100/?R200G50B40f ?EthernetClient client = server.available(); ?if (client) { ???while (client.connected()){ ?????if (client.available()){ ???????char c = client.read(); ???????if (leString.length() < 100) { ?????????leString += c; ???????} ??????? ???????if (c == 'n') { ???????????????? ?????????if (leString.indexOf("?") > 0) { ???????????int inicioR = leString.indexOf("r") + 1; ???????????int fimR ???= leString.indexOf("g"); ???????????acao = leString.substring(inicioR, fimR); ???????????R = acao.toInt(); ???????????Serial.print(R); ???????????Serial.print(" ??"); ???????????int inicioG = leString.indexOf("g") + 1; ???????????int fimG ???= leString.indexOf("b"); ???????????acao = leString.substring(inicioG, fimG); ???????????G = acao.toInt(); ???????????Serial.print(G); ???????????Serial.print(" ??"); ???????????int inicioB = leString.indexOf("b") + 1; ???????????int fimB ???= leString.indexOf("f"); ???????????acao = leString.substring(inicioB, fimB); ???????????B = acao.toInt(); ???????????Serial.println(B); ????? ???????????client.println("HTTP/1.1 200 OK"); ???????????client.println("Content-Type: text/html"); ???????????client.println(); ???????????client.println("<HTML>"); ???????????client.println("<HEAD>"); ???????????client.println("</head>"); ???????????client.println("<body>"); ???????????client.println("RED = "); ???????????client.println(R); ???????????client.println("<p>"); ???????????client.println("GREEN = "); ???????????client.println(G); ???????????client.println("<p>"); ???????????client.println("BLUE = "); ???????????client.println(B); ???????????client.println("<p>"); ???????????analogWrite(redPin ?, R); ???????????analogWrite(greenPin, G); ???????????analogWrite(bluePin , B); ???????????client.println("</font><br>"); ???????????client.println("</body>"); ???????????client.println("</html>"); ???????????client.flush(); ???????????client.stop(); ???????????leString = ""; ?????????} ???????} ?????} ???} ?} } ?//fim do loop






