ich möchte gerne ein Überdruck und Unterdruck erzeugen mit einer minipumpe. Für die Schaltung habe ich zwei 3/2wegeventil (eklektrisch) und für die Messung von Druck ein analoger drucksensor. Auf dem Arduino habe ich relais modul angebracht, jede relais steht für ventil, motor und meldeleuchte. Meine Frage ist, ob der Code die ich erstellt habe, richtig ist? oder ob das nicht Arduino sprache ist. Habe wenig erfahrung mit Arduino.
#include "SmartDelay.h"
SmartDelay::SmartDelay(unsigned long tick) {
smMicros = tick;
state = SMART_DELAY_START;
}
int SmartDelay::Now() {
unsigned long mcs = micros();
// Важно помнить про переполнение целого!
if (mcs - smLast < smMicros)
return false;
smLast = mcs;
return (state == SMART_DELAY_START);
}
unsigned long SmartDelay::Get() const {
return smMicros;
}
unsigned long SmartDelay::Set(unsigned long tick) {
unsigned long old = smMicros;
smMicros = tick;
return old;
}
unsigned long SmartDelay::Wait() {
unsigned long old = smMicros;
smLast = micros();
return old;
}
unsigned long SmartDelay::Reset() {
unsigned long old = smMicros;
smLast = 0; // про переполнение целого помнить!
return old;
}
unsigned long SmartDelay::Start() {
unsigned long old = smMicros;
state = SMART_DELAY_START;
return old;
}
unsigned long SmartDelay::Stop() {
unsigned long old = smMicros;
state = SMART_DELAY_STOP;
return old;
}
// OOP methods
void SmartDelay::run() {
if (Now()) Process();
}
void SmartDelay::Process() {}
// end of Smart Delay class definition
Mit Ehrlichkeit kommst Du hier definitiv eher weiter... Ich glaube nicht dass das Dein Code ist, oder bist Du "Link", und hast die Fähigkeiten unterwegs verloren!?
Und mit Code Tags war so etwas hier gemeint und kein Anhang:
#include "SmartDelay.h"
SmartDelay::SmartDelay(unsigned long tick) {
smMicros = tick;
state = SMART_DELAY_START;
}
int SmartDelay::Now() {
unsigned long mcs = micros();
// Важно помнить про переполнение целого!
if (mcs - smLast < smMicros)
return false;
smLast = mcs;
return (state == SMART_DELAY_START);
}
unsigned long SmartDelay::Get() const {
return smMicros;
}
unsigned long SmartDelay::Set(unsigned long tick) {
unsigned long old = smMicros;
smMicros = tick;
return old;
}
unsigned long SmartDelay::Wait() {
unsigned long old = smMicros;
smLast = micros();
return old;
}
unsigned long SmartDelay::Reset() {
unsigned long old = smMicros;
smLast = 0; // про переполнение целого помнить!
return old;
}
unsigned long SmartDelay::Start() {
unsigned long old = smMicros;
state = SMART_DELAY_START;
return old;
}
unsigned long SmartDelay::Stop() {
unsigned long old = smMicros;
state = SMART_DELAY_STOP;
return old;
}
// OOP methods
void SmartDelay::run() {
if (Now()) Process();
}
void SmartDelay::Process() {}
// end of Smart Delay class definition