• Non ci sono risultati.

Elettronica - E5 Safety 1, 2

MKR Vidor 4000

8) Modulo Wi_Fi - LED IoT

LED IoT

Il LED verde, segnala la trasmissione dei dati al Cloud ThingSpeak.

LED ON : inizio trasmissione LED OFF: fine trasmissione

9) Canale ThingSpeak: https://thingspeak.com/channels/1548306

Tramite il seguente link è possibile consultate i dati: https://thingspeak.com/channels/1548306

Per la consultazione tramite cellulare oppure tablet si deve scaricare un App ThingSpeak Viewer, ad esempio ThingView e configurarla con il canale 1548306. In figura è riportato lo screenshot del test effettuato il 00-0-20xx

.

Software di gestione - Arduino 2560 (Estratto-Scheda Principale) - Assembling_4.0_2560_BlueTooth_01B) // Assembling 4.0 - Meccatronica - comandi tramite BlueTooth

// Modulo HC-06 Bluetooth con Arduino MEGA 2560 // ---

#include <Servo.h>

Servo myservo; // Oggetto servo

byte pin1S1=30,pin1S2=31,pin2S1=32,pin2S2=33; // Pin Sensori F.C. cilindri (orizzontale e verticale)

byte pin1M1=46,pin1M2=47,pin2M1=48,pin2M2=49; // Pin elettrovalvole Cilindri (orizzontale e verticale)

byte pinza=50; // Pin Pinza

byte mark=41,mag=27,allarme=7,auto_man=11,led_auto_man=10;

byte mot=42,sol=43; // mot=Variabile comando motore, sol=variabile comando solenoide byte ind=25; // ind=variabile sensore induttivo

byte er1=44,es1=45; // Variabili Elettrovalvole Blocco 1-es1: Spinta Pezzo, er1: Rientro spinta pezzo byte es=38,er=39,ee=40; // Variabili Elettrovalvole Blocco 2-es: Spinta Pezzo, er: Rientro spinta pezzo byte Pin1M1=46,Pin1M2=47; // Pin elettrovalvola orizzontale

byte pinscarto=9; // Pin indicazione scarto char data_in;//

int red,green,blue; //RGB Color int ritardo=1000;

unsigned long last_time=0;int update_interval=100;

