Moin moin,
habe letzten hier schon ein post gemacht der mich auch schon ein stück weiter gebracht hat.
Ich bin nun wieder auf ein Problem gestoßen und versuche nun mein vorhaben ein wenig Genauer zu beschreiben.
Zum Projekt:
Ich baue gerade an einer Cocktailmaschine, ich habe dafür 5 Schlauchpumpen besorgt die ich nun mit Transistoren über den Arduino ansteuern möchte. Soweit so gut.
Zum Problem:
Ich habe nun in den Arduino über ein Array, ein Rezept eingespeichert(sollen später mehr werden.).
ich möchte nun wenn ein Knopf gedrückt wird der für ein Rezept steht eine Funktion aufgerufen(angedeutet mit der Funktion void pump, welche bis jetzt nur die zeit ausrechnet.) mit dem Rezept als Parameter. Soweit auch kein problem, aber die pumpen müssen jetzt unterschiedlich lange, möglichst gleichzeitig gesteuert werden.
Kann mir da wer helfen?
//Edit:
Ich weiss ich bin kein programmier Profi, können also Fehler vorkommen.
Zum Code:
//BoozeBot by Torben Friedel (2015)
// This is a program for a Cocktail bot. It consists of 5
// peristaltic pumps(12V).
//
const int pumps = 5; //Number of Pumps
int pumpPins[pumps] = {1,2,3,4,5};//Pins of the pumps (erstmal nur ein Platzhalter)
float plantersPunch[pumps] = {1.5, 2.0, 5.0, 1.3,0.0};//First Cockail amount of each liquid in mL(auch nur Platzhalter und nicht repräsentativ)
float timings[pumps];//for the individual time each pump needs for the ingredient
bool pStatus[pumps] = {0,0,0,0,0,}; //Status of each pump if its on or of(kann überflüssig sein)
const float timing = 2.5 ; //The time the pump needs to dispense 1 ml.
void setup() {
Serial.begin(9600);
}
void pump(float cocktail[pumps])
{
//Calculate time needed for the pump to pump the liquid and stored in array timings
for(int i = 0; i <= pumps; i++)
{
float Time = (cocktail[i]/timing)*1000 ;
Serial.println("");//New Line for a better overview
Serial.println(i);//current loop count
Serial.println(Time);//the time calculated in millis on line 25
long currentMillis = millis();
timings[i] = Time;
}
for(int i = 0; i <= pumps; i++)
{
if(pStatus[i] == 0)
{
}
}
memset(timings, 0,sizeof(timings));
}
void loop() {
pump(plantersPunch);
delay(2000);
}