Прошу помощи в исправлении скетча
- Войдите на сайт для отправки комментариев
Ср, 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
[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]поправить "ЭТО" будет дороже, чем написать заново
Написать заново - от 1500 руб
ded собака cur-ex.ru
Р е а л и з у е м о - maslachenko767@mail.ru , консультации, подбор компонентов бесплатно, гарантии
Можно телефон для контактов?
Пишы
Перепишу за 1500р
kakmycmail@gmail.com
Сделаю за 1000р. Обращайтесь: petrovskyi.rv@gmail.com