void setup() {

Serial3.begin(9600); //set baud rate

pinMode(pin1M1,OUTPUT);pinMode(pin1M2,OUTPUT);pinMode(pin2M1,OUTPUT);pinMode(pin2M2,OUTPUT);

pinMode(mot, OUTPUT);pinMode(sol, OUTPUT);pinMode(pinza, OUTPUT);

pinMode(mark, OUTPUT);pinMode(er1,OUTPUT);pinMode(es1,OUTPUT);pinMode(ee,OUTPUT);

pinMode(er,OUTPUT);pinMode(es,OUTPUT);pinMode(pinscarto,OUTPUT);

pinMode(mag,INPUT);pinMode(ind,INPUT);pinMode(allarme,INPUT);

pinMode(pin1S1,INPUT);pinMode(pin1S2,INPUT); pinMode(pin2S1,INPUT);pinMode(pin2S2,INPUT);

void loop() {

digitalWrite(ee,LOW); // Pulitura pezzo Off if (digitalRead(auto_man)==HIGH)

Automatico(); // Funzione comandi Automatico }

}

Software di gestione - Arduino 2560 (Estratto-Scheda Automatico) void Automatico ()

{

digitalWrite(10,LOW);

red=255; green=255; blue=0; //<---Set RGB color

Serial3.print("*TR"+String(red)+"G"+String(green)+"B"+String(blue)+"*");

red=0; green=0; blue=0; //<---Set RGB color here

Serial3.print("*MR"+String(red)+"G"+String(green)+"B"+String(blue)+"*");

while(digitalRead(mag)==HIGH) {

myservo.write(108);delay(15);

digitalWrite(es1,HIGH);digitalWrite(er1,LOW);delay (ritardo); // Spinta pezzo Metallo digitalWrite(er1,HIGH);digitalWrite(es1,LOW);delay (ritardo); //Rientro Spinta pezzo Metallo digitalWrite(mot,HIGH);delay (1000);digitalWrite(mot,LOW);delay(1000);

if(digitalRead(ind)==HIGH) {

digitalWrite(mark,HIGH);delay (800);digitalWrite(mark,LOW);

digitalWrite(mot,HIGH);delay (4000);digitalWrite(mot,LOW);

digitalWrite(es,HIGH);digitalWrite(er,LOW);delay (ritardo); // Spinta pezzo Plastica

digitalWrite(er,HIGH);digitalWrite(es,LOW);delay (ritardo); //Rientro spinta pezzo Plastica digitalWrite(pin1M1,HIGH); digitalWrite(pin1M2,LOW);delay(ritardo);

digitalWrite(pin2M1,HIGH); digitalWrite(pin2M2,LOW);delay(ritardo);

digitalWrite(pinza,HIGH); delay(ritardo);

digitalWrite(pin2M1,LOW); digitalWrite(pin2M2,HIGH); delay(ritardo);

digitalWrite(pin1M1,LOW); digitalWrite(pin1M2,HIGH);delay(ritardo);

digitalWrite(pin2M1,HIGH); digitalWrite(pin2M2,LOW);delay(ritardo);

digitalWrite(pin2M2,HIGH); digitalWrite(pin2M1,LOW);delay(ritardo);

digitalWrite(pin2M1,LOW); digitalWrite(pin2M2,HIGH);delay(ritardo);

digitalWrite(ee,HIGH);delay(300);digitalWrite(ee,LOW); // Pulitura pezzo myservo.write(0);delay(1000);digitalWrite(pinza,LOW);delay(ritardo);

myservo.write(108);delay(1000);

} else {

digitalWrite(sol,HIGH);//delay (5000);digitalWrite(sol,LOW);

digitalWrite(mot,HIGH);delay (2900);digitalWrite(mot,LOW);digitalWrite(sol,LOW);

digitalWrite(pinscarto,HIGH); delay (1200);digitalWrite(pinscarto,LOW);

} } }

Software di gestione - Arduino 2560 (Estratto-Scheda Manuale) // Sequenza manuale con comandi BlueTooth

void Manuale () {

digitalWrite(10,HIGH);

red=255; green=255; blue=0; //<---Set RGB color

Serial3.print("*MR"+String(red)+"G"+String(green)+"B"+String(blue)+"*");

red=0; green=0; blue=0; //<---Set RGB color here

Serial3.print("*TR"+String(red)+"G"+String(green)+"B"+String(blue)+"*");

if(Serial3.available()){

data_in=Serial3.read(); // Lettura carattere BlueTooth sulla Seriale 3 if (data_in=='R'){ // Carattere "R" comando cilindro marcatore digitalWrite(mark,HIGH);delay (800);// Cilindro marcatore HIGH

digitalWrite(es1,HIGH);digitalWrite(er1,LOW);delay (500); // Spinta pezzo Metallo }

if(data_in=='g'){ //Caratter "g" Comando cilindo doppio effetto spinta pezzo di metallo digitalWrite(er1,HIGH);digitalWrite(es1,LOW);delay (500); //Rientro Spinta pezzo Metallo }

if (data_in=='D'){ // Comando cilindo doppio effetto spinta pezzo di plastica

digitalWrite(es,HIGH);digitalWrite(er,LOW);delay (500); // Spinta pezzo di Plastica }

if(data_in=='d'){ //Comando cilindo doppio effetto spinta pezzo di metallo

digitalWrite(er,HIGH);digitalWrite(es,LOW);delay (500); //Rientro spinta pezzo di Plastica } digitalWrite(sol,HIGH); // Solenoide ON

digitalWrite(pinscarto,HIGH); delay (1200); digitalWrite(pinscarto,LOW);

}

digitalWrite(pin1M1,HIGH);digitalWrite(pin1M2,LOW);

}

if(data_in=='2'){ // ---

digitalWrite(pin1M1,LOW); digitalWrite(pin1M2,HIGH);

}

// -- Cilindro Verticale 2M1 e 2M2 -- if (data_in=='3'){ // --- Down

digitalWrite(pin2M1,HIGH);digitalWrite(pin2M2,LOW);

}

if(data_in=='1'){ // --- Up

digitalWrite(pin2M1,LOW); digitalWrite(pin2M2,HIGH);

}

// -- Comando pinza --

if (data_in=='P'){ // Comando pinza digitalWrite(pinza,HIGH); // pinza on }

if(data_in=='p'){ // Comando pinza digitalWrite(pinza,LOW); // pinza OFF }

// --- // -- Comando pulitura pezzo --

if (data_in=='E'){ // Comando pulitura pezzo

digitalWrite(ee,HIGH);delay(200);digitalWrite(ee,LOW); // Pulitura pezzo ON }

if(data_in=='e'){ // Comando pinza

digitalWrite(ee,LOW); // Pulitura pezzo Off }

// ---

if (data_in=='A'){ // Comando ServoMotore

myservo.write(108);delay(1000); // Servo posizione 108°

}

if(data_in=='a'){ // Comando ServoMotore

myservo.write(0);delay(1000); //Servo posizione 0°

} }

///////////// Send Data to Android device unsigned long t=millis();

if((t-last_time)>update_interval){

red=0; green=255; blue=0; //<---Set RGB color

red=255; green=0; blue=0; //<---Set RGB color here

Serial3.print("*LR"+String(red)+"G"+String(green)+"B"+String(blue)+"*");

}

//Comando Led Sensori cilindro orizzontale 1S1 - 1S2 if (digitalRead(pin1S1)==HIGH)// Sensore 2S1 {

red=0; green=255; blue=0; //<---Set RGB color

Serial3.print("*JR"+String(red)+"G"+String(green)+"B"+String(blue)+"*");

} else {

red=255; green=0; blue=0; //<---Set RGB color here

Serial3.print("*JR"+String(red)+"G"+String(green)+"B"+String(blue)+"*");

}

if (digitalRead(pin1S2)==HIGH)// Sensore 2S1 {

red=0; green=255; blue=0; //<---Set RGB color

Serial3.print("*FR"+String(red)+"G"+String(green)+"B"+String(blue)+"*");

} else {

red=255; green=0; blue=0; //<---Set RGB color here

Serial3.print("*FR"+String(red)+"G"+String(green)+"B"+String(blue)+"*");

}

if (digitalRead(pin2S1)==HIGH) // Sensore 2S1 {

red=0; green=255; blue=0; //<---Set RGB color

Serial3.print("*GR"+String(red)+"G"+String(green)+"B"+String(blue)+"*");

} else

{

red=255; green=0; blue=0; //<---Set RGB color here

Serial3.print("*GR"+String(red)+"G"+String(green)+"B"+String(blue)+"*");

}

if (digitalRead(pin2S2)==HIGH) // Sensore 2S1 {

red=0; green=255; blue=0; //<---Set RGB color

Serial3.print("*HR"+String(red)+"G"+String(green)+"B"+String(blue)+"*");

} else {

red=255; green=0; blue=0; //<---Set RGB color here

Serial3.print("*HR"+String(red)+"G"+String(green)+"B"+String(blue)+"*");

}

if (digitalRead(allarme)==HIGH) // Sensore 2S1 {

red=255; green=0; blue=0; //<---Set RGB color

Serial3.print("*9R"+String(red)+"G"+String(green)+"B"+String(blue)+"*");

} else {

red=0; green=255; blue=0; //<---Set RGB color here

Serial3.print("*9R"+String(red)+"G"+String(green)+"B"+String(blue)+"*");

} } }

