1
Vědátorna / Re:graficky lcd display 128x64 encoder menu POMOC
« Poslední příspěvek od KardashianKim kdy Duben 19, 2018, 12:16:04 odpoledne »x4 a tlačítkami cez pin A0 som sa rozhodol postúpiť o čosi ďalej. Te
<?php
$sprava= "Ahoj svet!";
$sprava= wordwrap($msg,70);
mail("adresaprijimatela@jehomail.com","Predmet spravy",$sprava);
?>
#include <SPI.h>
#include <Ethernet.h>
#define Hostname "Arduino"
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
char server[] = "www.mojweb.php5.sk";
IPAddress ip(192, 168, 1, 254);
EthernetClient client;
void setup() {
Serial.begin(9600);
}
void loop() {
if (Ethernet.begin(mac) == 0) {
Serial.println("Chyba konfiguracie cez DHCP, nastavujem pevnu IP");
Ethernet.begin(mac, ip);
}
if (client.connect(server, 80)) {
Serial.println("Pripojenie uspesne na webserver, vykonavam request: ");
client.print("GET /email.php");
client.println(" HTTP/1.1");
client.println("Host: www.mojweb.php5.sk");
client.println("Connection: close");
client.println();
client.stop();
} else {
Serial.println("Pripojenie zlyhalo...");
}
delay(10000);
}
#include <ESP8266WiFi.h>
const char* ssid = "wifimeno";
const char* password = "wifiheslo";
const char* host = "mojweb.php5.sk";
void setup() {
Serial.begin(9600);
Serial.println();
Serial.println();
Serial.print("Pripajam sa na wifi ");
Serial.println(ssid);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void loop() {
WiFiClient client;
const int httpPort = 80;
if (!client.connect(host, httpPort)) {
Serial.println("connection failed");
}
String url = "/email.php";
client.print(String("GET ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");
delay(10000);
}
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
const char* ssid = "wifimeno";
const char* password = "wifiheslo";
const char* host = "mojweb.php5.sk";
const int httpsPort = 443;
const char* fingerprint = "35 85 74 EF 67 35 A7 CE 40 69 50 F3 C0 F6 80 CF 80 3B 2E 19"; //odtlacok sha1 certifikatu
void setup() {
Serial.begin(9600);
Serial.println();
Serial.print("connecting to ");
Serial.println(ssid);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void loop() {
// Use WiFiClientSecure class to create TLS connection
WiFiClientSecure client;
Serial.print("connecting to ");
Serial.println(host);
if (!client.connect(host, httpsPort)) {
Serial.println("connection failed");
return;
}
if (client.verify(fingerprint, host)) {
Serial.println("certificate matches");
} else {
Serial.println("certificate doesn't match");
}
String url = "/email.php";
Serial.print("requesting URL: ");
Serial.println(url);
client.print(String("GET ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"User-Agent: BuildFailureDetectorESP8266\r\n" +
"Connection: close\r\n\r\n");
delay(10000);
}
#include <SPI.h>
#include <MFRC522.h>
#define RST_PIN 9 // Configurable, see typical pin layout above
#define SS_1_PIN 10
#define SS_2_PIN 8
#define NR_OF_READERS 1
byte ssPins[] = {SS_1_PIN, SS_2_PIN};
MFRC522 mfrc522[NR_OF_READERS]; // Create MFRC522 instance.
void setup() {
Serial.begin(9600); // Initialize serial communications with the PC
while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
SPI.begin(); // Init SPI bus
for (uint8_t reader = 0; reader < NR_OF_READERS; reader++) {
mfrc522[reader].PCD_Init(ssPins[reader], RST_PIN); // Init each MFRC522 card
Serial.print(F("Reader "));
Serial.print(reader);
Serial.print(F(": "));
mfrc522[reader].PCD_DumpVersionToSerial();
}
}
/**
* Main loop.
*/
void loop() {
for (uint8_t reader = 0; reader < NR_OF_READERS; reader++) {
// Look for new cards
if (mfrc522[reader].PICC_IsNewCardPresent() && mfrc522[reader].PICC_ReadCardSerial()) {
Serial.print(F("Reader "));
Serial.print(reader);
// Show some details of the PICC (that is: the tag/card)
Serial.print(F(": Card UID:"));
dump_byte_array(mfrc522[reader].uid.uidByte, mfrc522[reader].uid.size);
Serial.println();
Serial.print(F("PICC type: "));
MFRC522::PICC_Type piccType = mfrc522[reader].PICC_GetType(mfrc522[reader].uid.sak);
Serial.println(mfrc522[reader].PICC_GetTypeName(piccType));
// Halt PICC
mfrc522[reader].PICC_HaltA();
// Stop encryption on PCD
mfrc522[reader].PCD_StopCrypto1();
} //if (mfrc522[reader].PICC_IsNewC
} //for(uint8_t reader
}
/**
* Helper routine to dump a byte array as hex values to Serial.
*/
void dump_byte_array(byte *buffer, byte bufferSize) {
for (byte i = 0; i < bufferSize; i++) {
}
Serial.print("Kod:");
unsigned long kod = 10000*buffer[4]+1000*buffer[3]+100*buffer[2]+10*buffer[1]+buffer[0]; //finalny kod karty
Serial.print(kod);
}
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include <MFRC522.h>
#define RST_PIN 9 // Configurable, see typical pin layout above
#define SS_1_PIN 10 // Configurable, take a unused pin, only HIGH/LOW required, must be diffrent to SS 2
#define SS_2_PIN 8 // Configurable, take a unused pin, only HIGH/LOW required, must be diffrent to SS 1
#define NR_OF_READERS 1
byte ssPins[] = {SS_1_PIN, SS_2_PIN};
MFRC522 mfrc522[NR_OF_READERS]; // Create MFRC522 instance.
#define I2C_ADDR 0x3F // Define I2C Address where the PCF8574A is
// Address can be changed by soldering A0, A1, or A2
// Default is 0x27
// map the pin configuration of LCD backpack for the LiquidCristal class
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
LiquidCrystal_I2C lcd(I2C_ADDR,
En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin,
BACKLIGHT_PIN, POSITIVE);
unsigned long kod;
boolean run = false;
boolean run2 = false;
long timer = 0; //The timer
int second = 0;
int minute = 0;
int tenth = 0;
int hour =0;
int second2 = 0;
int minute2 = 0;
int tenth2 = 0;
int hour2 =0;
const int rfrele = 3;
const int gdprele = 4;
const int buzzer = 5;
void setup() {
Serial.begin(9600);
SPI.begin();
pinMode(rfrele,OUTPUT);
pinMode(gdprele,OUTPUT);
pinMode(buzzer,OUTPUT);
for (uint8_t reader = 0; reader < NR_OF_READERS; reader++) {
mfrc522[reader].PCD_Init(ssPins[reader], RST_PIN); // Init each MFRC522 card
Serial.print(F("Reader "));
Serial.print(reader);
Serial.print(F(": "));
mfrc522[reader].PCD_DumpVersionToSerial();
}
lcd.begin(20, 4); // intialise the LCD.
lcd.setBacklight(HIGH); // Turn on backlight, LOW for off
lcd.setCursor(0,0);
lcd.print(" RP2018 DOMINATOR");
lcd.setCursor(0,1);
lcd.print("--------------------");
lcd.setCursor(0,2);
lcd.print("RF 00:00:00");
lcd.setCursor(0,3);
lcd.print("GDP 00:00:00");
}
void tickClock() {
if((timer - millis()/100) >= 100 || timer == 0) {
tick();
tick2();
timer = millis()/100;
}
}
void loop() {
for (uint8_t reader = 0; reader < NR_OF_READERS; reader++) {
if (mfrc522[reader].PICC_IsNewCardPresent() && mfrc522[reader].PICC_ReadCardSerial()) {
Serial.print(F("Reader "));
Serial.print(reader);
// Show some details of the PICC (that is: the tag/card)
Serial.print(F(": Card UID:"));
dump_byte_array(mfrc522[reader].uid.uidByte, mfrc522[reader].uid.size);
Serial.println();
Serial.print(F("PICC type: "));
MFRC522::PICC_Type piccType = mfrc522[reader].PICC_GetType(mfrc522[reader].uid.sak);
Serial.println(mfrc522[reader].PICC_GetTypeName(piccType));
// Halt PICC
mfrc522[reader].PICC_HaltA();
// Stop encryption on PCD
mfrc522[reader].PCD_StopCrypto1();
} //if (mfrc522[reader].PICC_IsNewC
} //for(uint8_t reader
if(kod==4294946665 || kod==23101 || kod==8151 || kod==4294951443 || kod==4294953039 || kod==24519 || kod==4294945657 || kod==3801 || kod==4294945187){
digitalWrite(rfrele, LOW);
digitalWrite(gdprele, HIGH);
run = false;
run2 = true;
}else if(kod==4294956915 || kod==4294958051 || kod==4294961082 || kod==4294960491 || kod==4294958039 || kod==4294958091 || kod==4294946987 || kod==4294961057 || kod==4294959927){
digitalWrite(rfrele, HIGH);
digitalWrite(gdprele, LOW);
run = true;
run2 = false;
}else if(kod==12619){
digitalWrite(rfrele, LOW);
digitalWrite(gdprele, LOW);
run = false;
run2 = false;
}else if(kod==4294962506){
digitalWrite(rfrele, LOW);
digitalWrite(gdprele, LOW);
second = 0;
minute = 0;
tenth = 0;
hour =0;
second2 = 0;
minute2 = 0;
tenth2 = 0;
hour2 =0;
updateLCD();
updateLCD2();
run = false;
run2 = false;
}
tickClock(); //Start ticking the clock
}
void tick() {
if(run) {
updateLCD();
if(tenth == 9) {
tenth = 0;
if(second == 59) {
second = 0;
minute++;
}else {
second++;
}
if(minute == 60) {
minute = 0;
hour++;
}
} else {
tenth++;
}
}
}
void tick2() {
if(run2) {
updateLCD2();
if(tenth2 == 9) {
tenth2 = 0;
if(second2 == 59) {
second2 = 0;
minute2++;
}else {
second2++;
}
if(minute2 == 60) {
minute2 = 0;
hour2++;
}
} else {
tenth2++;
}
}
}
void updateLCD() {
lcd.setCursor(4,2);
if(hour < 10) { // If hour does not have 2 digits
lcd.print("0");
}
lcd.print(hour, DEC);
lcd.print(":");
if(minute < 10) { // If hour does not have 2 digits
lcd.print("0");
}
lcd.print(minute, DEC);
lcd.print(":");
if(second < 10) { // If minute does not have 2 digits
lcd.print("0");
}
lcd.print(second, DEC);
//
}
void updateLCD2() {
lcd.setCursor(4,3);
if(hour2 < 10) { // If hour does not have 2 digits
lcd.print("0");
}
lcd.print(hour2, DEC);
lcd.print(":");
if(minute2 < 10) { // If hour does not have 2 digits
lcd.print("0");
}
lcd.print(minute2, DEC);
lcd.print(":");
if(second2 < 10) { // If minute does not have 2 digits
lcd.print("0");
}
lcd.print(second2, DEC);
}
void dump_byte_array(byte *buffer, byte bufferSize) {
for (byte i = 0; i < bufferSize; i++) {
}
kod = 10000*buffer[4]+1000*buffer[3]+100*buffer[2]+10*buffer[1]+buffer[0];
tone(buzzer, 4000, 100);
Serial.println("Zaznamenany kod karty: ");
Serial.println(kod);
}
boolean run = false;
boolean run2 = false;
if(kod==4294946665 || kod==23101 || kod==8151 || kod==4294951443 || kod==4294953039 || kod==24519 || kod==4294945657 || kod==3801 || kod==4294945187){ // || = operator OR (alebo)
digitalWrite(rfrele, LOW); //vypni diodu/rele pre prvy tim
digitalWrite(gdprele, HIGH); //zapni diodu/rele pre druhy tim
run = false; //zastav cas prveho timu
run2 = true; //spust cas druheho timu