i build an little greenhouse with arduino i build the data recupartionand i need an…
- User
i build an little greenhouse with arduino i build the data recupartionand i need an indicator for lighting with 3 cercle diffrent color for the ligthing your goal is to make a full program with the circle who change with the light and the code i provide to you : //Libraries #include "TFT_eSPI.h" //TFT LCD library #include "DHT.h" // DHT library
//Definitions #define DHTPIN 0 //Define signal pin of DHT sensor // #define DHTPIN PIN_WIRE_SCL //Use I2C port as Digital Port */ #define DHTTYPE DHT11 //Define DHT sensor type
//Initializations DHT dht(DHTPIN, DHTTYPE); //Initializing DHT sensor TFT_eSPI tft; //Initializing TFT LCD TFT_eSprite spr = TFT_eSprite(&tft); //Initializing buffer
//Soil Moisture Sensor definitions int sensorPin = A1; //Define variable to store soil moisture sensor pin int sensorValue = 0; //Define variable to store soil moisture sensor value
void setup() { Serial.begin(9600); //Start serial communication
pinMode(WIO_LIGHT, INPUT); //Set light sensor pin as INPUT pinMode(WIO_BUZZER, OUTPUT); //Set buzzer pin as OUTPUT
dht.begin(); //Start DHT sensor tft.begin(); //Start TFT LCD tft.setRotation(3); //Set TFT LCD rotation spr.createSprite(TFT_HEIGHT,TFT_WIDTH); //Create buffer }
void loop() { int t = dht.readTemperature(); //Assign variable to store temperature int h = dht.readHumidity(); //Assign variable to store humidity int light = analogRead(WIO_LIGHT); //Assign variable to store light sensor values
//titre spr.fillSprite(TFT_WHITE); spr.fillRect(0,0,320,50,TFT_BLUE); spr.setTextColor(TFT_WHITE); spr.setTextSize(3); spr.drawString("biotechnicaca",50,15);
/*lignes spr.drawFastVLine(160,50,190,TFT_BLUE); spr.drawFastHLine(0,140,320,TFT_BLUE); */ // temperature spr.setTextColor(TFT_BLACK);
//thermometre
/**/ if(dht.readTemperature() < 15){ spr.fillRect(14,160,4,65,TFT_BLUE); } else if (dht.readTemperature() > 15 && dht.readTemperature()<18){ spr.fillRect(14,130,4,95,TFT_BLUE); } else if (dht.readTemperature() > 18 && dht.readTemperature()<21){ spr.fillRect(14,100,4,125,TFT_RED); } else if (dht.readTemperature() > 21 && dht.readTemperature()<24){ spr.fillRect(14,70,4,155,TFT_RED); } else if (dht.readTemperature() > 24){ spr.fillRect(14,40,4,185,TFT_RED); analogWrite(WIO_BUZZER, 10); //beep the buzzer delay(100); analogWrite(WIO_BUZZER, 0); //Silence the buzzer delay(100); }
spr.fillCircle(16,220,6,TFT_RED);
spr.setTextSize(2);
spr.setTextSize(2); spr.drawNumber(t,30,210); //Display temperature values spr.drawString("C",55,210);
/humiditee spr.setTextSize(2); spr.drawString("Humidity",35,40); spr.setTextSize(3); spr.drawNumber(h,45,190); //Display humidity values spr.drawString("%RH",70,190);/
//soil moisture sensorValue = analogRead(sensorPin); //Store sensor values sensorValue = map(sensorValue,1023,400,0,100); //Map sensor values spr.setTextSize(2); spr.drawString("Soil Moisture",162,65); spr.setTextSize(3); spr.drawNumber(sensorValue,200,95); //Display sensor values as percentage spr.drawString("%",260,95);
- Assistant
- User
show me the full patch code
- Assistant