Project tutorial
Making a Cheap Aquarium Parameters Controller

Making a Cheap Aquarium Parameters Controller

You will be able to create a small aquarium assistant which will switch on/off the light and control water parameters automatically.

  • 7,222 views
  • 3 comments
  • 20 respects

Components and supplies

Apps and online services

About this project

Short video of what you can easily get

HARDWARE

This project requires minimal hardware components. You will need an ESP8266 development board, like NodeMCU that I'm using here, some sensor module as temperature, ph, salinity or light (depends on what you want to know).

Of course, basics stuff as breadboard, jumper cables and USB wire will be essential to build this thing.

Here is web hosting part where the sensors are connected (you can see that they are only light and temperature sensor. But it's pretty the same with two more sensors). As the ESP8266 proposes only one analog port, you will probably need an ADC (MCP3008 for example in which you can connect 8 analog sensors) depending in the sensors you use. (The SPI protocol of communication between the ESP and the MCP is already managed by MCP3008 library.)

Here is the light part. You can ESP8266 connected to the Arduino uno, and the neopixel LEDs.

LED matrix power supply with a voltage of 5 V and a current of 3A. See photos for editing. An ESP8266 card connected to an arduino UNO card via a voltage booster.

SOFTWARE

Get the sensors parameters

The ESP8266 firmware for this project is developed using Arduino IDE. You need to install the ESP8266 core to enable the Arduino IDE for ESP8266 programming. Instructions can be found here: http://easy-esp.com/getting-started-with-easyesp-1-using-arduino-ide/

You will also need the following Adafruit libraries for reading data from the sensors you'll use.

• ESP8266WiFi.h - For the wifi connection

• MCP3008.h - For the ADC

• TimeLib.h - For the time

• NtpClientLib.h - for the time too

• ESP8266WiFi.h & ESP8266WiFiMulti.h: To set the wifi connection on the ESP

• ESP8266WebServer.h: To communicate with ESP via HTTP requests

• Adafruit_NeoPixel.h & Adafruit_GFX.h & Adafruit_NeoMatrix.h: To order the matrix of neopixels leds

Create a web server

The code for a very basic HTML webpage with sensor output and auto refresh meta tag is include in the attachment. Note that you need to edit the SSID name ans password in the program to match with your WiFi network before uploading it to the NodeMCU board.

After uploading the program to NodeMCU, when the ESP8266 restarts it prints out on the serial monitor the IP adress it's allocated in the local network. In order to access the ESP8266 web server, you need to open a web browser on any computer tablet or smartphone connected to the same WiFi network and type in the URL field and hit enter. On receiving a client request, the ESP8266 serves a webpage containing all the sensor readings, as shown below.

The HTML page is refreshed automatically every 15 second to get the latest sensor readings.

see Sensor_Webserver.ino

gmail/sms alert

In order to get an alert when one of the parameters exceed a certain limit, I used IFTTT, a free web-based service to create chains of simple conditional statements, called applets.

I followed a really well-done tutorial on how to send an sms using ESP8266 and IFTTT. You can easily adapt it to send an e-mail. https://circuitdigest.com/microcontroller-projects/sending-sms-using-esp8266

I also made a function that limit the number of alert that you can receive. Because if something turns bad, you won't like to be harassed...

see Sensor_Webserver.ino

Send command form an ESP to another

The ESP8266 is used as a Web server that receives the commands to command the matrix leds by HTTP_GET requests. The requests come from the Master ESP with its specific IP adress.

The orders to be made are:

  • Switch on and off of leds at a given moment
  • modulation of the intensity of the LEDs according to the ambient brightness. We recover in the request the type of modulation (increase = 1 and decrease = 0)

Once the orders are received the ESP transmits the action to be made to the Arduino Uno by the serial port.

See wifi_led.ino

Control the luminosity

I decided to switch on the light at 8:00 am and to switch it off at 8:00 pm. So I needed to get the time. I used two libraries (TimeLib.h and NtpClientLib.h available on Arduino IDE).

NTP.getTimeDateString(NTP.getLastNTPSync()) return a string with the time and the date like: 10:00:00 17/03/March. Then I keep only the two-first characters to decide if it's night or day.

This is a very nice and handy way of monitoring the water parameters of our aquarium, as it allows to watch it on our tablets and smartphones that we are carrying all the time.

see Sensor_Webserver.ino

Power the Neopixel LEDs with Arduino uno

We use the Arduino board because it provides sufficient voltage (5V) to control the LED matrix . Depending on the orders received on the serial port, we call the function made for this purpose.

The code is pretty simple. No need to explain how it works.

See Matrix_led.ino

ACKNOWLEDGEMENT

Thanks to Rui Santos from Random Nerd Tutorials for sharing his DS1820-based temperature web server code.

Also to A. Aswinth Raj for his tutorial on how we can send a sms using ESP8266 and IFTTT.

This project was made with Aminata Diagne and Melaine Siako.

Code

ESP8266 - Sensor SideC/C++
Put it into your ESP8266 (the one which is connected to the sensors).
Makes sure that you've changed the SSID/Password and the board terminals.
/*********
  Projet objet connect
  Aminata Diagne - Martin Boisse

  Groupe Sensaqua

  Code prsent sur l'ESP ct capteurs
*********/

#include <Wire.h>
#include <ESP8266WiFi.h>
#include <Arduino.h>
#include <MCP3008.h>
// Heure
#include <TimeLib.h>
#include <NtpClientLib.h>

//define pin connections
#define CS_PIN D8
#define CLOCK_PIN D5
#define MOSI_PIN D7
#define MISO_PIN D6

// Valeurs borne des paramtres
#define MIN_TEMP 23
#define MAX_TEMP 27

#define MIN_PH 6.3
#define MAX_PH 7.5

#define MIN_SALINITE 1.022
#define MAX_SALINITE 1.025

#define MIN_NITRATE 0
#define MAX_NITRATE 50

// Variable de temps
int time_add;
bool flag; 

MCP3008 adc(CLOCK_PIN, MOSI_PIN, MISO_PIN, CS_PIN);

//Sensor values
float val_temp;
float val_lum;
float val_nitrate;
float val_salinite;
float val_ph;

const char* ssid = "Livebox-S3X3";
const char* password = "grossebite";

// const char* ssid = "AndroidAP";
// const char* password = "zypy3306";

// Pour l'envoie de message
const char* host = "maker.ifttt.com";
const int httpsPort = 443;

// Web Server on port 80
WiFiServer server(80);

/* ------------------------------ SETUP ------------------------------ */
void setup() {
  // Initializing serial port for debugging purposes
  Serial.begin(115200);
  delay(10);
  Wire.begin(D3, D4);
  Wire.setClock(100000);
  // Connecting to WiFi network
  Serial.println();
  Serial.print("En train de se connecter  ");
  Serial.println(ssid);
  
  WiFi.begin(ssid, password);
  
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("ESP est connect");
  
  // Starting the web server
  server.begin();
  Serial.println("Le server web fonctionne. En attente de l'adresse IP de l'ESP...");
  delay(10000);
  
  // Affichage de l'adresse IP
  Serial.println(WiFi.localIP());

  //Mise  0 du temps
  time_add = 0;
  flag = true;

  // Get l'heure pour grer la luminosit
  NTP.begin("pool.ntp.org", 1, true);
  NTP.setInterval(1000);

  Serial.print("Got NTP time: ");
  Serial.println(NTP.getTimeDateString(NTP.getLastNTPSync()));

}

/* ----------------------------------------------------------------------- */

/* ----------------------------- ALLUMAGE LED ---------------------------- */

/*
  Obtention de l'heure et envoie de la commande d'allumage des LED
*/

void setLED() {

  int value;

  // Get de l'heure
  String heure = NTP.getTimeDateString(NTP.getLastNTPSync());

  // Jour / Nuit
  bool jour = true;
  if(heure[0] == '8')
    jour = true;
  else if(heure[0] == '2' && heure[1] == '0')
    jour = false;

  if(jour)
    OnLed();
  else if(!jour)
    OffLed(); 

  // Ajustement en fonction de la luminosit
  if (luminosite < 850 )
    value = HIGH;
  else if (luminosite >= 850 )
    value = LOW;

}

void OnLed()  {

  // Connection vers ESP_LED (TCP)

  const char* host_ESP_LED = "192.168.43.237";
  WiFiClient client_ESP;
  const int httpPort = 80;

  if (!client_ESP.connect(host_ESP_LED, httpPort)) {
    Serial.println("connection failed");
    return;
  }

  Serial.print("connecting to ");
  Serial.println(host_ESP_LED);

  String url = "/ON";

  // This will send the request to the server
  client_ESP.print(String("GET ") + url + " HTTP/1.1\r\n" +
               "Host: " + host_ESP_LED + "\r\n" + 
               "Connection: close\r\n\r\n");
  unsigned long timeout = millis();
  while (client_ESP.available() == 0) {
    if (millis() - timeout > 5000) {
      Serial.println(">>> Client Timeout !");
      client_ESP.stop();
      return;
    }
  }
}

void OffLed() {

  // Connection vers ESP_LED (TCP)

  const char* host_ESP_LED = "192.168.43.237";
  WiFiClient client_ESP;
  const int httpPort = 80;

  if (!client_ESP.connect(host_ESP_LED, httpPort)) {
    Serial.println("connection failed");
    return;
  }

  Serial.print("connecting to ");
  Serial.println(host_ESP_LED);

  String url = "/OFF";

  // This will send the request to the server
  client_ESP.print(String("GET ") + url + " HTTP/1.1\r\n" +
               "Host: " + host_ESP_LED + "\r\n" + 
               "Connection: close\r\n\r\n");
  unsigned long timeout = millis();
  while (client_ESP.available() == 0) {
    if (millis() - timeout > 5000) {
      Serial.println(">>> Client Timeout !");
      client_ESP.stop();
      return;
    }
  }
}

/* ----------------------------------------------------------------------- */

/* ------------------------------ GET PARAM ------------------------------ */

/*
  Obtention des paramtres grce au MCP3008
*/

void getParam() {

  val_lum = adc.readADC(0); // Li le channel 0 du MCP3008 (pin 1)
  val_temp = adc.readADC(2) * (3.3*10/1023);
  val_ph = adc.readADC(5);
  val_salinite = adc.readADC(3);
  val_nitrate = adc.readADC(4);  

  delay(5000);
}

/* ----------------------------------------------------------------------- */

/* ----------------------------- SEND MESSAGE ---------------------------- */

/*
  Envoie du message d'alerte
*/

void sendMessage()  {

  if(flag == true)  {
    Serial.print("-------------- Envoie du message d'alerte --------------");
    WiFiClientSecure client;
    Serial.print("Connection  ");
    Serial.println(host);
    if (!client.connect(host, httpsPort)) {
      Serial.println("Connection echoue");
      return;
    }

    // Trouv sur le site IFTTT
    String url = "write your own";

    Serial.print("Appel de l'url suivant: ");
    Serial.println(url);
    // Envoie de la requte
    client.print(String("GET ") + url + " HTTP/1.1\r\n" +
                "Host: " + host + "\r\n" +
                "User-Agent: BuildFailureDetectorESP8266\r\n" +
                "Connection: close\r\n\r\n");
    Serial.println("Requte envoye");
    while (client.connected()) {
      String line = client.readStringUntil('\n');
      if (line == "\r") {
        Serial.println("requte reue");
        break;
      }
    } 
    String line = client.readStringUntil('\n');
    Serial.println("La rponse a t:");
    Serial.println("==========");
    Serial.println(line);
    Serial.println("==========");
    Serial.println("Fermeture de la connection");
  
    // Mise en attente du prochain SMS
    flag = false;
  }

}

/* ----------------------------------------------------------------------- */

/* --------------------------------- LOOP -------------------------------- */

void loop() {

  setLED();

  /* ----------------- Contrle des paramtres ----------------- */

  getParam();

  if(val_temp > MAX_TEMP || val_temp < MIN_TEMP)  
    sendMessage();
  // if(val_ph > MAX_PH || val_ph < MIN_PH)
  //   sendMessage();
  // if(val_salinite > MAX_SALINITE ||val_salinite < MIN_SALINITE)
  //   sendMessage();
  // if(val_nitrate > MAX_NITRATE || val_nitrate < MIN_NITRATE)
  //   sendMessage();  

  /* ------------------------------------------------------------ */

  /* ----------------- Limiter le nombre de SMS ----------------- */

  time_add++;
  if(time_add > 8000) {
    flag = true;
    time_add = 0;
  }

  /* ------------------------------------------------------------ */

  /* ------------ Ct Serveur WEB - coute client -------------- */

  // En ecoute pour de nouveaux clients
  WiFiClient client = server.available();
  
  if (client) {
    Serial.println("New client");
    // bolean to locate when the http request ends
    boolean blank_line = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        
        if (c == '\n' && blank_line) {

            /* ----------------- Affichage de la page Web ----------------- */

            client.println("HTTP/1.1 200 OK");
            client.println("Content-Type: text/html");
            client.println("Connection: close");
            client.println();
            // Web Page intro
            client.println("<!DOCTYPE HTML>");
            client.println("<html>");
            client.println("<head><META HTTP-EQUIV=\"refresh\" CONTENT=\"15\">");
            client.println("<style>");
            client.println("body  {");
            client.println("background: url(\"/img/background.png\");");
            client.println("background-repeat: no-repeat;");
            client.println("background-size: 53%;}");
            client.println("h4    {");
            client.println("font-family: verdana;");
            client.println("color: #FF4000;}");
            client.println("h3    {");
            client.println("font-family: verdana;");
            client.println("font-weight: bold;");
            client.println("color: teal;}");
            client.println("</style>");
            client.println("</head>");
            // Body
            client.println("<body>");
            client.println("<table border=\"2\" width=\"405\" cellpadding=\"10\">");
            client.println("<tbody>");
            client.println("<tr>");
            client.println("<td>");
            client.println("<h4>Temperature min: ");
            client.println(MIN_TEMP);
            client.println("&deg;C</h4>");
            client.println("<h3>Temperature actuelle: ");
            //Affichage temperature
            client.println(val_temp);
            Serial.print(val_temp);
            client.println("&deg;C</h3>");
            client.println("<h4>Temperature max: ");
            client.println(MAX_TEMP);
            client.println("&deg;C</h4></td></tr>");
            client.println("<tr><td>");
            client.println("<h4>Ph min: ");
            client.println(MIN_PH);
            client.println("</h4>");
            client.println("<h3>Ph actuel: ");
            //Affichage PH
            client.println(val_ph);
            client.println("</h3>");
            client.println("<h4>Ph max: ");
            client.println(MAX_PH);
            client.println("</h4></td></tr>");
            client.println("<tr><td>");
            client.println("<h4>Salinit&eacute; min: ");
            client.println(MIN_SALINITE);
            client.println("</h4>");
            client.println("<h3>Salinit&eacute; actuelle: ");
            //Affichage salinite
            client.println(val_salinite);
            client.println("</h3>");
            client.println("<h4>Salinit&eacute; max: ");
            client.println(MAX_SALINITE);
            client.println("</h4></td></tr>");
            client.println("<tr><td>");
            client.println("<h4>Taux de nitrate min: ");
            client.println(MIN_NITRATE);
            client.println("mg/Litre</h4>");
            client.println("<h3>Taux de nitrate actuel: ");
            //Affichage nitrate
            client.println(val_nitrate);
            client.println("</h3>");
            client.println("<h4>Taux de nitrate max: ");
            client.println(MAX_NITRATE);
            client.println("mg/Litre</h4></td></tr>");
            // Fin Page
            client.println("</tbody></table></body></html>");

            /* ------------------------------------------------------------ */

            break;
        }
        if (c == '\n') {
          // when starts reading a new line
          blank_line = true;
        }
        else if (c != '\r') {
          // when finds a character on the current line
          blank_line = false;
        }
      }
    }  
    // closing the client connection
    delay(1);
    client.stop();
    Serial.println("Client disconnected.");
  }

  /* ------------------------------------------------------------ */

} 

