Etikettier Funktion (diejenige, um die es eigentlich geht ;-)) zugefügt
This commit is contained in:
parent
d07f251b04
commit
8e847d9c3b
|
@ -87,6 +87,7 @@ unsigned char MotorDelay = 1;
|
||||||
unsigned char MotorDelayOld = 0;
|
unsigned char MotorDelayOld = 0;
|
||||||
unsigned char MotorDelayEEPROM = 0;
|
unsigned char MotorDelayEEPROM = 0;
|
||||||
unsigned long previousMillis = 0;
|
unsigned long previousMillis = 0;
|
||||||
|
unsigned long previousMillisEti = 0;
|
||||||
int UP = 0;
|
int UP = 0;
|
||||||
int DOWN = 0;
|
int DOWN = 0;
|
||||||
int ENTER = 0;
|
int ENTER = 0;
|
||||||
|
@ -94,10 +95,23 @@ int UP_OLD = 0;
|
||||||
int DOWN_OLD = 0;
|
int DOWN_OLD = 0;
|
||||||
int ENTER_OLD = 0;
|
int ENTER_OLD = 0;
|
||||||
|
|
||||||
|
int gapDetected = 0;
|
||||||
|
int run = 0;
|
||||||
|
int finish = 1;
|
||||||
|
unsigned long Motor;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
pinMode(SCK, INPUT);
|
pinMode(SCK, INPUT);
|
||||||
pinMode(MOSI, INPUT);
|
pinMode(MOSI, INPUT);
|
||||||
pinMode(MISO, INPUT);
|
pinMode(MISO, INPUT);
|
||||||
|
pinMode(12, OUTPUT);
|
||||||
|
pinMode(11, INPUT);
|
||||||
|
pinMode(7, INPUT);
|
||||||
|
|
||||||
|
pinMode(8, OUTPUT);
|
||||||
|
pinMode(9, OUTPUT);
|
||||||
|
pinMode(10, OUTPUT);
|
||||||
|
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
|
|
||||||
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
|
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
|
||||||
|
@ -105,13 +119,14 @@ pinMode(MISO, INPUT);
|
||||||
Serial.println(F("SSD1306 allocation failed"));
|
Serial.println(F("SSD1306 allocation failed"));
|
||||||
for(;;); // Don't proceed, loop forever
|
for(;;); // Don't proceed, loop forever
|
||||||
}
|
}
|
||||||
|
MotorDelayEEPROM = EEPROM.read(0);
|
||||||
|
MotorDelay = MotorDelayEEPROM;
|
||||||
|
|
||||||
testdrawbitmap(); // Draw a small bitmap image
|
testdrawbitmap(); // Draw a small bitmap image
|
||||||
delay(2000); // Pause for 2 seconds
|
delay(2000); // Pause for 2 seconds
|
||||||
// Clear the buffer
|
// Clear the buffer
|
||||||
display.clearDisplay();
|
display.clearDisplay();
|
||||||
display.display();
|
display.display();
|
||||||
MotorDelayEEPROM = EEPROM.read(0);
|
|
||||||
MotorDelay = MotorDelayEEPROM;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
@ -131,7 +146,6 @@ void loop() {
|
||||||
}
|
}
|
||||||
if (ENTER == 1){
|
if (ENTER == 1){
|
||||||
if (currentMillis - previousMillis >= 2000) {
|
if (currentMillis - previousMillis >= 2000) {
|
||||||
// save the last time you blinked the LED
|
|
||||||
previousMillis = currentMillis;
|
previousMillis = currentMillis;
|
||||||
EEPROM.write(0, MotorDelay);
|
EEPROM.write(0, MotorDelay);
|
||||||
MotorDelayEEPROM = EEPROM.read(0);
|
MotorDelayEEPROM = EEPROM.read(0);
|
||||||
|
@ -142,6 +156,37 @@ void loop() {
|
||||||
else {
|
else {
|
||||||
previousMillis = currentMillis;
|
previousMillis = currentMillis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned long currentMillisEti = millis();
|
||||||
|
Motor = MotorDelay * 100;
|
||||||
|
if (digitalRead(11) == HIGH && run == 0 && finish == 1){
|
||||||
|
run = 1;
|
||||||
|
finish = 0;
|
||||||
|
}
|
||||||
|
if (run == 1) {
|
||||||
|
digitalWrite(12, HIGH);
|
||||||
|
if (digitalRead(7) == HIGH){
|
||||||
|
gapDetected = 1;
|
||||||
|
}
|
||||||
|
if(gapDetected = 1) {
|
||||||
|
if (currentMillisEti - previousMillisEti >= Motor) {
|
||||||
|
previousMillisEti = currentMillisEti;
|
||||||
|
run = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
previousMillisEti = currentMillisEti;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
digitalWrite(12, LOW);
|
||||||
|
previousMillisEti = currentMillisEti;
|
||||||
|
}
|
||||||
|
if (run == 0 && digitalRead(11) == 0){
|
||||||
|
finish = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
UP_OLD = UP;
|
UP_OLD = UP;
|
||||||
DOWN_OLD = DOWN;
|
DOWN_OLD = DOWN;
|
||||||
ENTER_OLD = ENTER;
|
ENTER_OLD = ENTER;
|
||||||
|
|
Loading…
Reference in a new issue