#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define HAUPT_MENU_CNT 3
#define UNTER_MENU1_CNT 4
#define UNTER_MENU2_CNT 2
#define UNTER_MENU3_CNT 3
#define UNTER_MENU11_CNT 3
#define UNTER_MENU12_CNT 3
#define UNTER_MENU13_CNT 3
#define UNTER_MENU14_CNT 3
#define UNTER_MENU111_CNT 1
#define UNTER_MENU112_CNT 1
#define UNTER_MENU113_CNT 1
#define UNTER_MENU121_CNT 1
#define UNTER_MENU122_CNT 1
#define UNTER_MENU123_CNT 1
#define UNTER_MENU131_CNT 1
#define UNTER_MENU132_CNT 1
#define UNTER_MENU133_CNT 1
#define UNTER_MENU141_CNT 1
#define UNTER_MENU142_CNT 1
#define UNTER_MENU143_CNT 1
#define UNTER_MENU21_CNT 1
#define UNTER_MENU22_CNT 1
LiquidCrystal_I2C lcd(0x27, 20, 4); // Adresse, Spalten, Zeilen
int P_FET_Q1 = 2;
int N_FET_Q4 = 3;
int P_FET_Q3 = 8;
int N_FET_Q2 = 9;
unsigned long startTime;
const unsigned long countdownDuration = 120000;
const float COUNTDOWN_INCREMENT = 30000;
unsigned long remainingTime;
//heizstab
int heatingPin = 7;
int dutyCycle = 0; // initial duty cycle set to 50%
bool biegen = false;
bool heatingEnabled = false; // Flag für Heizung Ein/Aus
//winkel sensor
int sensor = A3;
float winkel = 0;
int x;
//temperatur
int temperature = 0;
const int PT1000_PIN = A9;
const float vt_factor = 1.85;
const float offset = -25.7;
int temp_c;
// setup the emum with all the menu seites options
enum seiteType {HAUPT_MENU, UNTER_MENU1, UNTER_MENU2, UNTER_MENU3, UNTER_MENU11, UNTER_MENU12, UNTER_MENU13, UNTER_MENU14, UNTER_MENU111, UNTER_MENU112, UNTER_MENU113, UNTER_MENU121, UNTER_MENU122, UNTER_MENU123, UNTER_MENU131, UNTER_MENU132, UNTER_MENU133, UNTER_MENU141, UNTER_MENU142, UNTER_MENU143, UNTER_MENU21, UNTER_MENU22};
// holds which seite is aktuellently selected
enum seiteType aktuellseite = HAUPT_MENU;
// selected item pointer for the HAUPT menu
uint8_t HAUPT_Pos = 1;
// constants holding port addresses
const int BTN_ACCEPT = 10;
const int BTN_UP = A2;
const int BTN_DOWN = A1;
const int BTN_CANCEL = 6;
const int BUZZER = 11;
// =======================================================================================
// || SETUP ||
// =======================================================================================
void setup() {
// init the serial port to be used as a display return
lcd.init(); // initialize the lcd
lcd.init();
lcd.backlight();
// setup the basic I/O's
pinMode(BTN_ACCEPT, INPUT_PULLUP);
pinMode(BTN_UP, INPUT_PULLUP);
pinMode(BTN_DOWN, INPUT_PULLUP);
pinMode(BTN_CANCEL, INPUT_PULLUP);
pinMode(BUZZER, OUTPUT);
pinMode(P_FET_Q1, OUTPUT);
pinMode(N_FET_Q2, OUTPUT);
pinMode(P_FET_Q3, OUTPUT);
pinMode(N_FET_Q4, OUTPUT);
pinMode(heatingPin, OUTPUT);
}
// =======================================================================================
// || MAIN LOOP ||
// =======================================================================================
void loop() {
switch (aktuellseite){
case HAUPT_MENU: seite_HAUPTMenu(); break;
case UNTER_MENU1: seite_UNTERMenu1(); break;
case UNTER_MENU2: seite_UNTERMenu2(); break;
case UNTER_MENU3: seite_UNTERMenu3(); break;
case UNTER_MENU11: seite_UNTERMenu11(); break;
case UNTER_MENU12: seite_UNTERMenu12(); break;
case UNTER_MENU13: seite_UNTERMenu13(); break;
case UNTER_MENU14: seite_UNTERMenu14(); break;
case UNTER_MENU111: seite_UNTERMenu111(); break;
case UNTER_MENU112: seite_UNTERMenu112(); break;
case UNTER_MENU113: seite_UNTERMenu113(); break;
case UNTER_MENU121: seite_UNTERMenu121(); break;
case UNTER_MENU122: seite_UNTERMenu122(); break;
case UNTER_MENU123: seite_UNTERMenu123(); break;
case UNTER_MENU131: seite_UNTERMenu131(); break;
case UNTER_MENU132: seite_UNTERMenu132(); break;
case UNTER_MENU133: seite_UNTERMenu133(); break;
case UNTER_MENU21: seite_UNTERMenu21(); break;
case UNTER_MENU22: seite_UNTERMenu22(); break;
}
}
// =======================================================================================
// || seite - HAUPT MENU ||
// =======================================================================================
void seite_HAUPTMenu(void) {
//flag for updating the display
boolean updateDisplay = true;
// tracks when entered top of loop
uint32_t loopStartMs;
//tracks button states
boolean btn_Up_WasDown = false;
boolean btn_Down_WasDown = false;
boolean btn_Accept_WasDown = false;
//inner loop
while (true){
// capture start time
loopStartMs = millis();
// print the display
if (updateDisplay){
// clear the update flag
updateDisplay = false;
//clear the display
clearScreen();
// print the items
lcd.setCursor(5,0);lcd.print(F("Haupt-Menu"));
lcd.setCursor(0,1);printSelected(1, HAUPT_Pos); lcd.setCursor(1,1);lcd.print(F("Start"));
lcd.setCursor(0,2);printSelected(2, HAUPT_Pos); lcd.setCursor(1,2); lcd.print(F("Einstellungen"));
lcd.setCursor(0,3);printSelected(3, HAUPT_Pos); lcd.setCursor(1,3);lcd.print(F("Info"));
lcd.print("");
lcd.print("");
//print a divider line
}
// capture the button down states
if (btnIsDown(BTN_UP)) { delay(200);btn_Up_WasDown = true;delay(100);}
if (btnIsDown(BTN_DOWN)) { delay(200);btn_Down_WasDown = true;delay(100);}
if (btnIsDown(BTN_ACCEPT)) { btn_Accept_WasDown = true;}
//move the pointer down
if (btn_Down_WasDown && btnIsUp(BTN_DOWN)){
if (HAUPT_Pos == HAUPT_MENU_CNT) {HAUPT_Pos = 1;} else {HAUPT_Pos++;}
updateDisplay = true;
btn_Down_WasDown = false;
}
//move the pointer Up
if (btn_Up_WasDown && btnIsUp(BTN_UP)){
if (HAUPT_Pos == 1) {HAUPT_Pos = HAUPT_MENU_CNT;} else {HAUPT_Pos--;}
updateDisplay = true;
btn_Up_WasDown = false;
}
//move to the selected seite
if (btn_Accept_WasDown && btnIsUp(BTN_ACCEPT)){
digitalWrite(BUZZER, 0);
delay(100);
digitalWrite(BUZZER, 1);
switch (HAUPT_Pos) {
case 1: aktuellseite = UNTER_MENU1; return;
case 2: aktuellseite = UNTER_MENU2; return;
case 3: aktuellseite = UNTER_MENU3; return;
}
}
else{
digitalWrite(BUZZER, 1); // For every other condition make buzzer off
}
// keep a specific pace
while (millis() - loopStartMs < 25) {delay(2);}
}
}
// =======================================================================================
// || seite - UNTER MENU1 ||
// =======================================================================================
void seite_UNTERMenu1(void) {
//flag for updating the display
boolean updateDisplay = true;
// tracks when entered top of loop
uint32_t loopStartMs;
//tracks button states
boolean btn_Up_WasDown = false;
boolean btn_Down_WasDown = false;
boolean btn_Cancel_WasDown = false;
boolean btn_Accept_WasDown = false;
// selected item pointer
uint8_t UNTER_Pos = 1;
//inner loop
while (true){
// capture start time
loopStartMs = millis();
// print the display
if (updateDisplay){
// clear the update flag
updateDisplay = false;
//clear the display
clearScreen();
//menu title
//print a divider line
// print the items
lcd.setCursor(0,0);printSelected(1, UNTER_Pos); lcd.setCursor(1,0);lcd.print(F("Acryl-PMMA"));
lcd.setCursor(0,1);printSelected(2, UNTER_Pos); lcd.setCursor(1,1);lcd.print(F("PC"));
lcd.setCursor(0,2);printSelected(3, UNTER_Pos); lcd.setCursor(1,2);lcd.print(F("PVC"));
lcd.setCursor(0,3);printSelected(4, UNTER_Pos); lcd.setCursor(1,3);lcd.print(F("PE / PP"));
//print a divider line
}
// capture the button down states
if (btnIsDown(BTN_UP)) {delay(200);btn_Up_WasDown = true;delay(100);}
if (btnIsDown(BTN_DOWN)) { delay(200);btn_Down_WasDown = true;delay(100);}
if (btnIsDown(BTN_CANCEL)) { btn_Cancel_WasDown = true;}
if (btnIsDown(BTN_ACCEPT)) { btn_Accept_WasDown = true;}
//move the pointer down
if (btn_Down_WasDown && btnIsUp(BTN_DOWN)){
if (UNTER_Pos == UNTER_MENU1_CNT) {UNTER_Pos = 1;} else {UNTER_Pos++;}
updateDisplay = true;
btn_Down_WasDown = false;
}
//move the pointer Up
if (btn_Up_WasDown && btnIsUp(BTN_UP)){
if (UNTER_Pos == 1) {UNTER_Pos = UNTER_MENU1_CNT;} else {UNTER_Pos--;}
updateDisplay = true;
btn_Up_WasDown = false;
}
//move to the go to the HAUPT menu
if (btn_Cancel_WasDown && btnIsUp(BTN_CANCEL)){
digitalWrite(BUZZER, 0);
delay(100);
digitalWrite(BUZZER, 1);
aktuellseite = HAUPT_MENU;
return;
}
else{
digitalWrite(BUZZER, 1); // For every other condition make buzzer off
}
//move to the selected seite
if (btn_Accept_WasDown && btnIsUp(BTN_ACCEPT)){
digitalWrite(BUZZER, 0);
delay(100);
digitalWrite(BUZZER, 1);
switch (UNTER_Pos) {
case 1: aktuellseite = UNTER_MENU11; return;
case 2: aktuellseite = UNTER_MENU12; return;
case 3: aktuellseite = UNTER_MENU13; return;
case 4: aktuellseite = UNTER_MENU14; return;
}
}
else{
digitalWrite(BUZZER, 1); // For every other condition make buzzer off
}
// keep a specific pace
while (millis() - loopStartMs < 25) {delay(2);}
}
}
// =======================================================================================
// || seite - UNTER MENU11 ||
// =======================================================================================
float countera = 0;
int countera1 = 45;
void seite_UNTERMenu11(void) {
//flag for updating the display
boolean updateDisplay = true;
// tracks when entered top of loop
uint32_t loopStartMs;
//tracks button states
boolean btn_Up_WasDown = false;
boolean btn_Down_WasDown = false;
boolean btn_Cancel_WasDown = false;
boolean btn_Accept_WasDown = false;
// selected item pointer
uint8_t UNTER_Pos1 = 1;
//inner loop
while (true){
// capture start time
loopStartMs = millis();
// print the display
if (updateDisplay){
// clear the update flag
updateDisplay = false;
//clear the display
clearScreen();
//menu title
//print a divider line
// print the items
lcd.setCursor(5,0);lcd.print(F("Acryl PMMA"));
lcd.setCursor(0,1);printSelected(1, UNTER_Pos1); lcd.setCursor(1,1);lcd.print(F("St\341rke")); lcd.setCursor(14,1); lcd.print(countera);lcd.setCursor(18,1); lcd.print("mm");
lcd.setCursor(0,2);printSelected(2, UNTER_Pos1); lcd.setCursor(1,2);lcd.print(F("Winkel")); lcd.setCursor(17,2); lcd.print(countera1);lcd.setCursor(19,2); lcd.print("\337");
lcd.setCursor(0,3);printSelected(3, UNTER_Pos1); lcd.setCursor(8,3);lcd.print(F("LOS!"));
//print a divider line
}
// capture the button down states
if (btnIsDown(BTN_UP)) { delay(200);btn_Up_WasDown = true;delay(100);}
if (btnIsDown(BTN_DOWN)) { delay(200);btn_Down_WasDown = true;delay(100);}
if (btnIsDown(BTN_CANCEL)) { btn_Cancel_WasDown = true;}
if (btnIsDown(BTN_ACCEPT)) { btn_Accept_WasDown = true;}
//move the pointer down
if (btn_Down_WasDown && btnIsUp(BTN_DOWN)){
if (UNTER_Pos1 == UNTER_MENU11_CNT) {UNTER_Pos1 = 1;} else {UNTER_Pos1++;}
updateDisplay = true;
btn_Down_WasDown = false;
}
//move the pointer Up
if (btn_Up_WasDown && btnIsUp(BTN_UP)){
if (UNTER_Pos1 == 1) {UNTER_Pos1 = UNTER_MENU11_CNT;} else {UNTER_Pos1--;}
updateDisplay = true;
btn_Up_WasDown = false;
}
//move to the go to the HAUPT menu
if (btn_Cancel_WasDown && btnIsUp(BTN_CANCEL)){
digitalWrite(BUZZER, 0);
delay(100);
digitalWrite(BUZZER, 1);
aktuellseite = UNTER_MENU1;
return;
}
else{
digitalWrite(BUZZER, 1); // For every other condition make buzzer off
}
if (btn_Accept_WasDown && btnIsUp(BTN_ACCEPT)){
digitalWrite(BUZZER, 0);
delay(100);
digitalWrite(BUZZER, 1);
switch (UNTER_Pos1) {
case 1: aktuellseite = UNTER_MENU111; return;
case 2: aktuellseite = UNTER_MENU112; return;
case 3: aktuellseite = UNTER_MENU113; return;
case 4: aktuellseite = UNTER_MENU11; return;
}
}
else{
digitalWrite(BUZZER, 1); // For every other condition make buzzer off
}
// keep a specific pace
while (millis() - loopStartMs < 25) {delay(2);}
}
}
// =======================================================================================
// || seite - UNTER MENU111 ||
// =======================================================================================
void seite_UNTERMenu111(void) {
//flag for updating the display
boolean updateDisplay = true;
// tracks when entered top of loop
uint32_t loopStartMs;
//tracks button states
boolean btn_Up_WasDown = false;
boolean btn_Down_WasDown = false;
boolean btn_Cancel_WasDown = false;
boolean btn_Accept_WasDown = false;
// selected item pointer
uint8_t UNTER_Pos = 1;
//inner loop
while (true){
// capture start time
loopStartMs = millis();
// print the display
if (updateDisplay){
// clear the update flag
updateDisplay = false;
//clear the display
clearScreen();
//menu title
//print a divider line
// print the items
lcd.setCursor(5,0);lcd.print(F("Acryl PMMA"));
lcd.setCursor(0,1);printSelected(1, UNTER_Pos); lcd.setCursor(1,1);lcd.print(F("St\341rke<")); lcd.setCursor(14,1); lcd.print(countera);lcd.setCursor(18,1); lcd.print("mm");
lcd.setCursor(0,2);printSelected(2, UNTER_Pos); lcd.setCursor(1,2);lcd.print(F("Winkel")); lcd.setCursor(17,2); lcd.print(countera1);lcd.setCursor(19,2); lcd.print("\337");
lcd.setCursor(0,3);printSelected(3, UNTER_Pos); lcd.setCursor(8,3);lcd.print(F("LOS!"));
//print a divider line
}
// capture the button down states
if (btnIsDown(BTN_UP)) { delay(200);btn_Up_WasDown = true;delay(100);}
if (btnIsDown(BTN_DOWN)) { delay(200);btn_Down_WasDown = true;delay(100);}
if (btnIsDown(BTN_CANCEL)) { btn_Cancel_WasDown = true;}
if (btnIsDown(BTN_ACCEPT)) { btn_Accept_WasDown = true;}
//move the pointer down
if (btn_Down_WasDown && btnIsUp(BTN_DOWN)){
countera= countera +0.5;
updateDisplay = true;
btn_Down_WasDown = false;
}
//move the pointer Up
if (btn_Up_WasDown && btnIsUp(BTN_UP)){
countera= countera - 0.5;
updateDisplay = true;
btn_Up_WasDown = false;
}
//move to the go to the HAUPT menu
if (btn_Cancel_WasDown && btnIsUp(BTN_CANCEL)){
digitalWrite(BUZZER, 0);
delay(100);
digitalWrite(BUZZER, 1);
aktuellseite = UNTER_MENU11;
return;
}
else{
digitalWrite(BUZZER, 1); // For every other condition make buzzer off
}
if (btn_Accept_WasDown && btnIsUp(BTN_ACCEPT)){
digitalWrite(BUZZER, 0);
delay(100);
digitalWrite(BUZZER, 1);
aktuellseite = UNTER_MENU11;
return;
}
else{
digitalWrite(BUZZER, 1); // For every other condition make buzzer off
}
// keep a specific pace
while (millis() - loopStartMs < 25) {delay(2);}
}
}
// =======================================================================================
// || seite - UNTER MENU112 ||
// =======================================================================================
void seite_UNTERMenu112(void) {
//flag for updating the display
boolean updateDisplay = true;
// tracks when entered top of loop
uint32_t loopStartMs;
//tracks button states
boolean btn_Up_WasDown = false;
boolean btn_Down_WasDown = false;
boolean btn_Cancel_WasDown = false;
boolean btn_Accept_WasDown = false;
// selected item pointer
uint8_t UNTER_Pos = 1;
//inner loop
while (true){
// capture start time
loopStartMs = millis();
// print the display
if (updateDisplay){
// clear the update flag
updateDisplay = false;
//clear the display
clearScreen();
//menu title
//print a divider line
// print the items
lcd.setCursor(5,0);lcd.print(F("Acryl PMMA"));
lcd.setCursor(0,1); lcd.setCursor(1,1);lcd.print(F("St\341rke")); lcd.setCursor(14,1); lcd.print(countera);lcd.setCursor(18,1); lcd.print("mm");
lcd.setCursor(0,2);printSelected(1, UNTER_Pos); lcd.setCursor(1,2);lcd.print(F("Winkel<")); lcd.setCursor(17,2); lcd.print(countera1);lcd.setCursor(19,2); lcd.print("\337");
lcd.setCursor(0,3); lcd.setCursor(8,3);lcd.print(F("LOS!"));
//print a divider line
}
// capture the button down states
if (btnIsDown(BTN_UP)) { delay(50);btn_Up_WasDown = true;delay(50);}
if (btnIsDown(BTN_DOWN)) { delay(50);btn_Down_WasDown = true;delay(50);}
if (btnIsDown(BTN_CANCEL)) { btn_Cancel_WasDown = true;}
if (btnIsDown(BTN_ACCEPT)) { btn_Accept_WasDown = true;}
//move the pointer down
if (btn_Down_WasDown && btnIsUp(BTN_DOWN)){
countera1= countera1 +1;
updateDisplay = true;
btn_Down_WasDown = false;
}
//move the pointer Up
if (btn_Up_WasDown && btnIsUp(BTN_UP)){
countera1= countera1 - 1;
updateDisplay = true;
btn_Up_WasDown = false;
}
//move to the go to the HAUPT menu
if (btn_Cancel_WasDown && btnIsUp(BTN_CANCEL)){
digitalWrite(BUZZER, 0);
delay(100);
digitalWrite(BUZZER, 1);
aktuellseite = UNTER_MENU11;
return;
}
else{
digitalWrite(BUZZER, 1); // For every other condition make buzzer off
}
if (btn_Accept_WasDown && btnIsUp(BTN_ACCEPT)){
digitalWrite(BUZZER, 0);
delay(100);
digitalWrite(BUZZER, 1);
aktuellseite = UNTER_MENU11;
return;
}
else{
digitalWrite(BUZZER, 1); // For every other condition make buzzer off
}
// keep a specific pace
while (millis() - loopStartMs < 25) {delay(2);}
}
}
// =======================================================================================
// || seite - UNTER MENU113 ||
// =======================================================================================
void seite_UNTERMenu113(void) {
//flag for updating the display
boolean updateDisplay = true;
// tracks when entered top of loop
uint32_t loopStartMs;
//tracks button states
boolean btn_Up_WasDown = false;
boolean btn_Down_WasDown = false;
boolean btn_Cancel_WasDown = false;
boolean btn_Accept_WasDown = false;
boolean taster = false;
// selected item pointer
uint8_t UNTER_Pos = 1;
//inner loop
while (true){
// capture start time
loopStartMs = millis();
// print the display
if (updateDisplay){
// clear the update flag
updateDisplay = false;
//clear the display
clearScreen();
//SOLL DATEN
if (btnIsDown(BTN_ACCEPT)) { btn_Accept_WasDown = true;}
int sensorvalue = analogRead(PT1000_PIN);
float voltage = sensorvalue * (5.0 / 1023.0);
temp_c = (((voltage * 100) / vt_factor) + offset);
x = analogRead(sensor);
x = map(x, 256, 512, 0, 90);
lcd.setCursor(0,0);lcd.print(F("Temp:"));lcd.setCursor(5,0);lcd.print(temp_c, 1);lcd.setCursor(8,0);lcd.print(F("/150\337C"));
lcd.setCursor(0,1);lcd.print(F("Winkel:"));lcd.setCursor(7,1);lcd.print(x);lcd.setCursor(10,1);lcd.print(F("/"));lcd.setCursor(11,1);lcd.print(countera1);lcd.setCursor(13,1);lcd.print(F("\337"));
lcd.setCursor(0,2);lcd.print(F("Zeit:"));
unsigned long countdownDuration = (unsigned long)(countera * COUNTDOWN_INCREMENT) + 5000;
if (digitalRead(BTN_ACCEPT) == 0) {
taster = true;
heatingEnabled = true;
startTime = millis();
}
if (heatingEnabled && taster) {
digitalWrite(heatingPin, HIGH); // Heizelement einschalten
unsigned long elapsedTime = millis() - startTime;
remainingTime = countdownDuration > elapsedTime ? countdownDuration - elapsedTime : 0;
// calculate the minutes and seconds remaining
int minutes = remainingTime / 60000;
int seconds = (remainingTime / 1000) % 60;
lcd.setCursor(6,2);
if (remainingTime > 0) {
if (minutes < 10) {
lcd.print("0");
}
lcd.print(minutes);
lcd.print(":");
if (seconds < 10) {
lcd.print("0");
}
lcd.print(seconds);
lcd.setCursor(0,3);
if(temp_c >= 130){ // abfrage ob es 80 grad erreicht hat
lcd.print("uebertemperatur");
// abfrage ob es 120 grad erreicht hat wenn ja ausschalten
digitalWrite(heatingPin, LOW);
heatingEnabled = false;
}else{
lcd.print("wird erhitzt");
}
}
else {
digitalWrite(heatingPin, LOW); //ausschalten
lcd.print("00:00");
biegen = true;
}
}
else{
lcd.setCursor(0, 3);
lcd.print("erhitzen? [ok-lang]");
}
if(biegen)
{
lcd.setCursor(0, 3);
lcd.print("wird gebogen ");
if( x < countera1 -5 )
{
digitalWrite(P_FET_Q1, HIGH);
analogWrite(N_FET_Q4, 100);
}
if( x >= countera1 -5 )
{
digitalWrite(P_FET_Q1, HIGH);
analogWrite(N_FET_Q4, 50);
}
if( x == countera1){
digitalWrite(N_FET_Q4, LOW);
digitalWrite(P_FET_Q1, LOW);
lcd.setCursor(0,3);lcd.print(F("Warten"));
lcd.setCursor(0,3);lcd.print(F("ausgespannt? [ok]"));
if (btn_Accept_WasDown && btnIsUp(BTN_ACCEPT)){
lcd.setCursor(0,3);lcd.print(F("ausgangsstellung..."));
if( x > 5 )
{
digitalWrite(P_FET_Q3, HIGH);
analogWrite(N_FET_Q2, 100);
}
if( x < 5 )
{
digitalWrite(P_FET_Q3, HIGH);
analogWrite(N_FET_Q2, 50);
}
if( x == 0 )
{
digitalWrite(N_FET_Q2, LOW);
digitalWrite(P_FET_Q3, LOW);
aktuellseite = UNTER_MENU1;
return;
}
}
}
}
delay(1000);
updateDisplay = true;
}
// capture the button down states
if (btnIsDown(BTN_UP)) { delay(200);btn_Up_WasDown = true;delay(100);}
if (btnIsDown(BTN_DOWN)) { delay(200);btn_Down_WasDown = true;delay(100);}
if (btnIsDown(BTN_CANCEL)) { btn_Cancel_WasDown = true;}
if (btnIsDown(BTN_ACCEPT)) { btn_Accept_WasDown = true;}
//move the pointer down
if (btn_Down_WasDown && btnIsUp(BTN_DOWN)){
updateDisplay = true;
btn_Down_WasDown = false;
}
//move the pointer Up
if (btn_Up_WasDown && btnIsUp(BTN_UP)){
updateDisplay = true;
btn_Up_WasDown = false;
}
//move to the go to the HAUPT menu
if (btn_Cancel_WasDown && btnIsUp(BTN_CANCEL)){
aktuellseite = UNTER_MENU11;
return;
}
else{
digitalWrite(BUZZER, 1); // For every other condition make buzzer off
}
// keep a specific pace
while (millis() - loopStartMs < 25) {delay(2);}
}
}
// =======================================================================================
// || seite - UNTER MENU12 ||
// =======================================================================================
float counterb = 0;
int counterb1 = 45;
void seite_UNTERMenu12(void) {
//flag for updating the display
boolean updateDisplay = true;
// tracks when entered top of loop
uint32_t loopStartMs;
//tracks button states
boolean btn_Up_WasDown = false;
boolean btn_Down_WasDown = false;
boolean btn_Cancel_WasDown = false;
boolean btn_Accept_WasDown = false;
// selected item pointer
uint8_t UNTER_Pos2 = 1;
//inner loop
while (true){
// capture start time
loopStartMs = millis();
// print the display
if (updateDisplay){
// clear the update flag
updateDisplay = false;
//clear the display
clearScreen();
//menu title
//print a divider line
// print the items
lcd.setCursor(9,0);lcd.print(F("PC"));
lcd.setCursor(0,1);printSelected(1, UNTER_Pos2); lcd.setCursor(1,1);lcd.print(F("St\341rke"));lcd.setCursor(14,1); lcd.print(counterb);lcd.setCursor(18,1); lcd.print("mm");
lcd.setCursor(0,2);printSelected(2, UNTER_Pos2); lcd.setCursor(1,2);lcd.print(F("Winkel")); lcd.setCursor(17,2); lcd.print(counterb1);lcd.setCursor(19,2); lcd.print("\337");
lcd.setCursor(0,3);printSelected(3, UNTER_Pos2); lcd.setCursor(8,3);lcd.print(F("LOS!"));
//print a divider line
}
// capture the button down states
if (btnIsDown(BTN_UP)) { delay(200);btn_Up_WasDown = true;delay(100);}
if (btnIsDown(BTN_DOWN)) { delay(200);btn_Down_WasDown = true;delay(100);}
if (btnIsDown(BTN_CANCEL)) { btn_Cancel_WasDown = true;}
if (btnIsDown(BTN_ACCEPT)) { btn_Accept_WasDown = true;}
//move the pointer down
if (btn_Down_WasDown && btnIsUp(BTN_DOWN)){
if (UNTER_Pos2 == UNTER_MENU12_CNT) {UNTER_Pos2 = 1;} else {UNTER_Pos2++;}
updateDisplay = true;
btn_Down_WasDown = false;
}
//move the pointer Up
if (btn_Up_WasDown && btnIsUp(BTN_UP)){
if (UNTER_Pos2 == 1) {UNTER_Pos2 = UNTER_MENU12_CNT;} else {UNTER_Pos2--;}
updateDisplay = true;
btn_Up_WasDown = false;
}
//move to the go to the HAUPT menu
if (btn_Cancel_WasDown && btnIsUp(BTN_CANCEL)){
aktuellseite = UNTER_MENU1;
return;
}
if (btn_Accept_WasDown && btnIsUp(BTN_ACCEPT)){
switch (UNTER_Pos2) {
case 1: aktuellseite = UNTER_MENU121; return;
case 2: aktuellseite = UNTER_MENU122; return;
case 3: aktuellseite = UNTER_MENU123; return;
}
}
// keep a specific pace
while (millis() - loopStartMs < 25) {delay(2);}
}
}
// =======================================================================================
// || seite - UNTER MENU121 ||
// =======================================================================================
void seite_UNTERMenu121(void) {
//flag for updating the display
boolean updateDisplay = true;
// tracks when entered top of loop
uint32_t loopStartMs;
//tracks button states
boolean btn_Up_WasDown = false;
boolean btn_Down_WasDown = false;
boolean btn_Cancel_WasDown = false;
boolean btn_Accept_WasDown = false;
// selected item pointer
uint8_t UNTER_Pos = 1;
//inner loop
while (true){
// capture start time
loopStartMs = millis();
// print the display
if (updateDisplay){
// clear the update flag
updateDisplay = false;
//clear the display
clearScreen();
//menu title
//print a divider line
// print the items
lcd.setCursor(9,0);lcd.print(F("PC"));
lcd.setCursor(0,1);printSelected(1, UNTER_Pos); lcd.setCursor(1,1);lcd.print(F("St\341rke<")); lcd.setCursor(14,1); lcd.print(counterb);lcd.setCursor(18,1); lcd.print("mm");
lcd.setCursor(0,2);printSelected(2, UNTER_Pos); lcd.setCursor(1,2);lcd.print(F("Winkel")); lcd.setCursor(17,2); lcd.print(counterb1);lcd.setCursor(19,2); lcd.print("\337");
lcd.setCursor(0,3);printSelected(3, UNTER_Pos); lcd.setCursor(8,3);lcd.print(F("LOS!"));
//print a divider line
}
// capture the button down states
if (btnIsDown(BTN_UP)) { delay(200);btn_Up_WasDown = true;delay(100);}
if (btnIsDown(BTN_DOWN)) { delay(200);btn_Down_WasDown = true;delay(100);}
if (btnIsDown(BTN_CANCEL)) { btn_Cancel_WasDown = true;}
if (btnIsDown(BTN_ACCEPT)) { btn_Accept_WasDown = true;}
//move the pointer down
if (btn_Down_WasDown && btnIsUp(BTN_DOWN)){
counterb= counterb +0.5;
updateDisplay = true;
btn_Down_WasDown = false;
}
//move the pointer Ups
if (btn_Up_WasDown && btnIsUp(BTN_UP)){
counterb= counterb - 0.5;
updateDisplay = true;
btn_Up_WasDown = false;
}
//move to the go to the HAUPT menu
if (btn_Cancel_WasDown && btnIsUp(BTN_CANCEL)){
digitalWrite(BUZZER, 0);
delay(100);
digitalWrite(BUZZER, 1);
aktuellseite = UNTER_MENU12;
return;
}
else{
digitalWrite(BUZZER, 1); // For every other condition make buzzer off
}
if (btn_Accept_WasDown && btnIsUp(BTN_ACCEPT)){
digitalWrite(BUZZER, 0);
delay(100);
digitalWrite(BUZZER, 1);
aktuellseite = UNTER_MENU12;
return;
}
else{
digitalWrite(BUZZER, 1); // For every other condition make buzzer off
}
// keep a specific pace
while (millis() - loopStartMs < 25) {delay(2);}
}
}
// =======================================================================================
// || seite - UNTER MENU122 ||
// =======================================================================================
void seite_UNTERMenu122(void) {
//flag for updating the display
boolean updateDisplay = true;
// tracks when entered top of loop
uint32_t loopStartMs;
//tracks button states
boolean btn_Up_WasDown = false;
boolean btn_Down_WasDown = false;
boolean btn_Cancel_WasDown = false;
boolean btn_Accept_WasDown = false;
// selected item pointer
uint8_t UNTER_Pos = 1;
//inner loop
while (true){
// capture start time
loopStartMs = millis();
// print the display
if (updateDisplay){
// clear the update flag
updateDisplay = false;
//clear the display
clearScreen();
//menu title
//print a divider line
// print the items
lcd.setCursor(9,0);lcd.print(F("PC"));
lcd.setCursor(0,1);lcd.setCursor(1,1);lcd.print(F("St\341rke")); lcd.setCursor(14,1); lcd.print(counterb);lcd.setCursor(18,1); lcd.print("mm");
lcd.setCursor(0,2);printSelected(1, UNTER_Pos); lcd.setCursor(1,2);lcd.print(F("Winkel<")); lcd.setCursor(17,2); lcd.print(counterb1);lcd.setCursor(19,2); lcd.print("\337");
lcd.setCursor(0,3); lcd.setCursor(8,3);lcd.print(F("LOS!"));
//print a divider line
}
// capture the button down states
if (btnIsDown(BTN_UP)) { delay(200);btn_Up_WasDown = true;delay(100);}
if (btnIsDown(BTN_DOWN)) { delay(200);btn_Down_WasDown = true;delay(100);}
if (btnIsDown(BTN_CANCEL)) { btn_Cancel_WasDown = true;}
if (btnIsDown(BTN_ACCEPT)) { btn_Accept_WasDown = true;}
//move the pointer down
if (btn_Down_WasDown && btnIsUp(BTN_DOWN)){
counterb1= counterb1 +5;
updateDisplay = true;
btn_Down_WasDown = false;
}
//move the pointer Up
if (btn_Up_WasDown && btnIsUp(BTN_UP)){
counterb1= counterb1 - 5;
updateDisplay = true;
btn_Up_WasDown = false;
}
//move to the go to the HAUPT menu
if (btn_Cancel_WasDown && btnIsUp(BTN_CANCEL)){
digitalWrite(BUZZER, 0);
delay(100);
digitalWrite(BUZZER, 1);
aktuellseite = UNTER_MENU12;
return;
}
else{
digitalWrite(BUZZER, 1); // For every other condition make buzzer off
}
if (btn_Accept_WasDown && btnIsUp(BTN_ACCEPT)){
digitalWrite(BUZZER, 0);
delay(100);
digitalWrite(BUZZER, 1);
aktuellseite = UNTER_MENU12;
return;
}
else{
digitalWrite(BUZZER, 1); // For every other condition make buzzer off
}
// keep a specific pace
while (millis() - loopStartMs < 25) {delay(2);}
}
}
// =======================================================================================
// || seite - UNTER MENU123 ||
// =======================================================================================
void seite_UNTERMenu123(void) {
//flag for updating the display
boolean updateDisplay = true;
// tracks when entered top of loop
uint32_t loopStartMs;
//tracks button states
boolean btn_Up_WasDown = false;
boolean btn_Down_WasDown = false;
boolean btn_Cancel_WasDown = false;
boolean btn_Accept_WasDown = false;
boolean taster = false;
// selected item pointer
uint8_t UNTER_Pos = 1;
//inner loop
while (true){
// capture start time
loopStartMs = millis();
// print the display
if (updateDisplay){
// clear the update flag
updateDisplay = false;
//clear the display
clearScreen();
if (btnIsDown(BTN_ACCEPT)) { btn_Accept_WasDown = true;}
int sensorvalue = analogRead(PT1000_PIN);
float voltage = sensorvalue * (5.0 / 1023.0);
temp_c = (((voltage * 100) / vt_factor) + offset);
x = analogRead(sensor);
x = map(x, 256, 512, 0, 90);
lcd.setCursor(0,0);lcd.print(F("Temp:"));lcd.setCursor(5,0);lcd.print(temp_c, 1);lcd.setCursor(8,0);lcd.print(F("/150\337C"));
lcd.setCursor(0,1);lcd.print(F("Winkel:"));lcd.setCursor(7,1);lcd.print(x);lcd.setCursor(10,1);lcd.print(F("/"));lcd.setCursor(11,1);lcd.print(counterb1);lcd.setCursor(13,1);lcd.print(F("\337"));
lcd.setCursor(0,2);lcd.print(F("Zeit:"));
unsigned long countdownDuration = (unsigned long)(countera * COUNTDOWN_INCREMENT) + 5000;
if (digitalRead(BTN_ACCEPT) == 0) {
taster = true;
heatingEnabled = true;
startTime = millis();
}
if (heatingEnabled && taster) {
digitalWrite(heatingPin, HIGH); // Heizelement einschalten
unsigned long elapsedTime = millis() - startTime;
remainingTime = countdownDuration > elapsedTime ? countdownDuration - elapsedTime : 0;
// calculate the minutes and seconds remaining
int minutes = remainingTime / 60000;
int seconds = (remainingTime / 1000) % 60;
lcd.setCursor(6,2);
if (remainingTime > 0) {
if (minutes < 10) {
lcd.print("0");
}
lcd.print(minutes);
lcd.print(":");
if (seconds < 10) {
lcd.print("0");
}
lcd.print(seconds);
lcd.setCursor(0,3);
if(temp_c >= 130){ // abfrage ob es 80 grad erreicht hat
lcd.print("uebertemperatur");
// abfrage ob es 120 grad erreicht hat wenn ja ausschalten
digitalWrite(heatingPin, LOW);
heatingEnabled = false;
}else{
lcd.print("wird erhitzt");
}
}
else {
digitalWrite(heatingPin, LOW); //ausschalten
lcd.print("00:00");
biegen = true;
}
}
else{
lcd.setCursor(0, 3);
lcd.print("erhitzen? [ok-lang]");
}
if(biegen)
{
lcd.setCursor(0, 3);
lcd.print("wird gebogen ");
delay(5000);
if( x < countera1 -5 )
{
digitalWrite(P_FET_Q1, HIGH);
analogWrite(N_FET_Q4, 100);
}
if( x >= countera1 -5 )
{
digitalWrite(P_FET_Q1, HIGH);
analogWrite(N_FET_Q4, 50);
}
if( x == countera1){
digitalWrite(N_FET_Q4, LOW);
digitalWrite(P_FET_Q1, LOW);
lcd.setCursor(0,3);lcd.print(F("Warten"));
delay(5000);
lcd.setCursor(0,3);lcd.print(F("ausgespannt? [ok]"));
if (btn_Accept_WasDown && btnIsUp(BTN_ACCEPT)){
lcd.setCursor(0,3);lcd.print(F("ausgangsstellung..."));
if( x > 5 )
{
digitalWrite(P_FET_Q3, HIGH);
analogWrite(N_FET_Q2, 100);
}
if( x < 5 )
{
digitalWrite(P_FET_Q3, HIGH);
analogWrite(N_FET_Q2, 50);
}
if( x == 0 )
{
digitalWrite(N_FET_Q2, LOW);
digitalWrite(P_FET_Q3, LOW);
aktuellseite = UNTER_MENU1;
return;
}
}
}
}
delay(1000);
updateDisplay = true;
}
// capture the button down states
if (btnIsDown(BTN_UP)) { delay(200);btn_Up_WasDown = true;delay(100);}
if (btnIsDown(BTN_DOWN)) { delay(200);btn_Down_WasDown = true;delay(100);}
if (btnIsDown(BTN_CANCEL)) { btn_Cancel_WasDown = true;}
if (btnIsDown(BTN_ACCEPT)) { btn_Accept_WasDown = true;}
//move the pointer down
if (btn_Down_WasDown && btnIsUp(BTN_DOWN)){
updateDisplay = true;
btn_Down_WasDown = false;
}
//move the pointer Up
if (btn_Up_WasDown && btnIsUp(BTN_UP)){
updateDisplay = true;
btn_Up_WasDown = false;
}
//move to the go to the HAUPT menu
if (btn_Cancel_WasDown && btnIsUp(BTN_CANCEL)){
digitalWrite(BUZZER, 0);
delay(100);
digitalWrite(BUZZER, 1);
aktuellseite = UNTER_MENU12;
return;
}
else{
digitalWrite(BUZZER, 1); // For every other condition make buzzer off
}
// keep a specific pace
while (millis() - loopStartMs < 25) {delay(2);}
}
}
// =======================================================================================
// || seite - UNTER MENU13 ||
// =======================================================================================
void seite_UNTERMenu13(void) {
//flag for updating the display
boolean updateDisplay = true;
// tracks when entered top of loop
uint32_t loopStartMs;
//tracks button states
boolean btn_Up_WasDown = false;
boolean btn_Down_WasDown = false;
boolean btn_Cancel_WasDown = false;
boolean btn_Accept_WasDown = false;
// selected item pointer
uint8_t UNTER_Pos3 = 1;
//inner loop
while (true){
// capture start time
loopStartMs = millis();
// print the display
if (updateDisplay){
// clear the update flag
updateDisplay = false;
//clear the display
clearScreen();
//menu title
//print a divider line
// print the items
lcd.setCursor(8,0);lcd.print(F("PVC"));
lcd.setCursor(0,1);printSelected(1, UNTER_Pos3); lcd.setCursor(1,1);lcd.print(F("St\341rke"));
lcd.setCursor(0,2);printSelected(2, UNTER_Pos3); lcd.setCursor(1,2);lcd.print(F("Winkel"));
lcd.setCursor(0,3);printSelected(3, UNTER_Pos3); lcd.setCursor(8,3);lcd.print(F("LOS!"));
//print a divider line
}
// capture the button down states
if (btnIsDown(BTN_UP)) { delay(200);btn_Up_WasDown = true;delay(100);}
if (btnIsDown(BTN_DOWN)) { delay(200);btn_Down_WasDown = true;delay(100);}
if (btnIsDown(BTN_CANCEL)) { btn_Cancel_WasDown = true;}
if (btnIsDown(BTN_ACCEPT)) { btn_Accept_WasDown = true;}
//move the pointer down
if (btn_Down_WasDown && btnIsUp(BTN_DOWN)){
if (UNTER_Pos3 == UNTER_MENU13_CNT) {UNTER_Pos3 = 1;} else {UNTER_Pos3++;}
updateDisplay = true;
btn_Down_WasDown = false;
}
//move the pointer Up
if (btn_Up_WasDown && btnIsUp(BTN_UP)){
if (UNTER_Pos3 == 1) {UNTER_Pos3 = UNTER_MENU13_CNT;} else {UNTER_Pos3--;}
updateDisplay = true;
btn_Up_WasDown = false;
}
//move to the go to the HAUPT menu
if (btn_Cancel_WasDown && btnIsUp(BTN_CANCEL)){
digitalWrite(BUZZER, 0);
delay(100);
digitalWrite(BUZZER, 1);
aktuellseite = UNTER_MENU1;
return;
}
else{
digitalWrite(BUZZER, 1); // For every other condition make buzzer off
}
if (btn_Accept_WasDown && btnIsUp(BTN_ACCEPT)){
digitalWrite(BUZZER, 0);
delay(100);
digitalWrite(BUZZER, 1);
switch (UNTER_Pos3) {
case 1: aktuellseite = UNTER_MENU131; return;
case 2: aktuellseite = UNTER_MENU132; return;
case 3: aktuellseite = UNTER_MENU133; return;
}
}
else{
digitalWrite(BUZZER, 1); // For every other condition make buzzer off
}
// keep a specific pace
while (millis() - loopStartMs < 25) {delay(2);}
}
}
// =======================================================================================
// || seite - UNTER MENU131 ||
// =======================================================================================
float counterc = 1;
void seite_UNTERMenu131(void) {
//flag for updating the display
boolean updateDisplay = true;
// tracks when entered top of loop
uint32_t loopStartMs;
//tracks button states
boolean btn_Up_WasDown = false;
boolean btn_Down_WasDown = false;
boolean btn_Cancel_WasDown = false;
boolean btn_Accept_WasDown = false;
// selected item pointer
uint8_t UNTER_Pos = 1;
//inner loop
while (true){
// capture start time
loopStartMs = millis();
// print the display
if (updateDisplay){
// clear the update flag
updateDisplay = false;
//clear the display
clearScreen();
//menu title
//print a divider line
// print the items
lcd.setCursor(9,0);lcd.print(F("PVC"));
lcd.setCursor(0,1);printSelected(1, UNTER_Pos); lcd.setCursor(1,1);lcd.print(F("St\341rke<")); lcd.setCursor(14,1); lcd.print(counterc);lcd.setCursor(18,1); lcd.print("mm");
lcd.setCursor(0,2);printSelected(2, UNTER_Pos); lcd.setCursor(1,2);lcd.print(F("Winkel"));
lcd.setCursor(0,3);printSelected(3, UNTER_Pos); lcd.setCursor(8,3);lcd.print(F("LOS!"));
//print a divider line
}
// capture the button down states
if (btnIsDown(BTN_UP)) { delay(200);btn_Up_WasDown = true;delay(100);}
if (btnIsDown(BTN_DOWN)) { delay(200);btn_Down_WasDown = true;delay(100);}
if (btnIsDown(BTN_CANCEL)) { btn_Cancel_WasDown = true;}
if (btnIsDown(BTN_ACCEPT)) { btn_Accept_WasDown = true;}
//move the pointer down
if (btn_Down_WasDown && btnIsUp(BTN_DOWN)){
counterc= counterc +0.5;
updateDisplay = true;
btn_Down_WasDown = false;
}
//move the pointer Up
if (btn_Up_WasDown && btnIsUp(BTN_UP)){
counterc= counterc -0.5;
updateDisplay = true;
btn_Up_WasDown = false;
}
//move to the go to the HAUPT menu
if (btn_Cancel_WasDown && btnIsUp(BTN_CANCEL)){
digitalWrite(BUZZER, 0);
delay(100);
digitalWrite(BUZZER, 1);
aktuellseite = UNTER_MENU13;
return;
}
else{
digitalWrite(BUZZER, 1); // For every other condition make buzzer off
}
// keep a specific pace
while (millis() - loopStartMs < 25) {delay(2);}
}
}
// =======================================================================================
// || seite - UNTER MENU132 ||
// =======================================================================================
int counterc1 = 90;
void seite_UNTERMenu132(void) {
//flag for updating the display
boolean updateDisplay = true;
// tracks when entered top of loop
uint32_t loopStartMs;
//tracks button states
boolean btn_Up_WasDown = false;
boolean btn_Down_WasDown = false;
boolean btn_Cancel_WasDown = false;
boolean btn_Accept_WasDown = false;
// selected item pointer
uint8_t UNTER_Pos = 1;
//inner loop
while (true){
// capture start time
loopStartMs = millis();
// print the display
if (updateDisplay){
// clear the update flag
updateDisplay = false;
//clear the display
clearScreen();
//menu title
//print a divider line
// print the items
lcd.setCursor(9,0);lcd.print(F("PVC"));
lcd.setCursor(0,1);lcd.setCursor(1,1);lcd.print(F("St\341rke"));
lcd.setCursor(0,2);printSelected(1, UNTER_Pos); lcd.setCursor(1,2);lcd.print(F("Winkel<")); lcd.setCursor(17,2); lcd.print(counterc1);lcd.setCursor(19,2); lcd.print("\337");
lcd.setCursor(0,3); lcd.setCursor(8,3);lcd.print(F("LOS!"));
//print a divider line
}
// capture the button down states
if (btnIsDown(BTN_UP)) { delay(200);btn_Up_WasDown = true;delay(100);}
if (btnIsDown(BTN_DOWN)) { delay(200);btn_Down_WasDown = true;delay(100);}
if (btnIsDown(BTN_CANCEL)) { btn_Cancel_WasDown = true;}
if (btnIsDown(BTN_ACCEPT)) { btn_Accept_WasDown = true;}
//move the pointer down
if (btn_Down_WasDown && btnIsUp(BTN_DOWN)){
counterc1= counterc1 +5;
updateDisplay = true;
btn_Down_WasDown = false;
}
//move the pointer Up
if (btn_Up_WasDown && btnIsUp(BTN_UP)){
counterc1= counterc1 - 5;
updateDisplay = true;
btn_Up_WasDown = false;
}
//move to the go to the HAUPT menu
if (btn_Cancel_WasDown && btnIsUp(BTN_CANCEL)){
digitalWrite(BUZZER, 0);
delay(100);
digitalWrite(BUZZER, 1);
aktuellseite = UNTER_MENU13;
return;
}
else{
digitalWrite(BUZZER, 1); // For every other condition make buzzer off
}
// keep a specific pace
while (millis() - loopStartMs < 25) {delay(2);}
}
}
// =======================================================================================
// || seite - UNTER MENU133 ||
// =======================================================================================
void seite_UNTERMenu133(void) {
//flag for updating the display
boolean updateDisplay = true;
// tracks when entered top of loop
uint32_t loopStartMs;
//tracks button states
boolean btn_Up_WasDown = false;
boolean btn_Down_WasDown = false;
boolean btn_Cancel_WasDown = false;
boolean btn_Accept_WasDown = false;
// selected item pointer
uint8_t UNTER_Pos = 1;
//inner loop
while (true){
// capture start time
loopStartMs = millis();
// print the display
if (updateDisplay){
// clear the update flag
updateDisplay = false;
//clear the display
clearScreen();
//menu title
//print a divider line
lcd.setCursor(0,0);lcd.print(F("Mat.:"));lcd.setCursor(5,0);lcd.print(F("PVC |"));
lcd.setCursor(0,1);lcd.print(F("Dicke:"));lcd.setCursor(6,1);lcd.print(counterc);lcd.setCursor(10,1); lcd.print("|");
lcd.setCursor(0,2);lcd.print(F("Winkel:"));lcd.setCursor(7,2);lcd.print(counterc1);lcd.setCursor(9,2);lcd.print("\337|");
lcd.setCursor(0,3);lcd.print(F("Soll: 56\337C|"));
//IST DATEN
x = analogRead(sensor);
x = map(x, 0, 1010, 0, 360);
lcd.setCursor(11,2);lcd.print(F("Ist:"));lcd.setCursor(16,2);lcd.print(x);lcd.setCursor(18,3);lcd.print(F("\337"));
lcd.setCursor(11,3);lcd.print(F("Ist:"));lcd.setCursor(16,3);lcd.print((int)temperature);lcd.setCursor(18,3);lcd.print(F("\337C"));
lcd.setCursor(11,1);lcd.print(F("Zeit02:00"));
if(temperature < 25){
lcd.setCursor(11,0);lcd.print(F("aufw\341rmen"));
}
else{
lcd.setCursor(11,0);lcd.print(F("biegen"));
}
}
// capture the button down states
if (btnIsDown(BTN_UP)) { delay(200);btn_Up_WasDown = true;delay(100);}
if (btnIsDown(BTN_DOWN)) { delay(200);btn_Down_WasDown = true;delay(100);}
if (btnIsDown(BTN_CANCEL)) { btn_Cancel_WasDown = true;}
if (btnIsDown(BTN_ACCEPT)) { btn_Accept_WasDown = true;}
//move the pointer down
if (btn_Down_WasDown && btnIsUp(BTN_DOWN)){
updateDisplay = true;
btn_Down_WasDown = false;
}
//move the pointer Up
if (btn_Up_WasDown && btnIsUp(BTN_UP)){
updateDisplay = true;
btn_Up_WasDown = false;
}
//move to the go to the HAUPT menu
if (btn_Cancel_WasDown && btnIsUp(BTN_CANCEL)){
digitalWrite(BUZZER, 0);
delay(100);
digitalWrite(BUZZER, 1);
aktuellseite = UNTER_MENU13;
return;
}
else{
digitalWrite(BUZZER, 1); // For every other condition make buzzer off
}
// keep a specific pace
while (millis() - loopStartMs < 25) {delay(2);}
}
}
// =======================================================================================
// || seite - UNTER MENU14 ||
// =======================================================================================
void seite_UNTERMenu14(void) {
//flag for updating the display
boolean updateDisplay = true;
// tracks when entered top of loop
uint32_t loopStartMs;
//tracks button states
boolean btn_Up_WasDown = false;
boolean btn_Down_WasDown = false;
boolean btn_Cancel_WasDown = false;
boolean btn_Accept_WasDown = false;
// selected item pointer
uint8_t UNTER_Pos = 1;
//inner loop
while (true){
// capture start time
loopStartMs = millis();
// print the display
if (updateDisplay){
// clear the update flag
updateDisplay = false;
//clear the display
clearScreen();
//menu title
//print a divider line
// print the items
lcd.setCursor(6,0);lcd.print(F("PE / PP"));
lcd.setCursor(0,1);printSelected(1, UNTER_Pos); lcd.setCursor(1,1);lcd.print(F("St\341rke:"));
lcd.setCursor(0,2);printSelected(2, UNTER_Pos); lcd.setCursor(1,2);lcd.print(F("Winkel:"));
lcd.setCursor(0,3);printSelected(3, UNTER_Pos); lcd.setCursor(8,3);lcd.print(F("LOS!"));
//print a divider line
}
// capture the button down states
if (btnIsDown(BTN_UP)) { delay(200);btn_Up_WasDown = true;delay(100);}
if (btnIsDown(BTN_DOWN)) { delay(200);btn_Down_WasDown = true;delay(100);}
if (btnIsDown(BTN_CANCEL)) { btn_Cancel_WasDown = true;}
if (btnIsDown(BTN_ACCEPT)) { btn_Accept_WasDown = true;}
//move the pointer down
if (btn_Down_WasDown && btnIsUp(BTN_DOWN)){
if (UNTER_Pos == UNTER_MENU14_CNT) {UNTER_Pos = 1;} else {UNTER_Pos++;}
updateDisplay = true;
btn_Down_WasDown = false;
}
//move the pointer Up
if (btn_Up_WasDown && btnIsUp(BTN_UP)){
if (UNTER_Pos == 1) {UNTER_Pos = UNTER_MENU14_CNT;} else {UNTER_Pos--;}
updateDisplay = true;
btn_Up_WasDown = false;
}
//move to the go to the HAUPT menu
if (btn_Cancel_WasDown && btnIsUp(BTN_CANCEL)){
digitalWrite(BUZZER, 0);
delay(100);
digitalWrite(BUZZER, 1);
aktuellseite = UNTER_MENU1;
return;
}
else{
digitalWrite(BUZZER, 1); // For every other condition make buzzer off
}
// keep a specific pace
while (millis() - loopStartMs < 25) {delay(2);}
}
}
// =======================================================================================
// || seite - UNTER MENU2 ||
// =======================================================================================
void seite_UNTERMenu2(void) {
//flag for updating the display
boolean updateDisplay = true;
// tracks when entered top of loop
uint32_t loopStartMs;
//tracks button states
boolean btn_Up_WasDown = false;
boolean btn_Down_WasDown = false;
boolean btn_Cancel_WasDown = false;
boolean btn_Accept_WasDown = false;
// selected item pointer
uint8_t UNTER_Pos = 1;
//inner loop
while (true){
// capture start time
loopStartMs = millis();
// print the display
if (updateDisplay){
// clear the update flag
updateDisplay = false;
//clear the display
clearScreen();
//menu title
//print a divider line
// print the items
lcd.setCursor(0,0);printSelected(1, UNTER_Pos); lcd.setCursor(1,0);lcd.print(F("Ausfahren"));
lcd.setCursor(0,1);printSelected(2, UNTER_Pos); lcd.setCursor(1,1);lcd.print(F("Einfahren"));
//print a divider line
}
// capture the button down states
if (btnIsDown(BTN_UP)) {delay(200);btn_Up_WasDown = true;delay(100);}
if (btnIsDown(BTN_DOWN)) { delay(200);btn_Down_WasDown = true;delay(100);}
if (btnIsDown(BTN_CANCEL)) { btn_Cancel_WasDown = true;}
if (btnIsDown(BTN_ACCEPT)) { btn_Accept_WasDown = true;}
//move the pointer down
if (btn_Down_WasDown && btnIsUp(BTN_DOWN)){
if (UNTER_Pos == UNTER_MENU2_CNT) {UNTER_Pos = 1;} else {UNTER_Pos++;}
updateDisplay = true;
btn_Down_WasDown = false;
}
//move the pointer Up
if (btn_Up_WasDown && btnIsUp(BTN_UP)){
if (UNTER_Pos == 1) {UNTER_Pos = UNTER_MENU2_CNT;} else {UNTER_Pos--;}
updateDisplay = true;
btn_Up_WasDown = false;
}
//move to the go to the HAUPT menu
if (btn_Cancel_WasDown && btnIsUp(BTN_CANCEL)){
digitalWrite(BUZZER, 0);
delay(100);
digitalWrite(BUZZER, 1);
aktuellseite = HAUPT_MENU;
return;
}
else{
digitalWrite(BUZZER, 1); // For every other condition make buzzer off
}
//move to the selected seite
if (btn_Accept_WasDown && btnIsUp(BTN_ACCEPT)){
digitalWrite(BUZZER, 0);
delay(100);
digitalWrite(BUZZER, 1);
switch (UNTER_Pos) {
case 1: aktuellseite = UNTER_MENU21; return;
case 2: aktuellseite = UNTER_MENU22; return;
}
}
else{
digitalWrite(BUZZER, 1); // For every other condition make buzzer off
}
// keep a specific pace
while (millis() - loopStartMs < 25) {delay(2);}
}
}
// =======================================================================================
// || seite - UNTER MENU21 ||
// =======================================================================================
void seite_UNTERMenu21(void) {
//flag for updating the display
boolean updateDisplay = true;
// tracks when entered top of loop
uint32_t loopStartMs;
//tracks button states
boolean btn_Up_WasDown = false;
boolean btn_Down_WasDown = false;
boolean btn_Cancel_WasDown = false;
boolean btn_Accept_WasDown = false;
// selected item pointer
uint8_t UNTER_Pos1 = 1;
//inner loop
while (true){
// capture start time
loopStartMs = millis();
// print the display
if (updateDisplay){
// clear the update flag
updateDisplay = false;
//clear the display
clearScreen();
//menu title
//print a divider line
// print the items
lcd.setCursor(0,0);lcd.print(F("Ausfahren?"));
lcd.setCursor(0,1);printSelected(1, UNTER_Pos1); lcd.setCursor(1,1);lcd.print(F("[ok Lang]"));
//print a divider line
}
// capture the button down states
if (btnIsDown(BTN_UP)) { delay(200);btn_Up_WasDown = true;delay(100);}
if (btnIsDown(BTN_DOWN)) { delay(200);btn_Down_WasDown = true;delay(100);}
if (btnIsDown(BTN_CANCEL)) { btn_Cancel_WasDown = true;}
if (btnIsDown(BTN_ACCEPT)) { btn_Accept_WasDown = true;}
//move the pointer down
if (btn_Down_WasDown && btnIsUp(BTN_DOWN)){
if (UNTER_Pos1 == UNTER_MENU21_CNT) {UNTER_Pos1 = 1;} else {UNTER_Pos1++;}
updateDisplay = true;
btn_Down_WasDown = false;
}
//move the pointer Up
if (btn_Up_WasDown && btnIsUp(BTN_UP)){
if (UNTER_Pos1 == 1) {UNTER_Pos1 = UNTER_MENU21_CNT;} else {UNTER_Pos1--;}
updateDisplay = true;
btn_Up_WasDown = false;
}
//move to the go to the HAUPT menu
if (btn_Cancel_WasDown && btnIsUp(BTN_CANCEL)){
digitalWrite(BUZZER, 0);
delay(100);
digitalWrite(BUZZER, 1);
aktuellseite = UNTER_MENU2;
return;
}
else{
digitalWrite(BUZZER, 1); // For every other condition make buzzer off
}
if (btn_Accept_WasDown && btnIsUp(BTN_ACCEPT)){
digitalWrite(P_FET_Q1, HIGH);
analogWrite(N_FET_Q4, 80);
}else{
digitalWrite(N_FET_Q4, LOW);
digitalWrite(P_FET_Q1, LOW);
}
// keep a specific pace
while (millis() - loopStartMs < 25) {delay(2);}
}
}
// =======================================================================================
// || seite - UNTER MENU22 ||
// =======================================================================================
void seite_UNTERMenu22(void) {
//flag for updating the display
boolean updateDisplay = true;
// tracks when entered top of loop
uint32_t loopStartMs;
//tracks button states
boolean btn_Up_WasDown = false;
boolean btn_Down_WasDown = false;
boolean btn_Cancel_WasDown = false;
boolean btn_Accept_WasDown = false;
// selected item pointer
uint8_t UNTER_Pos1 = 1;
//inner loop
while (true){
// capture start time
loopStartMs = millis();
// print the display
if (updateDisplay){
// clear the update flag
updateDisplay = false;
//clear the display
clearScreen();
//menu title
//print a divider line
// print the items
lcd.setCursor(0,0);lcd.print(F("Einfahren?"));
lcd.setCursor(0,1);printSelected(1, UNTER_Pos1); lcd.setCursor(1,1);lcd.print(F("[ok Lang]"));
//print a divider line
}
// capture the button down states
if (btnIsDown(BTN_UP)) { delay(200);btn_Up_WasDown = true;delay(100);}
if (btnIsDown(BTN_DOWN)) { delay(200);btn_Down_WasDown = true;delay(100);}
if (btnIsDown(BTN_CANCEL)) { btn_Cancel_WasDown = true;}
if (btnIsDown(BTN_ACCEPT)) { btn_Accept_WasDown = true;}
//move the pointer down
if (btn_Down_WasDown && btnIsUp(BTN_DOWN)){
if (UNTER_Pos1 == UNTER_MENU11_CNT) {UNTER_Pos1 = 1;} else {UNTER_Pos1++;}
updateDisplay = true;
btn_Down_WasDown = false;
}
//move the pointer Up
if (btn_Up_WasDown && btnIsUp(BTN_UP)){
if (UNTER_Pos1 == 1) {UNTER_Pos1 = UNTER_MENU11_CNT;} else {UNTER_Pos1--;}
updateDisplay = true;
btn_Up_WasDown = false;
}
//move to the go to the HAUPT menu
if (btn_Cancel_WasDown && btnIsUp(BTN_CANCEL)){
digitalWrite(BUZZER, 0);
delay(100);
digitalWrite(BUZZER, 1);
aktuellseite = UNTER_MENU2;
return;
}
else{
digitalWrite(BUZZER, 1); // For every other condition make buzzer off
}
if (btn_Accept_WasDown && btnIsUp(BTN_ACCEPT)){
digitalWrite(P_FET_Q3, HIGH);
analogWrite(N_FET_Q2, 80);
}else{
digitalWrite(P_FET_Q3, LOW);
digitalWrite(N_FET_Q2, LOW);
}
// keep a specific pace
while (millis() - loopStartMs < 25) {delay(2);}
}
}
// =======================================================================================
// || seite - UNTER MENU3 ||
// =======================================================================================
void seite_UNTERMenu3(void) {
//flag for updating the display
boolean updateDisplay = true;
// tracks when entered top of loop
uint32_t loopStartMs;
//tracks button states
boolean btn_Up_WasDown = false;
boolean btn_Down_WasDown = false;
boolean btn_Cancel_WasDown = false;
// selected item pointer
uint8_t UNTER_Pos = 1;
//inner loop
while (true){
// capture start time
loopStartMs = millis();
// print the display
if (updateDisplay){
// clear the update flag
updateDisplay = false;
//clear the display
clearScreen();
//menu title
//print a divider line
// print the items
lcd.setCursor(1,0);lcd.print(F("Diplomarbeit von:"));
lcd.setCursor(0,1);printSelected(1, UNTER_Pos); lcd.setCursor(1,1);lcd.print(F("Selikoglu"));
lcd.setCursor(0,2);printSelected(2, UNTER_Pos); lcd.setCursor(1,2);lcd.print(F("Tischleritsch"));
lcd.setCursor(0,3);printSelected(3, UNTER_Pos); lcd.setCursor(1,3);lcd.print(F("Widhalm"));
lcd.print("");
//print a divider line
}
// capture the button down states
if (btnIsDown(BTN_UP)) { delay(200);btn_Up_WasDown = true;delay(100);}
if (btnIsDown(BTN_DOWN)) { delay(200);btn_Down_WasDown = true;delay(100);}
if (btnIsDown(BTN_CANCEL)) { btn_Cancel_WasDown = true;}
//move the pointer down
if (btn_Down_WasDown && btnIsUp(BTN_DOWN)){
if (UNTER_Pos == UNTER_MENU3_CNT) {UNTER_Pos = 1;} else {UNTER_Pos++;}
updateDisplay = true;
btn_Down_WasDown = false;
}
//move the pointer Up
if (btn_Up_WasDown && btnIsUp(BTN_UP)){
if (UNTER_Pos == 1) {UNTER_Pos = UNTER_MENU3_CNT;} else {UNTER_Pos--;}
updateDisplay = true;
btn_Up_WasDown = false;
}
//move to the go to the HAUPT menu
if (btn_Cancel_WasDown && btnIsUp(BTN_CANCEL)){aktuellseite = HAUPT_MENU; return;}
// keep a specific pace
while (millis() - loopStartMs < 25) {delay(2);}
}
}
// =======================================================================================
// || TOOLS - DISPLAY ||
// =======================================================================================
void printSelected(uint8_t p1, uint8_t p2){
if(p1 == p2){
lcd.print(F(">"));
}
else {
lcd.print(F(" "));
}
}
void clearScreen(void){
lcd.clear();
}
void printDivider(void){
for (uint8_t i = 0; i < 40; i++) {lcd.print("-");}
lcd.clear();
}
// =======================================================================================
// || TOOLS - BUTTON PRESSING ||
// =======================================================================================
boolean btnIsDown(int btn){
return digitalRead(btn) == LOW && digitalRead(btn) == LOW;
}
boolean btnIsUp(int btn){
return digitalRead(btn) == HIGH && digitalRead(btn) == HIGH;
}
// schreib mir ein arduino programm dass wenn ich ein heizstab runter klappe und dann mit ein knopf es bestätige das der heizstab unten ist, soll sie die heizstab erhitzen, nach dem erhitzen klappe ich den heizstab wieder hoch und die dann soll das programm ausgeben das die biege vorgang gestartet werden kann, die heizstab wird mit 2 tastern abgefragt wo seine aktuelle position ist, gib im seriellen monitor aus was zu tun ist