/* ----------------------------------------------------------------------- */
Wifi_led.inoC/C++
This is for ESP8266 that receive the command to switch on/off the light.
#include  <ESP8266WiFi.h>
#include  <ESP8266WiFiMulti.h>  
#include  <ESP8266mDNS.h>
#include  <ESP8266WebServer.h>


ESP8266WiFiMulti  wifiMulti;          //  Create  an  instance  of  the ESP8266WiFiMulti  class,  called  'wifiMulti'
ESP8266WebServer  server(80);       //  Create  a webserver object  that  listens for HTTP  request on  port  80

/********Prototypes***************/
void handleNotFound();
void allumage(void);
void extinction(void);
void modularite(void);

/**********************************/

String addr_client = "192.168.43.10"; // pour repondre a la requete d'un seul IP.
String addr_test ; 
String type,dat ; 


/*********************************/


void  setup(void){
    Serial.begin(115200);                 //  Start the Serial  communication to  send  messages  to  the computer
    wifiMulti.addAP("AndroidAP", "zypy3306");      //  add Wi-Fi networks  you want  to  connect to
    //Serial.println("Connecting  ...");
    int i = 0;
    while (wifiMulti.run()  !=  WL_CONNECTED) { //  Wait  for the Wi-Fi to  connect:  scan  for Wi-Fi networks, and connect to  the strongest of  the networks  above
        delay(250);
       // Serial.print('.');
    }
   // Serial.println('\n');
    //Serial.print("Connected to  ");
   // Serial.println(WiFi.SSID());                            //  Tell  us  what  network we're connected to
    //Serial.print("IP  address:\t");
    //Serial.println(WiFi.localIP());                     //  Send  the IP  address of  the ESP8266 to  the computer
    if  (MDNS.begin("esp8266")) {                           //  Start the mDNS  responder for esp8266.local
      //  Serial.println("mDNS  responder started");
    } else  {
        //Serial.println("Error setting up  MDNS  responder!");
    }

  
    server.on("/ON",  HTTP_GET, allumage); 
    server.on("/OFF",  HTTP_GET, extinction); 
    server.on("/MOD",  HTTP_GET,modularite); 
    server.onNotFound(handleNotFound);                //  When  a client  requests  an  unknown URI (i.e. something other than  "/"), call  function "handleNotFound"
    server.begin();                                                     //  Actually  start the server
    
   // Serial.println("HTTP  server  started");
}