Software di gestione - MKR Vidor 4000 (Estratto-Scheda Principale Esempio_10) /*

Assembling 4.0 - Meccatronica

*/

#define TRIGGER_PIN 5 // Arduino pin tied to trigger pin on the ultrasonic sensor.

#define ECHO_PIN 4 // Arduino pin tied to echo pin on the ultrasonic sensor.

#define MAX_DISTANCE 400 // Maximum distance we want to ping for (in centimeters).

//Maximum sensor distance is rated at 400-500cm.

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.

// Color definitions

#define DHTTYPE DHT22 //DHT22 (AM2302), AM2321 DHT dht(DHTPIN, DHTTYPE);

RTC_DS1307 rtc;

//#define DS1307_I2C_ADDRESS 0x68

#define CCS811_ADDR 0x5A //I2C Address CCS811 CCS811 mySensor(CCS811_ADDR);

Vidor_GFX vdgfx;

#include <Adafruit_MLX90614.h> //I2C ADDR 0x5B Adafruit_MLX90614 mlx = Adafruit_MLX90614();

//char ssid[] = "WIND-WiFi-D552"; // Wi-Fi SSID WIND //char pass[] = "j7e1tm7r"; // Wi-Fi Password WIND char ssid[] = "IPSIA_NEW"; // Wi-Fi SSID IPSIA char pass[] = "ldxxxxxxxxxxxxx"; // Wi-Fi password IPSIA char ora[9];char data[12];

