Прошу помощи в исправлении скетча
- Войдите на сайт для отправки комментариев
Ср, 06/03/2019 - 12:54
Доброе утро!
Данный скетч управляет двумя нагрузками по таймеру в режиме цикличности!
Проблема в том, что когда нажимаешь старт программа запускается, но при нажатии на стоп не реагирует на команду
Что не так?
[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]
не правильно вставлен код
Помочь? gas31a@mail.ru
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
11
LiquidCrystal_I2C lcd(0x27,20,4);
// set the LCD address to 0x27 for a 16 chars and 2 line display
12
13
const
byte
buttonLEFTpin = A2;
// (left button)
14
const
byte
buttonRIGHTpin = A3;
// (rightt button)
15
const
byte
buttonSTARTpin = A1;
// (start button)
16
const
byte
buttonSTOPpin = A0;
// (start button)
17
const
int
outPin = 10;
// heating controll
18
const
int
outPin2 = 11;
// magnet controll
19
int
smallNum;
20
int
t;
21
int
s;
22
int
min;
23
int
max;
24
bool
ls =
false
;
25
bool
rs =
false
;
26
bool
buttonSTOPpushed =
false
;
27
Switch buttonLEFT = Switch(buttonLEFTpin);
// button to GND, use internal 20K pullup resistor
28
Switch buttonRIGHT = Switch(buttonRIGHTpin);
// button to GND, use internal 20K pullup resistor
29
Switch buttonSTART = Switch(buttonSTARTpin);
// button to GND, use internal 20K pullup resistor
30
Switch 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
37
void
setup
()
38
{
39
lcd.init();
// initialize the lcd
40
lcd.backlight();
41
42
pinMode(outPin, OUTPUT);
// initialize the OUTPUT pin as an output:
43
digitalWrite(outPin, LOW);
44
45
s = 50;
46
min = 1000;
47
max = 12750;
48
smallNum = EEPROM.read(0); t = smallNum * 50;
49
}
50
51
void
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
70
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);
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]
поправить "ЭТО" будет дороже, чем написать заново
Написать заново - от 1500 руб
ded собака cur-ex.ru
Р е а л и з у е м о - maslachenko767@mail.ru , консультации, подбор компонентов бесплатно, гарантии
Можно телефон для контактов?
Пишы
Перепишу за 1500р
kakmycmail@gmail.com
Сделаю за 1000р. Обращайтесь: petrovskyi.rv@gmail.com