/*****************************************/
void  loop(void){
    server.handleClient();                                        //  Listen  for HTTP  requests  from  clients
}
/*****************************************/

void  handleNotFound(){
    server.send(404,  "text/plain", "404: Not found");  //  Send  HTTP  status  404 (Not  Found)  when  there's no  handler for the URI in  the request
}
/*****************************************/
void allumage(void){
addr_test = server.client().remoteIP().toString(); 
  if(addr_test == addr_client){
    Serial.print('A');
    server.send(200);
  }
}
/*****************************************/
void extinction(void){

 addr_test = server.client().remoteIP().toString(); 
 if(addr_test == addr_client){
    Serial.print('E'); 
    server.send(200);
  }
}
/*****************************************/
void modularite(void){
  
  
  addr_test = server.client().remoteIP().toString();   
  if(addr_test == addr_client){
    type = server.arg(0);
        
    dat = 'M';
    dat +=';'; 
    dat +=type; 
  
    Serial.print(dat);
    server.send(200);
 }
  
}
matrix_led.inoC/C++
This is for the Arduino Uno. It switch on/off the light when esp tells it.
/********************************************************************* 
 Adafruit invests time and resources providing this open source code,
 please support Adafruit and open-source hardware by purchasing
 products from Adafruit!

 MIT license, check LICENSE for more information
 All text above, and the splash screen below must be included in
 any redistribution
*********************************************************************/
#include <Adafruit_NeoPixel.h>
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>

