Прошу помощи в исправлении скетча

Gruf
Offline
Зарегистрирован: 06.03.2019
Доброе утро! 
Данный скетч управляет двумя нагрузками по таймеру в режиме цикличности!
Проблема в том, что когда нажимаешь старт программа запускается, но при нажатии на стоп не реагирует на команду
Что не так?
 
[code]
 
 
#include <Switch.h>
 
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <EEPROM.h> // подключаем библиотеку EEPROM
 
 
LiquidCrystal_I2C lcd(0x27,20,4);  // set the LCD address to 0x27 for a 16 chars and 2 line display
 
const byte buttonLEFTpin = A2; // (left button)
const byte buttonRIGHTpin = A3; // (rightt button)
const byte buttonSTARTpin = A1; // (start button)
const byte buttonSTOPpin = A0; // (start button)
const int outPin =  10; // heating controll
const int outPin2 =  11; // magnet controll
int smallNum;
int t;
int s;
int min;
int max;
bool ls = false;
bool rs = false;
bool buttonSTOPpushed = false;
Switch buttonLEFT = Switch(buttonLEFTpin); // button to GND, use internal 20K pullup resistor
Switch buttonRIGHT = Switch(buttonRIGHTpin); // button to GND, use internal 20K pullup resistor
Switch buttonSTART = Switch(buttonSTARTpin); // button to GND, use internal 20K pullup resistor
Switch buttonSTOP = Switch(buttonSTOPpin); // button to GND, use internal 20K pullup resistor
 
 
//Switch toggleSwitch = Switch(toggleSwitchpin);
//Switch buttonVCC = Switch(ButtonVCCpin, INPUT, HIGH); // button to VCC, 10k pull-down resistor, no internal pull-up resistor, HIGH polarity
//Switch button10ms = Switch(Button10mspin, INPUT_PULLUP, LOW, 1); // debounceTime 1ms
 
void setup()
{
 lcd.init();                      // initialize the lcd 
 lcd.backlight();
  
pinMode(outPin, OUTPUT); // initialize the OUTPUT pin as an output:
digitalWrite(outPin, LOW);
 
s = 50;
min = 1000;
max = 12750;
smallNum = EEPROM.read(0); t =  smallNum * 50;
}
 
void loop()
{
 buttonLEFT.poll();
 buttonRIGHT.poll();
 buttonSTART.poll();
 buttonSTOP.poll();
 
 if(buttonLEFT.pushed())  {    t = t - s;   if(t <= min) t = min;   } 
 if(buttonLEFT.longPress()) ls = true;
 if(buttonLEFT.released())  ls = false;
 
 if(buttonRIGHT.pushed())  {    t = t + s;   if(t >= max) t = max;  } 
 if(buttonRIGHT.longPress()) rs = true;
 if(buttonRIGHT.released())  rs = false;
  
  if(ls == true) {t = t - s;  if(t <= min) t = min;   delay(20);lcd.setCursor(9,0); lcd.print("     ");} 
  if(rs == true) {t = t + s;  if(t >= max) t = max;   delay(20);lcd.setCursor(9,0); lcd.print("     ");} 
 
 
lcd.setCursor(0,0); lcd.print("Time"); lcd.setCursor(9,0); lcd.print(t);lcd.setCursor(14,0); lcd.print("ms"); EEPROM.write(0, t/50);
 
 if(buttonSTART.pushed()) {
 
  do
{
  if(buttonSTOP.pushed() or buttonSTOP.longPress()) buttonSTOPpushed = true;
  lcd.setCursor(4,1); lcd.print("Induction");  digitalWrite(outPin, HIGH);delay(t);digitalWrite(outPin, LOW); lcd.clear(); lcd.print("Extraction"); digitalWrite(outPin2, HIGH);delay(600);digitalWrite(outPin2, LOW);lcd.clear();delay(4000);
  if(buttonSTOP.pushed() or buttonSTOP.longPress()) buttonSTOPpushed = true;
  } while (buttonSTOPpushed == false);
  buttonSTOPpushed = false;
  }
  
}
 
 
 
 
[/code]

 

andycat
andycat аватар
Offline
Зарегистрирован: 07.09.2017

не правильно вставлен код

Gas311
Gas311 аватар
Offline
Зарегистрирован: 06.12.2018

 Помочь? gas31a@mail.ru

