toegang registratie

Arduino specifieke Software
Gebruikers-avatar
Berichten: 9
Geregistreerd: 22 Feb 2020, 14:07
Woonplaats: Hellevoetsluis, The Netherlands

Re: toegang registratie

Berichtdoor wendy2112 » 27 Feb 2020, 11:07

Koepel schreef:Ieder heeft zo zijn eigen stijl van de tekst.
Ik hou van open en ruim: https://gist.github.com/Koepel/f7d625a6e5c0481fc4c7a9c530c643ef.
Anderen schrijven het meer compact.

Het onderste deel van jouw sketch is het een beetje té compact ;)
Het gaat erom dat je aan de sketch kunt zien wat er gebeurt, en dat je eenvoudig iets kunt wijzigen. Als je daarvoor meerdere statements op één regel zet, dan is dat natuurlijk prima.

Je hoeft niet meteen de EEPROM toe te voegen, je kunt eerst een test-sketch maken om de EEPROM te proberen.
Er is EEPROM.write() en EEPROM.read() die maar één byte doen.
Er is ook EEPROM.put() en EEPROM.get() die een hele variabele doen, ongeacht hoeveel byte dat wordt.

Arduino Reference: https://www.arduino.cc/en/Reference/EEPROM.



Het lukt mij niet om de eeprom te lezen/printen. Wil je nog even naar mijn laatste sketch kijken svp?

cpp code
#include <EEPROM.h>

#include <Adafruit_GFX.h>
#include <Adafruit_SPITFT.h>
#include <Adafruit_SPITFT_Macros.h>
#include <gfxfont.h>

#include <FreeDefaultFonts.h>
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;
#include <TFT_HX8357GLUE.h>
#include <UTFTGLUE.h>
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define BLACK 0x0000
#define WHITE 0xFFFF
#define GREY 0x8410
#define BLUE 0x001F
#define ORANGE 0xFA60
#define AQUA 0x04FF
#define PINK 0xF8FF
int groen = 22;
int wit = 24;
int rood = 26;
int x1 = 30;
int x2 = 31;
int x3 = 32;
int x4 = 33;
int y1 = 34;
int y2 = 35;
int y3 = 36;

int a = -1;
int b = -1;
int c = -1;
int d = -1;
int aanwezig = 0;
int f = 123456;

void setup() {



uint16_t ID = tft.readID();
if (ID == 0xD3) ID = 0x9481;
tft.begin(ID);
tft.setRotation(-45);
tft.setTextSize(3);
tft.setTextColor(CYAN);


Serial.begin(9600);
pinMode(x1, OUTPUT);
pinMode(x2, OUTPUT);
pinMode(x3, OUTPUT);
pinMode(x4, OUTPUT);
pinMode(y1, INPUT);
pinMode(y2, INPUT);
pinMode(y3, INPUT);
pinMode(groen, OUTPUT);
pinMode(wit, OUTPUT);
pinMode(rood, OUTPUT);

}