/*=========================================================================
    APPLICATION SETTINGS
                              
    MATRIX DECLARATION        Parameter 1 = width of NeoPixel matrix
                              Parameter 2 = height of matrix
                              Parameter 3 = pin number (most are valid)
                              Parameter 4 = matrix layout flags, add together as needed:
    NEO_MATRIX_TOP,
    NEO_MATRIX_BOTTOM,
    NEO_MATRIX_LEFT,
    NEO_MATRIX_RIGHT          Position of the FIRST LED in the matrix; pick two, e.g.
                              NEO_MATRIX_TOP + NEO_MATRIX_LEFT for the top-left corner.
                              NEO_MATRIX_ROWS, NEO_MATRIX_COLUMNS: LEDs are arranged in horizontal
                              rows or in vertical columns, respectively; pick one or the other.
    NEO_MATRIX_PROGRESSIVE,
    NEO_MATRIX_ZIGZAG         all rows/columns proceed in the same order, 
                              or alternate lines reverse direction; pick one.

                              See example below for these values in action.
    
    Parameter 5 = pixel type flags, add together as needed:
                              
    NEO_KHZ800                800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
    NEO_KHZ400                400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
    NEO_GRB                   Pixels are wired for GRB bitstream (most NeoPixel products)
    NEO_RGB                   Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
    -----------------------------------------------------------------------*/
    #define FACTORYRESET_ENABLE     1

    #define PIN                     6   // Which pin on the Arduino is connected to the NeoPixels
    #define width                   2
    #define height                  15

