Hallo an alle,
ich habe ein Sketch für mein Automaten
[code]
// created by Seafoxc
#include <SoftwareSerial.h>
SoftwareSerial EEBlue(0, 1); // RX | TX
//defining the pins used for each drink, you can changes this depending how you connect the pumps and the drinks.
int Vodka = 2;
int Cointreau = 3;
int CranberryJuice = 4;
int Sprite = 5;
int LemonJuice = 6;
int SugarWater = 7;
int BlueCur = 8;
int Gin = 9;
int Bacardi = 10;
int Weinbrand = 11;
int Cola = 12;
int state = 0;
// how much time there is between switching to the next pump.
int TimeBetweenPours = 500;
void setup()
{
Serial.begin(9600);
Serial.println("The bluetooth gates are open.\n Connect to HC-05 from any other bluetooth device with 1234 as pairing key!");
// Set pin 2-12 to output pins to drive the relay board
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
// My relayboard is a "low true" board. So setting the output to low energize the relay's. You don't want that they all switch on when powering on the cocktailmaker...
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
digitalWrite(11,HIGH);
digitalWrite(12,HIGH);
}
void loop()
{
if(Serial.available() > 0){ // Checks whether data is comming from the serial port
state = Serial.read(); // Reads the data from the serial port
Serial.println(state);
}
// Cocktails:
//Vodka sprite
if (state == 'a') {
Serial.println("Vodka Sprite wird gemacht");
Mix(3000,0,0,0,5000,0,0,0,0,0,0); // Vodka, Triple Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin, Bacardi, Weinbrand, Cola
}
// Blue Lagoon
if (state == 'b') {
Serial.println("Blue Lagoon wird gemacht");
Mix(2000,0,0,5000,1800,1000,1800,0,0,0,0); // Vodka, Triple Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin, Bacardi, Weinbrand, Cola
}
// Cosmo
if (state == 'c') {
Serial.println("Cosmo wird gemacht");
Mix(2500,1500,3800,0,1200,1200,0,0,0,0,0); // Vodka, Triple Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin, Bacardi, Weinbrand, Cola
}
// Lemon drop
if (state == 'd') {
Serial.println("Lemon drop wird gemacht");
Mix(1500,1500,0,0,1800,1200,0,0,0,0,0); // Vodka, Triple Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin, Bacardi, Weinbrand, Cola
}
// Blue Moon
if (state == 'e') {
Serial.println("Blue Moon wird gemacht");
Mix(2000,0,3000,0,1800,1200,1200,0,0,0,0); // Vodka, Triple Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin, Bacardi, Weinbrand, Cola
}
// Blue Gin Moon
if (state == 'f') {
Serial.println("Blue Gin Moon wird gemacht");
Mix(0,0,3000,0,1800,1200,1200,2000,0,0,0); // Vodka, Triple Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin, Bacardi, Weinbrand, Cola
}
// Double Strike
if (state == 'g') {
Serial.println("Double Strike wird gemacht");
Mix(2000,0,3000,0,1800,0,1200,0,0,0,0); // Vodka, Triple Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin, Bacardi, Weinbrand, Cola
}
// Tom Collins
if (state == 'h') {
Serial.println("Tom Collins wird gemacht");
Mix(0,0,0,4000,1800,1800,0,2200,0,0,0); // Vodka, Triple Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin, Bacardi, Weinbrand, Cola
}
// Flying Dutchman
if (state == 'i') {
Serial.println("Flying Dutchman wird gemacht");
Mix(0,2000,0,0,1200,1000,0,2000,0,0,0); // Vodka, Triple Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin, Bacardi, Weinbrand, Cola
}
// London Cosmo
if (state == 'j') {
Serial.println("London Cosmo wird gemacht");
Mix(0,2000,5000,1800,0,0,0,2000,0,0,0); // Vodka, Triple Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin, Bacardi, Weinbrand, Cola
}
// Vodka Cranberry
if (state == 'k') {
Serial.println("Vodka Cranberry wird gemacht");
Mix(2000,0,5000,0,0,1200,0,0,0,0,0); // Vodka, Triple Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin, Bacardi, Weinbrand, Cola
}
// Cranberry Gin
if (state == 'l') {
Serial.println("Cranberry Gin wird gemacht");
Mix(0,0,5000,0,2000,0,0,2200,0,0,0); // Vodka, Triple Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin, Bacardi, Weinbrand, Cola
}
// Bacardi Cola
if (state == 'm') {
Serial.println("Bacardi Cola wird gemacht");
Mix(0,0,0,0,0,0,0,0,1500,0,3000); // Vodka, Triple Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin, Bacardi, Weinbrand, Cola
}
// Weinbrand Cola
if (state == 'n') {
Serial.println("Weinbrand Cola wird gemacht");
Mix(0,0,0,0,0,0,0,0,0,1500,3000); // Vodka, Triple Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin, Bacardi, Weinbrand, Cola
}
// Testin and maintenance options
// Set-up Vodka
if (state == 'o') {
Serial.println("Set-up Vodka");
Mix(1100,0,0,0,0,0,0,0,0,0,0); // Vodka, Triple Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin, Bacardi, Weinbrand, Cola
}
// Set-up Tripple Sec
if (state == 'p') {
Serial.println("Set-up Tripple Sec");
Mix(0,1100,0,0,0,0,0,0,0,0,0); // Vodka, Triple Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin, Bacardi, Weinbrand, Cola
}
// Set-up Cranberry juice
if (state == 'q') {
Serial.println("Set-up Cranberry juice");
Mix(0,0,1000,0,0,0,0,0,0,0,0); // Vodka, Triple Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin, Bacardi, Weinbrand, Cola
}
// Set-up Sprite
if (state == 'r') {
Serial.println("Set-up Sprite");
Mix(0,0,0,1000,0,0,0,0,0,0,0); // Vodka, Triple Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin, Bacardi, Weinbrand, Cola
}
// Set-up Lime juice
if (state == 's') {
Serial.println("Set-up Lime juice");
Mix(0,0,0,0,1100,0,0,0,0,0,0); // Vodka, Triple Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin, Bacardi, Weinbrand, Cola
}
// Set-up Sugar water
if (state == 't') {
Serial.println("Set-up Sugar water");
Mix(0,0,0,0,0,1200,0,0,0,0,0); // Vodka, Triple Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin, Bacardi, Weinbrand, Cola
}
// Set-up Blue curacao
if (state == 'u') {
Serial.println("Set-up Blue curacao");
Mix(0,0,0,0,0,0,800,0,0,0,0); // Vodka, Triple Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin, Bacardi, Weinbrand, Cola
}
// Set-up Gin
if (state == 'v') {
Serial.println("Set-up Gin");
Mix(0,0,0,0,0,0,0,1000,0,0,0); // Vodka, Triple Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin, Bacardi, Weinbrand, Cola
}
// Set-up Bacardi
if (state == 'w') {
Serial.println("Set-up Gin");
Mix(0,0,0,0,0,0,0,0,1000,0,0); // Vodka, Triple Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin, Bacardi, Weinbrand, Cola
}
// Set-up Weinbrand
if (state == 'x') {
Serial.println("Set-up Gin");
Mix(0,0,0,0,0,0,0,0,0,1000,0); // Vodka, Triple Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin, Bacardi, Weinbrand, Cola
}
// Set-up Cola
if (state == 'y') {
Serial.println("Set-up Gin");
Mix(0,0,0,0,0,0,0,0,0,0,1000); // Vodka, Triple Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin, Bacardi, Weinbrand, Cola
}
// Cleaning
if (state == 'z') {
Serial.println("Set-up Gin");
Mix(4000,4000,4000,4000,4000,4000,4000,4000,4000,4000,4000); // Vodka, Triple Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin, Bacardi, Weinbrand, Cola
}
// Set-up all (intial first time after cleaning)
if (state == '{') {
Serial.println("Set-up All");
Mix(800,800,800,800,1000,1600,800,800,800,800,800); // Vodka, Triple Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin, Bacardi, Weinbrand, Cola
}
}
void Mix(int DelayTimeVodka, int DelayTimeCointreau, int DelayTimeCranberryJuice, int DelayTimeSprite, int DelayTimeLemonJuice, int DelayTimeSugarWater, int DelayTimeBlueCur, int DelayTimeGin, int DelayTimeBacardi, int DelayTimeWeinbrand, int DelayTimeCola ) {
state = 0;
delay(800);
digitalWrite(Vodka, LOW);
delay(DelayTimeVodka);
digitalWrite(Vodka, HIGH);
delay(TimeBetweenPours);
digitalWrite(Cointreau, LOW);
delay(DelayTimeCointreau);
digitalWrite(Cointreau, HIGH);
delay(TimeBetweenPours);
digitalWrite(CranberryJuice, LOW);
delay(DelayTimeCranberryJuice);
digitalWrite(CranberryJuice, HIGH);
delay(TimeBetweenPours);
digitalWrite(Sprite, LOW);
delay(DelayTimeSprite);
digitalWrite(Sprite, HIGH);
delay(TimeBetweenPours);
digitalWrite(LemonJuice, LOW);
delay(DelayTimeLemonJuice);
digitalWrite(LemonJuice, HIGH);
delay(TimeBetweenPours);
digitalWrite(SugarWater, LOW);
delay(DelayTimeSugarWater);
digitalWrite(SugarWater, HIGH);
delay(TimeBetweenPours);
digitalWrite(BlueCur, LOW);
delay(DelayTimeBlueCur);
digitalWrite(BlueCur, HIGH);
delay(TimeBetweenPours);
digitalWrite(Gin, LOW);
delay(DelayTimeGin);
digitalWrite(Gin, HIGH);
delay(TimeBetweenPours);
digitalWrite(Bacardi, LOW);
delay(DelayTimeBacardi);
digitalWrite(Bacardi, HIGH);
delay(TimeBetweenPours);
digitalWrite(Weinbrand, LOW);
delay(DelayTimeWeinbrand);
digitalWrite(Weinbrand, HIGH);
delay(TimeBetweenPours);
digitalWrite(Cola, LOW);
delay(DelayTimeCola);
digitalWrite(Cola, HIGH);
delay(TimeBetweenPours);
Serial.println("Cocktail ist fertig!");
state = 0;
}
[/code]
Jetzt habe ich mir MAX7219 mit 8x32x4 LED-Band geholt. Im Sketch ist Serial.print eingetragen. Es soll die einzelnen Cocktails anzeigen und mit ein Effekt versehen werden. Das soll in diesem Sketch oben passieren.
Meine Frage ist ,wie mach ich das dann. Hab da überhaupt kein wirklichen Plan. Habe mir etliche Videos angeschaut und weiss nicht wirklich weiter. Meine Konfiguration ist ein Mega 2650 mit 16-fach Relaiskarte und HC-05 als Bluetooth Anbindung.
Kann man mir da ein wenig helfen?
Danke euch dafür.
Gruß Referent