String ips;

int status = WL_IDLE_STATUS;

WiFiClient client;

int pezzi=0,scarto=0; // Var. pezzi=conta pezzi finiti - scarto=pezzi scartati int CO2,TVOC,gas,rumore;

float voltrumore,dB;

float Tm,Ta, Ta2,hic,Dp, Um;//Tm:Temp. Motore, hic: Indice calore float d,vs;//variabili per il calcolo della distanza

float dmin=35.0;// Distanza minima di sicurezza byte k=0;

byte dist=1; //Pin distanza byte pinfire=3;//Pin Fire

byte Fire=0;// Pin Output per allarme Fire byte pingas=6;// Pin Output per allarme Gas long intervallo=19000, tempo;

unsigned long canale1 = 1548306;const char * WriteAPIKey1 = "NFX7GPFSTP2F3ANX";

unsigned long canale2 = 1637722;const char * WriteAPIKey2 = "BULOYIRH3PTWKCK1";

const char * ReadAPIKey1 = "0OOFHQY27BC0G07W";

void setup() {

dht.begin(); // Inizializzazione DHT22

pinMode(pinfire,INPUT);pinMode(Fire,OUTPUT);pinMode(dist,OUTPUT);pinMode(pingas,OUTPUT);

pinMode(7,INPUT);

Serial.begin(9600);

Wire.begin();

#else

Wire.begin(); // Shield I2C pins connect to alt I2C bus on Arduino Due

#endif rtc.begin();

CCS811Core::status returnCode = mySensor.begin();

if (returnCode != CCS811Core::SENSOR_SUCCESS) {

Serial.println(".begin() returned with an error.");

while (1); //Hang if there was a problem.

}

Serial.println(mlx.readEmissivity());

// Initialize the FPGA if (!FPGA.begin()) {

Serial.println("Initialization failed!");

while (1) {}

vdgfx.text.setColor(vdgfx.Blue());vdgfx.println(" - Meccatronica");

vdgfx.fillRect(9,61, 625,24, vdgfx.White());

vdgfx.fillRect(349,232, 145,24, vdgfx.White()); // Sfondo scritta Cloud

vdgfx.drawLine(8,59, 632,59, vdgfx.Red());vdgfx.drawLine(8,85, 632,85, vdgfx.Red());

//vdgfx.drawLine(8,85, 632,85, vdgfx.Red());

vdgfx.text.setColor(vdgfx.Blue());

vdgfx.text.setCursor(10,80); vdgfx.println("Ambiente");

vdgfx.text.setCursor(351,80); vdgfx.println("Produzione");

vdgfx.text.setCursor(495,80); vdgfx.println("Sicurezza");

vdgfx.text.setCursor(351,250);vdgfx.println("Cloud:Thin");

vdgfx.text.setCursor(10,110); vdgfx.println("CO2: ppm");

vdgfx.text.setCursor(175,110);vdgfx.println("TVOC: ppb");

vdgfx.text.setCursor(351,110);vdgfx.println("Pezzi:");

vdgfx.text.setCursor(351,130);vdgfx.println("Scart:");

vdgfx.text.setCursor(10,130); vdgfx.println("Ta1: *C");

vdgfx.text.setCursor(495,110);vdgfx.println("Tmot:");

vdgfx.text.setCursor(495,130);vdgfx.println("Fire:");

vdgfx.text.setCursor(495,150);vdgfx.println("Dmin:");

vdgfx.text.setCursor(495,170);vdgfx.println("Gas :");

vdgfx.text.setCursor(495,190);vdgfx.println("CO2 :");

vdgfx.text.setCursor(495,210);vdgfx.println("TVOC:");

vdgfx.text.setCursor(495,230);vdgfx.println("Noise:");

vdgfx.text.setCursor(10,150);vdgfx.println("Ta2: *C");

vdgfx.text.setCursor(175,130);vdgfx.println("Tmot: *C");

vdgfx.text.setCursor(175,150); vdgfx.println("UM : %");

vdgfx.text.setCursor(10,170);vdgfx.println("Hic: *C");

vdgfx.text.setCursor(10,190);vdgfx.println("Tru: *C");

vdgfx.drawRect(574,94, 57,20, vdgfx.Purple());

vdgfx.drawRect(574,114, 57,20, vdgfx.Purple()); vdgfx.drawRect(574,134, 57,20, vdgfx.Purple());

vdgfx.drawRect(574,154, 57,20, vdgfx.Purple()); vdgfx.drawRect(574,174, 57,20, vdgfx.Purple());

vdgfx.drawRect(574,194, 57,20, vdgfx.Purple()); vdgfx.drawRect(574,214, 57,20, vdgfx.Purple());

vdgfx.drawRect(351,257, 24,20, vdgfx.Purple()); // Bordo TX Cloud vdgfx.drawRect(377,257, 34,20, vdgfx.Purple()); // Bordo TX Time vdgfx.drawRect(494,60, 140,230, vdgfx.Red());

vdgfx.drawLine(10,460, 630,460, vdgfx.Red());

vdgfx.drawRect(349,232, 145,58, vdgfx.Red()); // Rettangolo Cloud vdgfx.drawLine(349,255, 493,255, vdgfx.Red()); // Linea Cloud vdgfx.drawRect(8,60, 342,230, vdgfx.Red());

vdgfx.fillRect(353,259, 20,16, vdgfx.Red());

tempo=millis();

}