// Example for NeoPixel 8x8 Matrix.  In this application we'd like to use it 
// with the back text positioned along the bottom edge.
// When held that way, the first pixel is at the top left, and
// lines are arranged in columns, zigzag order.  The 8x8 matrix uses
// 800 KHz (v2) pixels that expect GRB color data.
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(width, height, PIN,
  NEO_MATRIX_TOP     + NEO_MATRIX_LEFT+
  NEO_MATRIX_COLUMNS + NEO_MATRIX_PROGRESSIVE,
  NEO_GRB            + NEO_KHZ800);
/*=========================================================================*/
#include <SoftwareSerial.h>

SoftwareSerial mySerial(0, 1); // RX, TX

String data ; 
int type ; 

/*=========================================================================*/

void setup(void)
{
  pinMode(PIN, OUTPUT);      // sets the digital pin 6 as output
  matrix.begin();
  matrix.setBrightness(50);
  matrix.fillScreen(0);
  matrix.show(); // This sends the updated pixel colors to the hardware.

  Serial.begin(115200);
  Serial.println("Arduino ready");
  mySerial.begin(115200);
  
}

/*=========================================================================*/

void loop(void)
{
   if (mySerial.available() > 0){ 
     data = mySerial.readString(); // Lecture des donnes arrivant sur le port serie
     
      if(data[0] == 'A'){
        Serial.println("allumage");
        allumage_progressif();
      }

     else if(data[0] == 'E'){
        Serial.println("extinction");
        extinction_progressif();
      }

      else if(data[0] == 'M'){
         Serial.println("\nmodulation");
         
         // Parse of String data
         type = data[2] -'0';
                    
         Serial.print("type = ");
         Serial.print(type);
         modulation_luminosite(type);
        }
   }
  
}

