Проверить код, выдаёт ошибку по оформлению #include
#include

#include

#include
#include
#include
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
#define Mic A1
#define LED 8
int val;
char state = 0;
int pin = 6;
#include
#include
#include
#include
Servo servo;
#include

MenuSystem ms;
Menu mm("menu");
MenuItem mm_mi1("ABOUT");
Menu mu2("Sensors");
MenuItem mu2_mi1("temperature");
MenuItem mu2_mi2("humidi");
MenuItem mu2_mi3("pocva");
MenuItem mu2_mi4("wolue");

Menu mu3("seting");
MenuItem mu3_mi2("Servo");
LiquidCrystal_I2C lcd(0x3F, 16, 2);
#define dht_apin A0
dht DHT;
void on_item1_selected(MenuItem * p_menu_item)
{

lcd.setCursor(0, 1);
lcd.print("Item1 Selected ");
delay(1500);
lcd.clear();
DHT.read11(dht_apin);
lcd.print("temperature ");
lcd.print(DHT.temperature);
delay(1500);
}

void on_item2_selected(MenuItem * p_menu_item)
{
lcd.setCursor(0, 1);
lcd.print("Item2 Selected ");
delay(1500);
lcd.clear();
lcd.print(" humidity = ");
lcd.print(DHT.humidity);

lcd.print("% ");
delay(1500);
}
void on_item4_selected(MenuItem * p_menu_item)
{
lcd.setCursor(0, 1);
lcd.print("Item4 Selected ");
delay(1500);
servo.write(180);
delay(5000);
servo.write(0);
delay(1500);
}
void on_item5_selected(MenuItem * p_menu_item)

{
lcd.setCursor(0, 1);
int lectura = digitalRead(pin);
if (lectura == 1) {
lcd.print("Mokro");
} else {
lcd.print("cyxo");

}
delay(1500);

}
void on_item6_selected(MenuItem * p_menu_item)
{
lcd.setCursor(0, 1);
val = analogRead(Mic);
if (val > 100)

{
state = ~state;
digitalWrite(LED, state);

delay(1000);
}
lcd.print("MIC value is");
lcd.print(val);
delay(930);
}
void on_item7_selected(MenuItem * p_menu_item)
{
lcd.setCursor(0, 1);
lcd.print("livenskii vadim");
delay(1500);
}
void setup()
{
Serial.begin(9600);
lcd.begin();
serialPrintHelp();
Serial.println("Setting up the menu.");
// Menu setup
servo.attach(9);
pinMode(7, OUTPUT);
pinMode(pin, INPUT);
pinMode(2, OUTPUT);
mm.add_item(&mm_mi1, &on_item7_selected);
mm.add_menu(&mu2);
mu2.add_item(&mu2_mi1, &on_item1_selected);
mu2.add_item(&mu2_mi2, &on_item2_selected);
mu2.add_item(&mu2_mi3, &on_item5_selected);
mu2.add_item(&mu2_mi4, &on_item6_selected);
mm.add_menu(&mu3);
mu3.add_item(&mu3_mi2, &on_item4_selected);
ms.set_root_menu(&mm);
Serial.println("Menu setted.");
displayMenu();
}
void loop()
{
serialHandler();
}
void displayMenu() {

lcd.clear();
lcd.setCursor(0, 0);
Menu const* cp_menu = ms.get_current_menu();
//lcd.print("Current menu name: ");

lcd.print(cp_menu->get_name());
lcd.setCursor(0, 1);
lcd.print(cp_menu->get_selected()->get_name());
}
void serialHandler() {
char inChar;
if ((inChar = Serial.read()) > 0) {
switch (inChar) {
case 'w':
ms.prev();
displayMenu();
break;
case 's':
ms.next();
displayMenu();
break;
case 'a':
ms.back();
displayMenu();
break;
case 'd':
ms.select();
displayMenu();
break;
case '?':
case 'h':
serialPrintHelp();
break;
default:
break;
}
}
void serialPrintHelp() {
Serial.println("");
Serial.println("w:(up)");
Serial.println("s:(down)");
Serial.println("a:(right)");
Serial.println("d: select");
Serial.println("h: print this help");
Serial.println("");
}

geptor2012 geptor2012    3   07.03.2021 21:47    4

Другие вопросы по теме Информатика