Hello Delta
The pin 7 goes directly to the relais board... so i can not limit the current there... all other circuilt ar limited with resistors. and the external power on vin is 12vdc 1amp...
the code is down there..
/*
Web client
This sketch connects to a website (http://www.google.com)
using an Arduino Wiznet Ethernet shield.
Circuit:
* Ethernet shield attached to pins 10, 11, 12, 13
created 18 Dec 2009
by David A. Mellis
modified 9 Apr 2012
by Tom Igoe, based on work by Adrian McEwen
*/
//#include <WiFi.h>
#include <Arduino_GigaDisplay.h>
#include <Arduino_GigaDisplay_GFX.h>
#include <lvgl.h>
//#include <SPI.h>
#include <Ethernet.h>
#include <USBHostGiga.h>
/* Start Keyboard and Serial Communication */
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
/* Variables needed during processing */
String ku_lock = "True";
String ku_name = "";
String ku_result = "";
String ku_rest = "";
int ku_prg = 0;
unsigned long t_start, t_end;
unsigned long timer_1, timer_2;
/* Start Keyboard and Serial Communication */
Keyboard keyb; // create the object
HostSerial ser; // create the object
GigaDisplay_GFX display; // create the object
// ---------- Ethernet Config ---------- //
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 0, 78);
IPAddress myDns(8, 8, 8, 8);
// ---------- WiFi Config -------------- //
//char ssid[] = "Fragilia"; // your network SSID (name)
//char pass[] = "Markus_Barbara1"; // your network password (use for WPA, or use as key for WEP)
//int status = WL_IDLE_STATUS; // the WiFi radio's status
EthernetClient client;
//WiFiClient wclient;
// ---------- Server Config ---------- //
char server[] = "www.breitenstein.ag"; // name address for Google (using DNS)
unsigned long beginMicros, endMicros;
unsigned long byteCount = 0;
bool printWebData = true; // set to false for better speed measurement
String rfid; // string for the RFID
bool rfid_ok = false; // boolean for RFID validation
int count = 1; // counter for Keyboard
int runonce = 0; // value 0 ist a onetimer inside the loop
String text = ""; // text for print function
/* PIN declaration */
int wash = 6 ; //Relais 3 Pin
int lift = 7 ; //Relais 4 Pin
void setup() {
/* PIN declaration */
pinMode(6, OUTPUT); // Relais Waschen
pinMode(7, OUTPUT); // Relais Lift
pinMode(22, INPUT); // Input Programm 1
pinMode(24, INPUT); // Input Programm 2
pinMode(23, INPUT); // Input Start
pinMode(25, INPUT); // Input Stop
pinMode(28, OUTPUT); // LED BLAU
// Open serial communications and wait for port to open:
Serial.begin(115200);while (!Serial) { ; } // wait for serial port to connect. Needed for native USB port only
display.begin(); // enable display
display.fillScreen(BLACK); // display backcolor
display.setRotation(3); // display rotation
display.setTextSize(4); // display text size
pinMode(PA_15, OUTPUT); // enable keyboard on USB A
keyb.begin(); // start keyboard scanner
ser.begin(); // start serial communication on ethernet shield
// start th wifi connection
// if (WiFi.status() == WL_NO_MODULE) { Serial.println("Communication with WiFi module failed!"); display.println("Communication with WiFi module failed!"); while (true); }
// while (status != WL_CONNECTED) { Serial.print("Attempting to connect SSID: "); Serial.println(ssid); display.print("Attempting to connect SSID: "); display.println(ssid); status = WiFi.begin(ssid, pass); delay(1000); }
// start the Ethernet connection:
Serial.println("Initialize Ethernet with DHCP:");
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// Check for Ethernet hardware present
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
Serial.println("Ethernet shield was not found. Sorry, can't run without hardware. :(");
while (true) {
delay(1); // do nothing, no point running without Ethernet hardware
}
}
if (Ethernet.linkStatus() == LinkOFF) {
Serial.println("Ethernet cable is not connected.");
}
Ethernet.begin(mac, ip, myDns); // try to congifure using IP address instead of DHCP:
} else {
display.print("DHCP assigned IP ");
display.println(Ethernet.localIP());
}
// give the Ethernet shield a second to initialize:
delay(1000);
if (client.connect(server, 80)) {
Serial.print("connected to ");
Serial.println(client.remoteIP());
// Make a HTTP request:
client.println("GET /search?q=arduino HTTP/1.1");
client.println("Host: www.google.com");
client.println("Connection: close");
client.println();
Serial.println("connection ok");
} else {
// if you didn't get a connection to the server:
Serial.println("connection failed");
}
beginMicros = micros();
Serial.println("start loop");
digitalWrite(28, HIGH);
display.fillScreen(BLACK);
display.setTextColor(WHITE);
display.setTextSize(4);
display.setCursor(30, 200); display.println("Halten Sie bitte die RFID");
display.setCursor(30, 270); display.println("an den Sensor.");
}
void loop() {
while (ku_lock == "True"){
if (rfid.length() <= 8) {
if (keyb.available()) {
for (int count = 1; count < 22; count ++){
auto _key = keyb.read();
if (keyb.getAscii(_key) != NULL) {
if (pow(-1,count) <= 0){
rfid += keyb.getAscii(_key);
Serial.println(count);
delay(30);
}
}
}
rfid=rfid.substring(0,8); Serial.println(rfid); display.println(rfid);
if (rfid.length()>=8) { RFID_Check(); }
}
}
} // Lesen der RFID
if (digitalRead(22) == HIGH) { ku_prg = 1; PRG_1_START(); }
if (digitalRead(24) == HIGH) { ku_prg = 2; PRG_2_START(); }
while (ku_prg != 0 ){
while ((micros() - 300000) <= timer_1 ){
for (int i = 1; i <= 11; i ++){
delay(250);
digitalWrite(28, LOW);
delay(250);
digitalWrite(28, HIGH);
}
}
ku_prg = 0;
}
}
void PRG_1_START(){
display.fillScreen(GREEN);
display.setTextColor(BLACK);
display.setTextSize(5);
display.setCursor(20, 20); display.println("Programm 1 gewählt");
display.setCursor(20, 200); display.println("Sie haben 10 Minuten Zeit,");
display.setCursor(20, 260); display.println("den Startknopf zu drücken.");
timer_1 = micros();
} // Bildschirm Programm 1
void PRG_2_START(){
display.fillScreen(GREEN);
display.setTextColor(BLACK);
display.setTextSize(5);
display.setCursor(20, 20); display.println("Programm 2 gewählt");
display.setCursor(20, 200); display.println("Sie haben 10 Minuten Zeit,");
display.setCursor(20, 260); display.println("den Startknopf zu drücken.");
timer_1 = micros();
} // Bildschirm Programm 2
void PRG_1(){
t_start = micros();
display.fillScreen(GREEN);
display.setTextColor(BLACK);
display.setTextSize(5);
display.setCursor(10, 10); display.println("Programm 1 gestartet");
if (client.connect(server, 80)) { // if you get a connection, report back via serial:
String str = "insert into WASCHEN (KU_RFID, WA_DATUM, WA_START) values ('" + rfid +"', GETDATE(), CURRENT_TIMESTAMP)"; //rfid.substring(0,8);
str.replace(" ", "%20");
str.replace("'", "%27");
client.println("GET /SQL.aspx?tell=" + str + " HTTP/1.1");
client.println("Host: www.breitenstein.ag");
client.println("Connection: close");
client.println();
}
for (int i = 1; i <= 11; i ++){
delay(500);
digitalWrite(28, LOW);
delay(500);
digitalWrite(28, LOW);
}
delay(10000);
display.fillScreen(BLACK);
display.setTextColor(WHITE);
display.setTextSize(4);
display.setCursor(10, 10); display.println("Ich warte auf eine Eingabe");
ku_lock = "True";
rfid="";
if (client.connect(server, 80)) { // if you get a connection, report back via serial:
String str = "update WASCHEN set WA_ENDE = CURRENT_TIMESTAMP WHERE (WA_ID = (select MAX(WA_ID) from WASCHEN))"; //rfid.substring(0,8);
str.replace(" ", "%20");
str.replace("'", "%27");
client.println("GET /SQL.aspx?tell=" + str + " HTTP/1.1");
client.println("Host: www.breitenstein.ag");
client.println("Connection: close");
client.println();
}
digitalWrite(28, HIGH);
}
void PRG_2(){
display.fillScreen(GREEN);
display.setTextColor(BLACK);
display.setTextSize(5);
display.setCursor(10, 10); display.println("Programm 2 gestartet");
for (int i = 1; i <= 11; i ++){
delay(500);
digitalWrite(32, LOW);
digitalWrite(36, HIGH);
delay(500);
digitalWrite(32, HIGH);
digitalWrite(36, LOW);
}
display.fillScreen(BLACK);
display.setTextColor(WHITE);
display.setTextSize(4);
display.setCursor(10, 10); display.println("Ich warte auf eine Eingabe");
ku_lock = "True";
rfid="";
digitalWrite(28, LOW);
digitalWrite(32, HIGH);
digitalWrite(36, LOW);
}
void RFID_Check(){
String readString, readString1;
int x=0; //for counting line feeds
char lf=10; //line feed character
if (client.connect(server, 80)) { // if you get a connection, report back via serial:
String str = "Select%20*%20from%20KUNDE%20where%20(KU_RFID%20='" + rfid.substring(0,8) +"')"; //rfid.substring(0,8);
display.fillScreen(BLACK);
display.setTextColor(WHITE);
display.setCursor(0, 0);
display.print("send request to server: "); display.println(client.remoteIP());
client.println("GET /SQL.aspx?ask=" + str + " HTTP/1.1");
client.println("Host: www.breitenstein.ag");
client.println("Connection: close");
client.println();
delay(2000);
} else {
// if you didn't get a connection to the server:
display.println("connection failed");
}
if (client.connect(server, 80)) { // if you get a connection, report back via serial:
display.print("load file server: "); display.println(client.remoteIP());
client.println("GET /ASK.txt HTTP/1.1");
client.println("Host: www.breitenstein.ag");
client.println("Connection: close");
client.println();
}
while(client.connected() && !client.available()) delay(1); //waits for data
while (client.connected() || client.available()) { //connected or data available
char c = client.read(); //gets byte from ethernet buffer
if ( c == lf ) {x=x+1;}
if ( x >=10 ) {if ( c != lf) {ku_result += c;}} //building readString
}
client.stop(); //stop client
//ku_result to single strings
ku_lock = ku_result.substring(0, ku_result.indexOf(" "));
ku_lock.trim();
ku_name = ku_result.substring(ku_result.indexOf(" ")+1);
Serial.println(ku_result);
Serial.println(ku_lock);
Serial.println(ku_name);
ku_result= "";
if (ku_lock == "False"){
display.fillScreen(GREEN);
display.setTextColor(BLACK);
display.setTextSize(4);
display.setCursor(10, 10); display.println("Willkommen");
display.setCursor(10, 50); display.println(ku_name);
display.setCursor(10, 110); display.println("Programme:");
display.setCursor(10, 170); display.println("1 Nur Waschen");
display.setCursor(10, 210); display.println("2 Waschen mit Lift");
digitalWrite(28, HIGH);
}
else
{
display.fillScreen(YELLOW);
display.setTextColor(BLACK);
display.setTextSize(4);
display.setCursor(10, 10); display.println("Willkommen");
display.setCursor(10, 50); display.println(ku_name);
display.setCursor(10, 110); display.println("Die Karte ist nicht aktiviert.");
display.setCursor(10, 200); display.println("Melden Sie sich bei unserem");
display.setCursor(10, 250); display.println("Werkstattpersonal.");
digitalWrite(28, HIGH);
/* 10 sekunden warten, dann wieder auf Startbidlschirm */
delay(10000);
display.fillScreen(BLACK);
display.setTextColor(WHITE);
display.setTextSize(4);
display.setCursor(30, 200); display.println("Halten Sie bitte die RFID");
display.setCursor(30, 270); display.println("an den Sensor.");
ku_lock = "True";
rfid="";
}
}