void loop() {

digitalWrite(groen, LOW);
digitalWrite(rood, LOW);
digitalWrite(wit, HIGH);

tft.fillScreen(BLACK);


digitalWrite (x2, LOW); digitalWrite(x3, LOW); digitalWrite (x4, LOW); digitalWrite (x1, HIGH);
y1 = digitalRead(34);
if (y1 == HIGH)
{
if (a == -1)
{
a = 1000;
b = 99;
}
else if (b == -1)
{
b = (a) + 100;
c = 99;
}
else if (c == -1)
{
c = (b) + 10;
d = 99;
}
else if (d == -1)
{
d = (c) + 1;
}
}
y2 = digitalRead(35);
if (y2 == HIGH)
{
if (a == -1)
{
a = 2000;
b = 99;
}
else if (b == -1)
{ b = (a) + 200;
c = 99;
}
else if (c == -1)
{
c = (b) + 20;
d = 99;
}
else if (d == -1) {
d = (c) + 2;
}
}

y3 = digitalRead(36);
if (y3 == HIGH)
{
if (a == -1)
{
a = 3000;
b = 99;
}
else if (b == -1)
{
b = (a) + 300;
c = 99;
}
else if (c == -1)
{
c = (b) + 30;
d = 99;
}
else if (d == -1)
{
d = (c) + 3;
}
}


digitalWrite (x1, LOW); digitalWrite (x3, LOW); digitalWrite (x4, LOW); digitalWrite (x2, HIGH);

y1 = digitalRead(34);
if (y1 == HIGH)
{
if (a == -1)
{
a = 4000;
b = 99;
}
else if (b == -1)
{
b = (a) + 400;
c = 99;
}
else if (c == -1)
{
c = (b) + 40;
d = 99;
}
else if (d == -1)
{
d = (c) + 4;
}
}

y2 = digitalRead(35);
if (y2 == HIGH)
{
if (a == -1)
{
a = 5000;
b = 99;
}
else if (b == -1)
{
b = (a) + 500;
c = 99;
}
else if (c == -1)
{
c = (b) + 50;
d = 99;
}
else if (d == -1)
{
d = (c) + 5;
}
}

y3 = digitalRead(36);
if (y3 == HIGH)
{
if (a == -1)
{
a = 6000;
b = 99;
}
else if (b == -1)
{
b = (a) + 600;
c = 99;
}
else if (c == -1)
{
c = (b) + 60;
d = 99;
}
else if (d == -1)
{
d = (c) + 6;
}
}


digitalWrite (x1, LOW); digitalWrite (x2, LOW); digitalWrite (x4, LOW); digitalWrite (x3, HIGH);

y1 = digitalRead(34);
if (y1 == HIGH)
{
if (a == -1)
{
a = 7000;
b = 99;
}
else if (b == -1)
{
b = (a) + 700;
c = 99;
}
else if (c == -1)
{
c = (b) + 70;
d = 99;
}
else if (d == -1)
{
d = (c) + 7;
}
}

y2 = digitalRead(35);
if (y2 == HIGH)
{
if (a == -1)
{
a = 8000;
b = 99;
}
else if (b == -1)
{
b = (a) + 800;
c = 99;
}
else if (c == -1)
{
c = (b) + 80;
d = 99;
} else if (d == -1)
{
d = (c) + 8;
}
}

y3 = digitalRead(36);
if (y3 == HIGH)
{ if (a == -1)
{
a = 9000;
b = 99;
}
else if (b == -1)
{
b = (a) + 900;
c = 99;
}
else if (c == -1)
{
c = (b) + 90;
d = 99;
}
else if (d == -1)
{
d = (c) + 9;
}
}

digitalWrite (x1, LOW); digitalWrite (x2, LOW); digitalWrite (x3, LOW); digitalWrite (x4, HIGH);
y1 = digitalRead(34);

if (y1 == HIGH)
{
a = -1;
b = -1;
c = -1;
d = -1;
}
/* if(a==-1)
{
a=0000;
b=99;
}
else if(b==-1)
{
b=(a)+000;
c=99;
}
else if(c==-1)
{
c=(b)+00;
d=99;
}
else if(d==-1)
{
d=(c)+0;
}*/



y2 = digitalRead(35);
if (y2 == HIGH)
{
if (a == -1)
{
a = 0000;
b = 99;
}
else if (b == -1)
{
b = (a) + 000;
c = 99;
}
else if (c == -1)
{
c = (b) + 00;
d = 99;
} else if (d == -1)
{
d = (c) + 0;
}
}

y3 = digitalRead(36);
if (y3 == HIGH)
{
if (a == -1)
{
a = 0000;
b = 99;
}
else if (b == -1)
{
b = (a) + 000;
c = 99;
} else if (c == -1)
{
c = (b) + 00;
d = 99;
}
else if (d == -1)
{
d = (c) + 0.1;
}
}


if (a == 99)
{
a = -1;
} if (b == 99)
{
b = -1;
}
if (c == 99)
{
c = -1;
}
if (d == 99)
{
d = -1;
}


tft.setCursor(50, 100);
tft.print("VOER CODE IN");
tft.setCursor( 120, 140);
if (a >= 0)
{
tft.print("*");
}
if (b >= 0)
{
tft.print("*");
}

if (c >= 0)
{
tft.print("*");
}

if (d >= 0)
{
tft.print("*");
}



if (d == 5109)
{ digitalWrite(rood, LOW); digitalWrite(wit, LOW); digitalWrite(groen, HIGH); tft.fillScreen(BLACK); tft.setTextColor(GREEN);
tft.setCursor(20, 80);
tft.print("WELKOM"); tft.setCursor(20, 120); tft.print("mevr. M.A. Lange"); tft.setTextColor(CYAN);
EEPROM.put(aanwezig,d);
for (int aanwezig = 0;
aanwezig < 255;
aanwezig++)
EEPROM.get(aanwezig,f);
Serial.println(f,3);
delay(10000); a = -1; b = -1; c = -1; d = -1;
}
if (d == 5104) {
digitalWrite(rood, LOW); digitalWrite(wit, LOW); digitalWrite(groen, HIGH);
tft.fillScreen(BLACK); tft.setTextColor(GREEN); tft.setCursor(10, 80);
tft.print("WELKOM"); tft.setCursor(10, 120); tft.print("hr.van Staveren"); tft.setTextColor(CYAN);
EEPROM.put(aanwezig,d);
for (int aanwezig = 0;
aanwezig < 255;
aanwezig++)
EEPROM.get(aanwezig,f);
Serial.println(f,3);
Serial.println();
delay(10000); a = -1; b = -1; c = -1; d = -1;
}
if (d == 7307) {
digitalWrite(rood, LOW); digitalWrite(wit, LOW); digitalWrite(groen, HIGH);
tft.fillScreen(BLACK); tft.setTextColor(GREEN); tft.setCursor(20, 80);
tft.print("WELKOM"); tft.setCursor(20, 120); tft.print("fam. van Staveren"); tft.setTextColor(CYAN);
delay(10000); a = -1; b = -1; c = -1; d = -1;
}

if (d == 1111) {
digitalWrite(rood, LOW); digitalWrite(wit, LOW); digitalWrite(groen, HIGH);
tft.fillScreen(BLACK); tft.setTextColor(GREEN); tft.setCursor(20, 80);
tft.print("WELKOM"); tft.setCursor(20, 120); tft.print("gast 1"); tft.setTextColor(CYAN);
delay(10000); a = -1; b = -1; c = -1; d = -1;
}
if (d == 2222) {
digitalWrite(rood, LOW); digitalWrite(wit, LOW); digitalWrite(groen, HIGH);
tft.fillScreen(BLACK); tft.setTextColor(GREEN); tft.setCursor(20, 80);
tft.print("WELKOM"); tft.setCursor(20, 120); tft.print("gast 2"); tft.setTextColor(CYAN);
delay(10000); a = -1; b = -1; c = -1; d = -1;
}
if (d == 3333) {
digitalWrite(rood, LOW); digitalWrite(wit, LOW); digitalWrite(groen, HIGH);
tft.fillScreen(BLACK); tft.setTextColor(GREEN); tft.setCursor(20, 80);
tft.print("welkom"); tft.setCursor(20, 120); tft.print("gast 3"); tft.setTextColor(CYAN);
delay(10000); a = -1; b = -1; c = -1; d = -1;
}

else if (d >= 0) {
digitalWrite(rood, HIGH); digitalWrite(wit, LOW); digitalWrite(groen, LOW);
tft.fillScreen(BLACK); tft.setTextColor(RED); tft.setCursor(0, 80);
tft.print("onbekende code"); tft.setCursor(0, 120); tft.print("geen toegang"); tft.setTextColor(CYAN);
delay(5000); a = -1; b = -1; c = -1; d = -1;
}



}

Advertisement

Berichten: 4067
Geregistreerd: 16 Okt 2013, 14:31
Woonplaats: s hertogenbosch

Re: toegang registratie

Berichtdoor shooter » 28 Feb 2020, 11:13

eerst het adres en dan pas de variabele, en je moet precies bijhouden waar je wat neerschrijft, want het zijn bytes en geen int.
paul deelen
shooter@home.nl

Gebruikers-avatar
Berichten: 9
Geregistreerd: 22 Feb 2020, 14:07
Woonplaats: Hellevoetsluis, The Netherlands

Re: toegang registratie

Berichtdoor wendy2112 » 28 Feb 2020, 11:21

Het adres van mij is "aanwezig" en de variabele bij put is "d" en by get is dat "f". Of zit ik nu helemaal verkeerd??
Ik snap die voorbeeld sketches met:

struct MyObject {
float field1;
byte field2;
char name[10];

Helemaal niet, maar ik ben ook maar een beginneling.......

Vorige

Terug naar Arduino software

Wie is er online?

Gebruikers in dit forum: uwutijovigef en 8 gasten