/*=========================================================================*/
/*=========================================================================*/
void allumage_progressif(void){
  /******Lumire rouge *******/
  matrix.drawPixel(0, 2, matrix.Color(255,0,0)); // x, y, color
  matrix.drawPixel(0,12, matrix.Color(255,0,0)); // x, y, color
  
  matrix.drawPixel(1, 7, matrix.Color(255,0,0)); // x, y, color
  matrix.show(); // This sends the updated pixel colors to the hardware.

  // Attente de 3 min 
  //delay(18000);
  delay(2000); // 2 s

   /******Lumire Bleue *******/
  matrix.drawPixel(0, 1, matrix.Color(0,0,255)); // x, y, color
  matrix.drawPixel(0, 3, matrix.Color(0,0,255)); // x, y, color
  matrix.drawPixel(0, 7, matrix.Color(0,0,255)); // x, y, color
  matrix.drawPixel(0, 11, matrix.Color(0,0,255)); // x, y, color
  matrix.drawPixel(0, 13, matrix.Color(0,0,255)); // x, y, color

  matrix.drawPixel(1, 12, matrix.Color(0,0,255)); // x, y, color
  matrix.drawPixel(1, 8, matrix.Color(0,0,255)); // x, y, color
  matrix.drawPixel(1, 6, matrix.Color(0,0,255)); // x, y, color
  matrix.drawPixel(1, 2, matrix.Color(0,0,255)); // x, y, color
  matrix.show(); // This sends the updated pixel colors to the hardware.
  
  // Attente de 10 min 
  //delay(60000);
  delay(4000); // 4 s

   /******Lumire Blanche *******/
  matrix.drawPixel(0, 0, matrix.Color(255,255,255)); // x, y, color
  matrix.drawPixel(0, 4, matrix.Color(255,255,255)); // x, y, color
  matrix.drawPixel(0, 5, matrix.Color(255,255,255)); // x, y, color
  matrix.drawPixel(0, 6, matrix.Color(255,255,255)); // x, y, color
  matrix.drawPixel(0, 8, matrix.Color(255,255,255)); // x, y, color
  matrix.drawPixel(0, 9, matrix.Color(255,255,255)); // x, y, color
  matrix.drawPixel(0, 10, matrix.Color(255,255,255)); // x, y, color
  matrix.drawPixel(0, 14, matrix.Color(255,255,255)); // x, y, color

  matrix.drawPixel(1, 14, matrix.Color(255,255,255)); // x, y, color
  matrix.drawPixel(1, 13, matrix.Color(255,255,255)); // x, y, color
  matrix.drawPixel(1, 11, matrix.Color(255,255,255)); // x, y, color
  matrix.drawPixel(1, 10, matrix.Color(255,255,255)); // x, y, color
  matrix.drawPixel(1, 9, matrix.Color(255,255,255)); // x, y, color
  matrix.drawPixel(1, 5, matrix.Color(255,255,255)); // x, y, color
  matrix.drawPixel(1, 4, matrix.Color(255,255,255)); // x, y, color
  matrix.drawPixel(1, 3, matrix.Color(255,255,255)); // x, y, color
  matrix.drawPixel(1, 1, matrix.Color(255,255,255)); // x, y, color
  matrix.drawPixel(1, 0, matrix.Color(255,255,255)); // x, y, color
  matrix.show(); // This sends the updated pixel colors to the hardware.

}
/*=========================================================================*/
/*=========================================================================*/

