Hallo zusammen,
ich habe eine kleine Schaltung mit Display, zwei Tastern, einem Mic. und einem Pieper gebaut.
Das ganze ist eine kleine Schaltung für meine Kamera und löst diese über einen Optokoppler aus.
Das Programm habe ich mit Ardublock Maxi und Scope erstellt.
Das ganze funktioniert auch, jedoch Piept der Pieper jedes mal, wenn einer der Taster gedrückt wird, um die Verzögerung einzustellen.
Ich kann mir dies einfach nicht erklären und vielleicht kann mir jemand kurz sagen warum dies so ist...
Hier das Programm:
#include <SCoop.h>
#include <LiquidCrystal.h>
bool isABEventTriggered(int trigFlag, int lastStatus, int currentStatus)
{
switch (trigFlag)
{
case (0): //LOW
{
return !currentStatus;
}
case (1): //HIGH
{
return (bool)currentStatus;
}
case (2): //FALLING
{
return (lastStatus!=currentStatus && LOW==currentStatus);
}
case (3): //RISING
{
return (lastStatus!=currentStatus && HIGH==currentStatus);
}
case (4): //CHANGE
{
return (lastStatus != currentStatus);
}
default:
{
return false;
}
}
}
int _ABVAR_1_pin_event_7 = 0;
int verzoegerung = 0 ;
int _ABVAR_3_pin_event_8 = 0;
int _ABVAR_4_pin_event_6 = 0;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup()
{
pinMode( 6 , INPUT);
pinMode( 13 , OUTPUT);
mySCoop.start();
pinMode( 9 , OUTPUT);
pinMode( 10 , OUTPUT);
lcd.begin(16, 2);
pinMode( 7 , OUTPUT);
pinMode( 8 , OUTPUT);
Serial.begin(9600);
}
void loop()
{
yield();
}
defineTask(scoopTask37)
void scoopTask37::setup()
{
pinMode(7, INPUT);
_ABVAR_1_pin_event_7 = digitalRead(7);
}
void scoopTask37::loop()
{
int abvarCurrentStatus = digitalRead(7);
if (isABEventTriggered(0, _ABVAR_1_pin_event_7, abvarCurrentStatus))
{
verzoegerung = constrain( ( verzoegerung + 5 ) , 0 , 400 ) ;
sleep(90);
}
_ABVAR_1_pin_event_7 = abvarCurrentStatus;
}
defineTask(scoopTask38)
void scoopTask38::setup()
{
pinMode(8, INPUT);
_ABVAR_3_pin_event_8 = digitalRead(8);
}
void scoopTask38::loop()
{
int abvarCurrentStatus = digitalRead(8);
if (isABEventTriggered(0, _ABVAR_3_pin_event_8, abvarCurrentStatus))
{
verzoegerung = constrain( ( verzoegerung - 5 ) , 0 , 400 ) ;
sleep(90);
}
_ABVAR_3_pin_event_8 = abvarCurrentStatus;
}
defineTask(scoopTask39)
void scoopTask39::setup()
{
_ABVAR_4_pin_event_6 = digitalRead(6);
}
void scoopTask39::loop()
{
int abvarCurrentStatus = digitalRead(6);
if (isABEventTriggered(1, _ABVAR_4_pin_event_6, abvarCurrentStatus))
{
sleep(verzoegerung);
digitalWrite(9 , HIGH);
digitalWrite(10 , HIGH);
digitalWrite(13 , HIGH);
sleep(70);
digitalWrite(13 , LOW);
digitalWrite(9 , LOW);
digitalWrite(10 , LOW);
sleep(200);
lcd.setCursor(0,0);
lcd.print( "Delay (ms):" );
if (( ( verzoegerung ) > ( 99 ) ))
{
lcd.setCursor(11,0);
lcd.print( verzoegerung );
}
if (( ( verzoegerung ) < ( 99 ) ))
{
lcd.setCursor(12,0);
lcd.print( verzoegerung );
lcd.setCursor(11,0);
lcd.print( "0" );
}
if (( ( verzoegerung ) < ( 9 ) ))
{
lcd.setCursor(13,0);
lcd.print( verzoegerung );
lcd.setCursor(11,0);
lcd.print( "00" );
}
}
_ABVAR_4_pin_event_6 = abvarCurrentStatus;
}
defineTask(scoopTask40)
void scoopTask40::setup()
{
verzoegerung = 0 ;
}
void scoopTask40::loop()
{
digitalWrite(7 , HIGH);
digitalWrite(8 , HIGH);
Serial.print("message");
Serial.print(verzoegerung);
Serial.print(" ");
Serial.println();
}
Pin 6 - Mic
Pin 7 - Taster
Pin 8 - Taster
Pin 9 - LED
Pin 10 - Optokoppler/Kamera
Pin 13 - Pieper
Danke und VG
Leif