Gruf
Offline
Зарегистрирован: 06.03.2019
01[code]
02 
03 
04#include <Switch.h>
05 
06#include <Wire.h>
07#include <LiquidCrystal_I2C.h>
08#include <EEPROM.h> // подключаем библиотеку EEPROM
09 
10 
11LiquidCrystal_I2C lcd(0x27,20,4);  // set the LCD address to 0x27 for a 16 chars and 2 line display
12 
13const byte buttonLEFTpin = A2; // (left button)
14const byte buttonRIGHTpin = A3; // (rightt button)
15const byte buttonSTARTpin = A1; // (start button)
16const byte buttonSTOPpin = A0; // (start button)
17const int outPin =  10; // heating controll
18const int outPin2 =  11; // magnet controll
19int smallNum;
20int t;
21int s;
22int min;
23int max;
24bool ls = false;
25bool rs = false;
26bool buttonSTOPpushed = false;
27Switch buttonLEFT = Switch(buttonLEFTpin); // button to GND, use internal 20K pullup resistor
28Switch buttonRIGHT = Switch(buttonRIGHTpin); // button to GND, use internal 20K pullup resistor
29Switch buttonSTART = Switch(buttonSTARTpin); // button to GND, use internal 20K pullup resistor
30Switch buttonSTOP = Switch(buttonSTOPpin); // button to GND, use internal 20K pullup resistor
31 
32 
33//Switch toggleSwitch = Switch(toggleSwitchpin);
34//Switch buttonVCC = Switch(ButtonVCCpin, INPUT, HIGH); // button to VCC, 10k pull-down resistor, no internal pull-up resistor, HIGH polarity
35//Switch button10ms = Switch(Button10mspin, INPUT_PULLUP, LOW, 1); // debounceTime 1ms
36 
37void setup()
38{
39 lcd.init();                      // initialize the lcd
40 lcd.backlight();
41   
42pinMode(outPin, OUTPUT); // initialize the OUTPUT pin as an output:
43digitalWrite(outPin, LOW);
44 
45s = 50;
46min = 1000;
47max = 12750;
48smallNum = EEPROM.read(0); t =  smallNum * 50;
49}
50 
51void loop()
52{
53 buttonLEFT.poll();
54 buttonRIGHT.poll();
55 buttonSTART.poll();
56 buttonSTOP.poll();
57 
58 if(buttonLEFT.pushed())  {    t = t - s;   if(t <= min) t = min;   }
59 if(buttonLEFT.longPress()) ls = true;
60 if(buttonLEFT.released())  ls = false;
61 
62 if(buttonRIGHT.pushed())  {    t = t + s;   if(t >= max) t = max;  }
63 if(buttonRIGHT.longPress()) rs = true;
64 if(buttonRIGHT.released())  rs = false;
65   
66  if(ls == true) {t = t - s;  if(t <= min) t = min;   delay(20);lcd.setCursor(9,0); lcd.print("     ");}
67  if(rs == true) {t = t + s;  if(t >= max) t = max;   delay(20);lcd.setCursor(9,0); lcd.print("     ");}
68 
69 
70lcd.setCursor(0,0); lcd.print("Time"); lcd.setCursor(9,0); lcd.print(t);lcd.setCursor(14,0); lcd.print("ms"); EEPROM.write(0, t/50);
71 
72 if(buttonSTART.pushed()) {
73 
74  do
75{
76  if(buttonSTOP.pushed() or buttonSTOP.longPress()) buttonSTOPpushed = true;
77  lcd.setCursor(4,1); lcd.print("Induction");  digitalWrite(outPin, HIGH);delay(t);digitalWrite(outPin, LOW); lcd.clear(); lcd.print("Extraction"); digitalWrite(outPin2, HIGH);delay(600);digitalWrite(outPin2, LOW);lcd.clear();delay(4000);
78  if(buttonSTOP.pushed() or buttonSTOP.longPress()) buttonSTOPpushed = true;
79  } while (buttonSTOPpushed == false);
80  buttonSTOPpushed = false;
81  }
82   
83}
84 
85 
86 
87 
88[/code]

 

b707
Offline
Зарегистрирован: 26.05.2017

поправить "ЭТО" будет дороже, чем написать заново

Написать заново - от 1500 руб

ded собака cur-ex.ru

karamzin01
Offline
Зарегистрирован: 08.03.2018

Р е а л и з у е м о - maslachenko767@mail.ru , консультации, подбор компонентов бесплатно, гарантии

Gruf
Offline
Зарегистрирован: 06.03.2019

karamzin01 пишет:
Р е а л и з у е м о - maslachenko767@mail.ru , консультации, подбор компонентов бесплатно, гарантии

Можно телефон для контактов?

DetSimen
DetSimen аватар
Offline
Зарегистрирован: 25.01.2017

Пишы 

Kakmyc
Offline
Зарегистрирован: 15.01.2018

Перепишу за 1500р
kakmycmail@gmail.com

Roman1984
Offline
Зарегистрирован: 17.02.2017

Сделаю за 1000р. Обращайтесь: petrovskyi.rv@gmail.com