void extinction_progressif(void){

  /******Lumire Blanche *******/
  matrix.drawPixel(0, 0, matrix.Color(0,0,0)); // x, y, color
  matrix.drawPixel(0, 4, matrix.Color(0,0,0)); // x, y, color
  matrix.drawPixel(0, 5, matrix.Color(0,0,0)); // x, y, color
  matrix.drawPixel(0, 6, matrix.Color(0,0,0)); // x, y, color
  matrix.drawPixel(0, 8, matrix.Color(0,0,0)); // x, y, color
  matrix.drawPixel(0, 9, matrix.Color(0,0,0)); // x, y, color
  matrix.drawPixel(0, 10, matrix.Color(0,0,0)); // x, y, color
  matrix.drawPixel(0, 14, matrix.Color(0,0,0)); // x, y, color

  matrix.drawPixel(1, 14, matrix.Color(0,0,0)); // x, y, color
  matrix.drawPixel(1, 13, matrix.Color(0,0,0)); // x, y, color
  matrix.drawPixel(1, 11, matrix.Color(0,0,0)); // x, y, color
  matrix.drawPixel(1, 10, matrix.Color(0,0,0)); // x, y, color
  matrix.drawPixel(1, 9, matrix.Color(0,0,0)); // x, y, color
  matrix.drawPixel(1, 5, matrix.Color(0,0,0)); // x, y, color
  matrix.drawPixel(1, 4, matrix.Color(0,0,0)); // x, y, color
  matrix.drawPixel(1, 3, matrix.Color(0,0,0)); // x, y, color
  matrix.drawPixel(1, 1, matrix.Color(0,0,0)); // x, y, color
  matrix.drawPixel(1, 0, matrix.Color(0,0,0)); // x, y, color
  matrix.show(); // This sends the updated pixel colors to the hardware.

   // Attente de 10 min 
  //delay(60000);
  delay(4000); //  s

  
  /******Lumire Bleue *******/
  matrix.drawPixel(0, 1, matrix.Color(0,0,0)); // x, y, color
  matrix.drawPixel(0, 3, matrix.Color(0,0,0)); // x, y, color
  matrix.drawPixel(0, 7, matrix.Color(0,0,0)); // x, y, color
  matrix.drawPixel(0, 11, matrix.Color(0,0,0)); // x, y, color
  matrix.drawPixel(0, 13, matrix.Color(0,0,0)); // x, y, color

  matrix.drawPixel(1, 12, matrix.Color(0,0,0)); // x, y, color
  matrix.drawPixel(1, 8, matrix.Color(0,0,0)); // x, y, color
  matrix.drawPixel(1, 6, matrix.Color(0,0,0)); // x, y, color
  matrix.drawPixel(1, 2, matrix.Color(0,0,0)); // x, y, color
  matrix.show(); // This sends the updated pixel colors to the hardware.
  
  // Attente de 3 min 
  //delay(18000);
  delay(2000); // 1 s
  
  
  /******Lumire rouge *******/
  matrix.drawPixel(0, 2, matrix.Color(0,0,0)); // x, y, color
  matrix.drawPixel(0,12, matrix.Color(0,0,0)); // x, y, color
  
  matrix.drawPixel(1, 7, matrix.Color(0,0,0)); // x, y, color
  matrix.show(); // This sends the updated pixel colors to the hardware.

 
}
/*=========================================================================*/
// Type    : augmentation = 1 , diminution = 0
/*=========================================================================*/
void modulation_luminosite(int type){

   int pourcentage = 90 ; // pourcentage de changement
   int ancien_val,new_val,delta;
  
  ancien_val= matrix.getBrightness(); 
  delta = (int)((ancien_val * pourcentage) / 100 ); 
  
  switch(type){
    case 0 : 
        new_val = ancien_val - delta ; 
        matrix.setBrightness(new_val);
        break ; 
    case 1:
        new_val = ancien_val + delta ; 
        matrix.setBrightness(new_val);
        break;
     default :
        Serial.print("Action impossible\n\r");
  }

}

Comments

Similar projects you might like

Solar Panel Sun Tracker - Phone Charger

Project tutorial by FIELDING

  • 27,297 views
  • 11 comments
  • 118 respects

Reef Controller

Project showcase by Shawn Leclair

  • 13,537 views
  • 0 comments
  • 19 respects

Wireless weather station (Arduino + ESP8266 + Thingspeak)

Project tutorial by Alin-Constantin Paun

  • 8,862 views
  • 2 comments
  • 11 respects

RGB Lighting Reactive to Music and WiFi Controlled

Project in progress by Philipp Jurasic

  • 4,052 views
  • 2 comments
  • 21 respects

Smart Blinds

Project tutorial by Froz3nArcher

  • 14,887 views
  • 3 comments
  • 49 respects

Circuito Arduino Controller Pad

Project tutorial by AhmedAzouz

  • 2,676 views
  • 1 comment
  • 7 respects
Add projectSign up / Login