void loop() {

{

//If so, have the sensor read and calculate the results.

//Get them later

mySensor.readAlgorithmResults();

CO2=mySensor.getCO2();TVOC=mySensor.getTVOC();

Tm=mlx.readObjectTempC();Ta=mlx.readAmbientTempC();

Ta2=dht.readTemperature(); // Lettura temperatura Um=dht.readHumidity(); // Lettura Umidità

hic = dht.computeHeatIndex(Ta2, Um, false);

Dp=dewPointFast(Ta2,Um);

gas=map(analogRead(A1), 0,1023,0,100);

vs = 331.45 + (0.606 * 25) + (0.0124 * 50); //Velocità del suono in m/s - Correzione con Temp. e Umidità

unsigned int tempo= sonar.ping_median(40); // Invia un ping multiplo (40 ping),restituisce il tempo medio di echo in microsecondi d=(vs*tempo/2.0)/10000.0;

if(digitalRead(7)==HIGH) {

scarto=scarto+1;

}

vdgfx.fillRect(163,235, 80,18, vdgfx.White());

vdgfx.text.setCursor(165,250);vdgfx.text.setColor(vdgfx.Purple());vdgfx.println(d,1);

if(digitalRead(2)==HIGH) {

vdgfx.fillRect(522,38, 111,19, vdgfx.White());

vdgfx.text.setCursor(520,54);vdgfx.text.setColor(vdgfx.Blue());vdgfx.println(ora);

vdgfx.fillRect(63,95, 60,18, vdgfx.White());

vdgfx.text.setCursor(65,110);vdgfx.text.setColor(vdgfx.Purple());vdgfx.println(CO2);

vdgfx.fillRect(242,95, 60,18, vdgfx.White());

vdgfx.text.setCursor(245,110);vdgfx.text.setColor(vdgfx.Purple());vdgfx.println(TVOC);

vdgfx.fillRect(432,95, 55,18, vdgfx.White());

vdgfx.text.setCursor(435,110);vdgfx.text.setColor(vdgfx.Blue());vdgfx.println(pezzi);

vdgfx.fillRect(432,115, 55,18, vdgfx.White());

vdgfx.text.setCursor(435,130);vdgfx.text.setColor(vdgfx.Blue());vdgfx.println(scarto);

vdgfx.fillRect(63,115, 60,18, vdgfx.White());

vdgfx.text.setCursor(65,130);vdgfx.text.setColor(vdgfx.Blue());vdgfx.println(Ta,1);

vdgfx.fillRect(242,115, 60,18, vdgfx.White());

vdgfx.text.setCursor(245,130);vdgfx.text.setColor(vdgfx.Purple());vdgfx.println(Tm,1);

//vdgfx.fillRect(548,95, 60,18, vdgfx.White());

//vdgfx.text.setCursor(547,110);vdgfx.text.setColor(vdgfx.Blue());vdgfx.println(Tm,1);

vdgfx.fillRect(63,135, 60,18, vdgfx.White());

vdgfx.text.setCursor(65,150);vdgfx.text.setColor(vdgfx.Blue());vdgfx.println(Ta2,1);

vdgfx.fillRect(242,135, 60,18, vdgfx.White());

vdgfx.text.setCursor(245,150);vdgfx.text.setColor(vdgfx.Blue());vdgfx.println(Um,1);

vdgfx.fillRect(63,155, 60,18, vdgfx.White());

vdgfx.text.setCursor(65,170);vdgfx.text.setColor(vdgfx.Blue());vdgfx.println(hic,1);

vdgfx.fillRect(63,175, 60,18, vdgfx.White());

vdgfx.text.setCursor(65,190);vdgfx.text.setColor(vdgfx.Blue());vdgfx.println(Dp,1);

// Calcolo Rumore rumore=0;

for (int i = 1; i <= 5; i++) {

rumore=rumore+analogRead(A2);

}

rumore=rumore/5;

dB=(rumore+83.2073)/(10.1879);

voltrumore=rumore*3.3/1024.0;

//vdgfx.fillRect(263,235, 80,18, vdgfx.White());

//vdgfx.text.setCursor(265,250);vdgfx.text.setColor(vdgfx.Purple());vdgfx.println(rumore);

// Scrittura Canale 1:1548306 ThingSpeak vdgfx.fillRect(378,258, 32,18, vdgfx.White());

vdgfx.text.setCursor(379,273);vdgfx.text.setColor(vdgfx.Blue());vdgfx.println(19-(millis()-tempo)/1000.0,0);

k=(millis()-tempo)/1000.0;

vdgfx.drawLine(353+k,261, 353+k,265, vdgfx.White());

//vdgfx.println("dB");

if (millis()-tempo>intervallo) {

vdgfx.fillRect(353,259, 20,16, vdgfx.Green());

ThingSpeak.setField(1, CO2);ThingSpeak.setField(2, TVOC);

ThingSpeak.setField(3, Tm);ThingSpeak.setField(4, Ta);

ThingSpeak.setField(5, Ta2);ThingSpeak.setField(6, Um);

ThingSpeak.setField(7, hic);ThingSpeak.setField(8,Dp );

ThingSpeak.writeFields(canale1, WriteAPIKey1);

//Scrittura Canale 2:1637722 ThingSpeak

ThingSpeak.setField(1, gas);ThingSpeak.setField(2, dB);

ThingSpeak.setField(3, d); ThingSpeak.setField(4, pezzi);ThingSpeak.setField(5, scarto);

ThingSpeak.setField(6, digitalRead(pinfire));

ThingSpeak.writeFields(canale2, WriteAPIKey2);

vdgfx.fillRect(353,259, 20,16, vdgfx.Red());

tempo=millis();

}

delay (20);

}

double dewPointFast(double celsius, double humidity) {

Software di gestione - MKR Vidor 4000 (Estratto-Scheda Principale Allarme)

vdgfx.fillRect(575,115, 55,18, vdgfx.Red());

digitalWrite(Fire,HIGH);

} else {

vdgfx.fillRect(575,115, 55,18, vdgfx.Green());

digitalWrite(Fire,LOW);

}

vdgfx.fillRect(575,95, 55,18, vdgfx.Green());

}

else if(Tm>=45&&Tm<70) {

vdgfx.fillRect(575,95, 55,18, vdgfx.Purple());

} else {

vdgfx.fillRect(575,95, 55,18, vdgfx.Red());

}

// Controllo Distanza if(d<dmin)

{

vdgfx.fillRect(575,135, 55,18, vdgfx.Red());

vdgfx.text.setCursor(573,150);vdgfx.text.setColor(vdgfx.White());vdgfx.print(d,1);

digitalWrite(dist,HIGH);

} else {

if(gas>=5) {

vdgfx.fillRect(575,155, 55,18, vdgfx.Red());

vdgfx.text.setCursor(573,170);vdgfx.text.setColor(vdgfx.White());vdgfx.print(gas);vdgfx.println("%");

digitalWrite(pingas,HIGH);

} else {

vdgfx.fillRect(575,155, 55,18, vdgfx.Green());

vdgfx.text.setCursor(573,170);vdgfx.text.setColor(vdgfx.Blue());vdgfx.print(gas);vdgfx.println("%");

digitalWrite(pingas,LOW);

}

vdgfx.fillRect(575,175, 55,18, vdgfx.Green());

}

else if(CO2>=1500&&CO2<5000) {

vdgfx.fillRect(575,175, 55,18, vdgfx.Purple());

} else {

vdgfx.fillRect(575,175, 55,18, vdgfx.Red());

}

// Controllo TVOC if(TVOC<50) {

vdgfx.fillRect(575,195, 55,18, vdgfx.Green());

}

else if(TVOC>=50&&TVOC<150) {

vdgfx.fillRect(575,195, 55,18, vdgfx.Purple());

} else {

vdgfx.fillRect(575,195, 55,18, vdgfx.Red());

}

// Controllo Rumore

if(dB<60) {

vdgfx.fillRect(575,215, 55,18, vdgfx.Green());

vdgfx.text.setCursor(573,230);vdgfx.text.setColor(vdgfx.Blue());vdgfx.print(dB,0);vdgfx.println("dB");

}

else if(dB>=60&&dB<80) {

vdgfx.fillRect(575,215, 55,18, vdgfx.Purple());

vdgfx.text.setCursor(573,230);vdgfx.text.setColor(vdgfx.White());vdgfx.print(dB,0);vdgfx.println("dB");

} else {

vdgfx.fillRect(575,215, 55,18, vdgfx.Red());

vdgfx.text.setCursor(573,230);vdgfx.text.setColor(vdgfx.White());vdgfx.print(dB,0);vdgfx.println("dB");

} }

Upgrade -

Documenti correlati