G
G
golovanoff232019-05-30 15:18:05
Arduino
golovanoff23, 2019-05-30 15:18:05

Combining several sketches into one, how to do it?

I assemble a smart hive device, no ready-made code, you need to connect a humidity sensor, a gsm module 800c, and a vibration sensor. Temperature and humidity should be transmitted to the monitor screen and via SMS using the gsm module, if the hive falls or comes under physical contact, too SMS notification should come. Please help.
sketch for a humidity sensor with a dht 11 display
Displaying humidity and temperature values
​​on the LCD 1602 I2C from a DHT11 or DHT22 sensor
*/
// connecting libraries
#include
#include
#include "DHT.h"
// assigning a PIN and selecting the type of DHT sensor
#define DHTPIN 2 //
// uncomment the desired line
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22 (AM2302)
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
DHTdht(DHTPIN,DHTTYPE); // DHT sensor initialization
LiquidCrystal_I2Clcd(0x27,16,2);// Display initialization
bytesymb_grad[8]=// Degree symbol encoding
{
B00111,
B00101,
B00111,
B00000,
B00000,
B00000,
B00000,
};
voidsetup()
{
lcd.init();// lcd initialization
lcd.createChar(1,symb_grad);// register custom symbol with code 1
Serial.begin(9600); // start data transfer
dht.begin();// start DHT sensor
}
voidloop()
{
// add 2 second pauses between measurements
delay(2000);
floath=dht.readHumidity(); // read humidity
floatt=dht.readTemperature(); // reading temperature
// Printing humidity and temperature
readings lcd.clear();// clearing the screen
lcd.setCursor(0,0);// setting the cursor to the beginning of line 1
lcd.print("Humidity: %");/ / text output
lcd.setCursor(10,0);// setting the cursor to the 10th position
lcd.print(h,1);// displaying the humidity value on the screen
lcd.setCursor(0,1);// setting the cursor to the beginning 2 lines
lcd.print("Temperat: C");// print text
lcd.setCursor(14,1);// set cursor to position 14
lcd.print("\1"); // print degree symbol
lcd.setCursor(10,1);// Set cursor to position 10 lcd.print (
t,1);// Display temperature value / Pin to which the vibration sensor is attached void setup() { pinMode(PIN_LED, OUTPUT); } void loop() { int val = digitalRead(PIN_SENSOR); // Read the value from the sensor if(val==1){ digitalWrite(PIN_LED, HIGH); // Sensor triggered - turn on the LED }else{ digitalWrite(PIN_LED, LOW); } }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vanyamba-electronics, 2019-05-31
@vanyamba-electronics

Write a state machine.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question