Home Code Display

Code Display

The display receives instructions from the hub.
Subjective display:

/*
Display Code (subjective display)

Part of a Master's thesis project
"Designing and evaluating an energy consumption competition"

Author: Stijn Coppens
Date: 2012-03-05

The display receives instructions from the hub and uses those to visualize the energy
consumption of the competitors
*/

// EtherCard Library by Jean-Claude Wippler and Andrew Lindsay
// JeeLib Library by Jean-Claude Wippler
//--------------------------------------------------------------------------------------
int sentence = 0;
#include //https://github.com/jcw/jeelib
#include

#define MYNODE 50 // node ID 50 reserved for display
#define freq RF12_433MHZ // frequency
#define group 113 // network group

unsigned long lastRF; // used to check for RF recieve failures
unsigned long update_instruction; // Used to count time for slow 10s events
int RFerror=0; //RF error flag - high when no data received
int led = 13;

// define structure of the packages that are received via RF (from the Hub)
typedef struct{
char instruction [50]; // instruction (from the nanode)
} PayloadDisp;
PayloadDisp Display;

// buttons
const int buttonLeft = 4; // the number of the left pushbutton pin (previous)
const int buttonRight = 3; // the number of the right pushbutton pin (next)
int Left = 0;
int Right = 0;

int SER_Pin = 5; //pin 14 on the 75HC595
int RCLK_Pin = 6; //pin 12 on the 75HC595
int SRCLK_Pin = 7; //pin 11 on the 75HC595

//How many of the shift registers - change this
#define number_of_74hc595s 5
#define numOfRegisterPins number_of_74hc595s * 8
boolean registers[numOfRegisterPins];

void setup () {
Serial.begin(9600);
rf12_initialize(MYNODE, freq,group);
lastRF = millis()-40000; // setting lastRF back 40s is useful as it forces the code to run straight away

pinMode(SER_Pin, OUTPUT);
pinMode(RCLK_Pin, OUTPUT);
pinMode(SRCLK_Pin, OUTPUT);

pinMode(buttonLeft, INPUT);
pinMode(buttonRight, INPUT);

//reset all register pins
clearRegisters();
writeRegisters();
}

//set all register pins to LOW
void clearRegisters(){
for(int i = numOfRegisterPins - 1; i >= 0; i--){
setRegisterPin(i, LOW);

}
}

//Set and display registers
//Only call AFTER all values are set how you would like (slow otherwise)
void writeRegisters(){

digitalWrite(RCLK_Pin, LOW);

for(int i = numOfRegisterPins - 1; i >= 0; i--){
digitalWrite(SRCLK_Pin, LOW);
int val = registers[i];
digitalWrite(SER_Pin, val);
digitalWrite(SRCLK_Pin, HIGH);

}
digitalWrite(RCLK_Pin, HIGH);

}

//set an individual pin HIGH or LOW
void setRegisterPin(int index, int value){
registers[index] = value;
}

void loop () {

// if an instruction is received:
if (rf12_recvDone() && rf12_crc == 0 && (rf12_hdr & RF12_HDR_CTL) == 0)
{
Display=*(PayloadDisp*) rf12_data; // Get the payload for the display
RFerror=0; //reset RF error flag

String New = Display.instruction;
int length = New.length();

if (length > 1){
Serial.println("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
Serial.print("New instruction received: ");
Serial.println(Display.instruction); // print the complete instruction

char *p = Display.instruction;
char *str;
while ((str = strtok_r(p, ";", &p)) != NULL) // delimiter is the semicolon
{
storePart(str);
}

}

lastRF = millis(); // reset lastRF timer
#ifdef DEBUG
Serial.println("RF recieved");
#endif
}

// If no data is recieved from rf12 module the server is updated every 30s with RFfail = 1 indicator for debugging
if ((millis()-lastRF)>30000)
{
lastRF = millis(); // reset lastRF timer
Serial.println("no data received in the last 30 seconds"); // No RF received in 30 seconds so send failure
RFerror=1;
}

// update the sentence
if ((millis()-update_instruction)>15000)
{
update_instruction = millis();
DisplayNext();
}

// read the state of the pushbutton value:
Left = digitalRead(buttonLeft);
Right = digitalRead(buttonRight);

// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (Left == HIGH) {
Serial.println("Left is pressed");
delay(300);
DisplayPrevious();
}

if (Right == HIGH) {
Serial.println("Right is pressed");
delay(300);
DisplayNext();
Serial.print("sentence: ");Serial.println(sentence);
}

} // end loop


// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// VARIABLES
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

int int_A = 0;
int int_B = 0;
int int_C = 0;
int int_D = 0;
int int_E = 0;
int int_F = 0;
int int_G = 0;
int int_H = 0;
int int_I = 0;
int int_J = 0;
int int_K = 0;
int int_L = 0;

// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// STORE RECEIVING STRING IN DIFFERENT PARTS
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

void storePart(String str){
// Check if it starts with an 'A'
if (str.charAt(0) == 'A') {
Serial.print("instruction_A is: ");
String instruction_A = str.substring(1,str.length()); // remove first character and store the rest in the variable
Serial.println(instruction_A);
char this_char[instruction_A.length() + 1];
instruction_A.toCharArray(this_char, sizeof(this_char));
int_A = atoi(this_char);
}

// Check if it starts with a 'B'
if (str.charAt(0) == 'B') {
Serial.print("instruction_B is: ");
String instruction_B = str.substring(1,str.length()); // remove first character and store the rest in the variable
Serial.println(instruction_B);
char this_char[instruction_B.length() + 1];
instruction_B.toCharArray(this_char, sizeof(this_char));
int_B = atoi(this_char);
}

if (str.charAt(0) == 'C') {
Serial.print("instruction_C is: ");
String instruction_C = str.substring(1,str.length()); // remove first character and store the rest in the variable
Serial.println(instruction_C);
char this_char[instruction_C.length() + 1];
instruction_C.toCharArray(this_char, sizeof(this_char));
int_C = atoi(this_char);
}
if (str.charAt(0) == 'D') {
Serial.print("instruction_D is: ");
String instruction_D = str.substring(1,str.length()); // remove first character and store the rest in the variable
Serial.println(instruction_D);
char this_char[instruction_D.length() + 1];
instruction_D.toCharArray(this_char, sizeof(this_char));
int_D = atoi(this_char);
}
if (str.charAt(0) == 'E') {
Serial.print("instruction_E is: ");
String instruction_E = str.substring(1,str.length()); // remove first character and store the rest in the variable
Serial.println(instruction_E);
char this_char[instruction_E.length() + 1];
instruction_E.toCharArray(this_char, sizeof(this_char));
int_E = atoi(this_char);
}
if (str.charAt(0) == 'F') {
Serial.print("instruction_F is: ");
String instruction_F = str.substring(1,str.length()); // remove first character and store the rest in the variable
Serial.println(instruction_F);
char this_char[instruction_F.length() + 1];
instruction_F.toCharArray(this_char, sizeof(this_char));
int_F = atoi(this_char);
}
if (str.charAt(0) == 'G') {
Serial.print("instruction_G is: ");
String instruction_G = str.substring(1,str.length()); // remove first character and store the rest in the variable
Serial.println(instruction_G);
char this_char[instruction_G.length() + 1];
instruction_G.toCharArray(this_char, sizeof(this_char));
int_G = atoi(this_char);
}
if (str.charAt(0) == 'H') {
Serial.print("instruction_H is: ");
String instruction_H = str.substring(1,str.length()); // remove first character and store the rest in the variable
Serial.println(instruction_H);
char this_char[instruction_H.length() + 1];
instruction_H.toCharArray(this_char, sizeof(this_char));
int_H = atoi(this_char);
}
if (str.charAt(0) == 'I') {
Serial.print("instruction_I is: ");
String instruction_I = str.substring(1,str.length()); // remove first character and store the rest in the variable
Serial.println(instruction_I);
char this_char[instruction_I.length() + 1];
instruction_I.toCharArray(this_char, sizeof(this_char));
int_I = atoi(this_char);
}
if (str.charAt(0) == 'J') {
Serial.print("instruction_J is: ");
String instruction_J = str.substring(1,str.length()); // remove first character and store the rest in the variable
Serial.println(instruction_J);
char this_char[instruction_J.length() + 1];
instruction_J.toCharArray(this_char, sizeof(this_char));
int_J = atoi(this_char);
}
if (str.charAt(0) == 'K') {
Serial.print("instruction_K is: ");
String instruction_K = str.substring(1,str.length()); // remove first character and store the rest in the variable
Serial.println(instruction_K);
char this_char[instruction_K.length() + 1];
instruction_K.toCharArray(this_char, sizeof(this_char));
int_K = atoi(this_char);
}
if (str.charAt(0) == 'L') {
Serial.print("instruction_L is: ");
String instruction_L = str.substring(1,str.length()); // remove first character and store the rest in the variable
Serial.println(instruction_L);
char this_char[instruction_L.length() + 1];
instruction_L.toCharArray(this_char, sizeof(this_char));
int_L = atoi(this_char);
}

}

// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// DEFINE LEDS
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

const int r1_Jouw = 9;
const int r1_Momenteel = 18;
const int r1_Het = 25;
const int r1_Jij = 31;

const int r2_Verbruik = 8;
const int r2_Te = 17;
const int r2_Is = 24;
const int r2_Jij = 29;
const int r2_Was = 30;

const int r3_Het = 7;
const int r3_Laatste = 16;
const int r3_Gisteren = 38;

const int r4_Uur = 6;
const int r4_Kwartier = 23;
const int r4_Vandaag = 28;

const int r5_Even = 5;
const int r5_Veel = 14;
const int r5_Minder = 22;
const int r5_Meer = 34;

const int r6_Heel = 4;
const int r6_Constant = 13;
const int r6_Energie = 27;

const int r7_Laag = 3;
const int r7_Hoog = 12;
const int r7_Gestegen = 21;
const int r7_Wat = 33;

const int r8_Gedaald = 2;
const int r8_Normaal = 37;
const int r8_Zou = 26;

const int r9_Als = 1;
const int r9_Bij = 10;
const int r9_De = 11;
const int r9_Jouw = 19;
const int r9_Winnaar = 32;

const int r10_Tegenspeler = 0;
const int r10_Nu = 20;
const int r10_Doen = 35;
const int r10_Vraagteken = 36;

// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// DISPLAY SENTENCES
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

int NumberOfSentences = 6;

void DisplayNext(){
sentence ++ ;
if (sentence > NumberOfSentences) {sentence = 1;}

//if this sentence is special sentence -> check first!
//...
//...
Serial.print('zin: ');Serial.println(sentence);
DisplaySentence(sentence);
}

void DisplayPrevious(){
sentence -- ;
if (sentence = 0) {sentence = NumberOfSentences;}
DisplaySentence(sentence);
}

void DisplaySentence(int sentence){
clearRegisters();

if (sentence == 1){ // momenteel verbruik jij energie als jouw tegenspeler
clearRegisters();
//static part of the sentence
setRegisterPin(r1_Momenteel, HIGH);
setRegisterPin(r2_Verbruik, HIGH);
setRegisterPin(r2_Jij, HIGH);
setRegisterPin(r6_Energie, HIGH);
setRegisterPin(r9_Als, HIGH);
setRegisterPin(r9_Jouw, HIGH);
setRegisterPin(r10_Tegenspeler, HIGH);

//variable part of the sentence
Variable_Amount(int_A);
writeRegisters();
}

if (sentence == 2){ //Jij was gisteren de winnaar
clearRegisters();
if (int_B==1){ // check if they were the winner yesterday
setRegisterPin(r1_Jij, HIGH);
setRegisterPin(r2_Was, HIGH);
setRegisterPin(r3_Gisteren, HIGH);
setRegisterPin(r9_De, HIGH);
setRegisterPin(r9_Winnaar, HIGH);
writeRegisters();
}
else { DisplayNext();}
}

if (sentence == 3){ //Jij verbruikte energie als jouw tegenspeler
clearRegisters();

// static part
setRegisterPin(r1_Jij, HIGH);
setRegisterPin(r2_Verbruik, HIGH);
setRegisterPin(r2_Te, HIGH);
setRegisterPin(r6_Energie, HIGH);
setRegisterPin(r9_Als, HIGH);
setRegisterPin(r9_Jouw, HIGH);
setRegisterPin(r10_Tegenspeler, HIGH);

//Variable part
int randomTime = random(0, 3);
if (randomTime==0){ //gisteren
Variable_Time(1);
Variable_Amount(int_C);
}
if (randomTime==1){ //Het laatste uur
Variable_Time(3);
Variable_Amount(int_D);
}
if (randomTime==2){ // Het laatste kwartier
Variable_Time(4);
Variable_Amount(int_E);
}

writeRegisters();
}

if (sentence == 4){ //Jouw verbruik is
clearRegisters();
//static part of the sentence
setRegisterPin(r1_Jouw, HIGH);
setRegisterPin(r2_Verbruik, HIGH);
setRegisterPin(r2_Is, HIGH);

//Variable part
int randomTime = random(0, 3);
if (randomTime==0){ //vandaag
Variable_Time(2);
Variable_Indication(int_F);
}
if (randomTime==1){ //Het laatste uur
Variable_Time(3);
Variable_Indication(int_G);
}
if (randomTime==2){ // Het laatste kwartier
Variable_Time(4);
Variable_Indication(int_H);
}

writeRegisters();
}

if (sentence == 5){ //Het verbruik is bij jouw tegenspeler
clearRegisters();

//static part
setRegisterPin(r1_Het, HIGH);
setRegisterPin(r2_Verbruik, HIGH);
setRegisterPin(r2_Is, HIGH);
setRegisterPin(r9_Bij, HIGH);
setRegisterPin(r9_Jouw, HIGH);
setRegisterPin(r10_Tegenspeler, HIGH);

//Variable part
int randomTime = random(0, 3);
if (randomTime==0){ //vandaag
Variable_Time(2);
Variable_Indication(int_I);
}
if (randomTime==1){ //Het laatste uur
Variable_Time(3);
Variable_Indication(int_J);
}
if (randomTime==2){ // Het laatste kwartier
Variable_Time(4);
Variable_Indication(int_K);
}

writeRegisters();
}

if (sentence == 6){ // Wat zou de tegenspeler nu doen?
clearRegisters();
if (int_L==1){ // check if we should display this sentence
setRegisterPin(r7_Wat, HIGH);
setRegisterPin(r8_Zou, HIGH);
setRegisterPin(r9_De, HIGH);
setRegisterPin(r10_Tegenspeler, HIGH);
setRegisterPin(r10_Nu, HIGH);
setRegisterPin(r10_Doen, HIGH);
setRegisterPin(r10_Vraagteken, HIGH);
}
else { DisplayNext();}

writeRegisters();
}

}

void Variable_Amount(int value){ // (veel) minder, evenveel, (veel) meer
if(value==1){ // veel minder
setRegisterPin(r5_Veel, HIGH);
setRegisterPin(r5_Minder, HIGH);
}
if(value==2){ // minder
setRegisterPin(r5_Minder, HIGH);
}
if(value==3){ // evenveel
setRegisterPin(r5_Even, HIGH);
setRegisterPin(r5_Veel, HIGH);
}
if(value==4){ // veel minder
setRegisterPin(r5_Meer, HIGH);
}
if(value==5){ // veel minder
setRegisterPin(r5_Veel, HIGH);
setRegisterPin(r5_Meer, HIGH);
}
}

void Variable_Indication(int value){ // laag hoog constant gestegen ...
if(value==1){ // heel laag
setRegisterPin(r6_Heel, HIGH);
setRegisterPin(r7_Laag, HIGH);
}
if(value==2){ // laag
setRegisterPin(r7_Laag, HIGH);
}
if(value==3){ // normaal
setRegisterPin(r8_Normaal, HIGH);
}
if(value==4){ // hoog
setRegisterPin(r7_Hoog, HIGH);
}
if(value==5){ // heel hoog
setRegisterPin(r6_Heel, HIGH);
setRegisterPin(r7_Hoog, HIGH);
}
if(value==6){ // constant
setRegisterPin(r6_Constant, HIGH);
}
if(value==7){ // gestegen
setRegisterPin(r7_Gestegen, HIGH);
}
if(value==8){ // gedaald
setRegisterPin(r8_Gedaald, HIGH);
}
}

void Variable_Time(int value){ //gisteren, vandaag, laatste kwartier, laatste uur
if(value==1){ // gisteren
setRegisterPin(r3_Gisteren, HIGH);
}
if(value==2){ // vandaag
setRegisterPin(r4_Vandaag, HIGH);
}
if(value==3){ // Het laatste uur
setRegisterPin(r3_Het, HIGH);
setRegisterPin(r3_Laatste, HIGH);
setRegisterPin(r4_Uur, HIGH);
}
if(value==4){ // Het laatste kwartier
setRegisterPin(r3_Het, HIGH);
setRegisterPin(r3_Laatste, HIGH);
setRegisterPin(r4_Kwartier, HIGH);
}
}

//Het verbruik is bij jouw tegenspeler
// Wat zou de tegenspeler nu doen?

objective display:

/*
Display Code (objective display)

Part of a Master's thesis project
"Designing and evaluating an energy consumption competition"

Author: Stijn Coppens
Date: 2012-03-05

The display receives instructions from the hub and uses those to visualize the energy
consumption of the competitors
*/

// EtherCard Library by Jean-Claude Wippler and Andrew Lindsay
// JeeLib Library by Jean-Claude Wippler
//--------------------------------------------------------------------------------------

#include //https://github.com/jcw/jeelib
#include

#define MYNODE 50 // node ID 50 reserved for display
#define freq RF12_433MHZ // frequency
#define group 210 // network group

unsigned long lastRF; // used to check for RF recieve failures
unsigned long update_sentence;
unsigned long update_user;
int RFerror=0; //RF error flag - high when no data received
int sentence_interval = 30000;
int user_interval = 7500;
int sentence = 1;
int NumberOfSentences = 5;
String user = "";
// define structure of the packages that are received via RF (from the Hub)
typedef struct{
char instruction [50]; // instruction (from the nanode)
} PayloadDisp;
PayloadDisp Display;

// buttons
const int buttonLeft = 4; // the number of the left pushbutton pin (previous)
const int buttonRight = 3; // the number of the right pushbutton pin (next)
int Left = 0;
int Right = 0;

int SER_Pin = 5; //pin 14 on the 75HC595
int RCLK_Pin = 6; //pin 12 on the 75HC595
int SRCLK_Pin = 7; //pin 11 on the 75HC595

//How many of the shift registers - change this
#define number_of_74hc595s 6
#define numOfRegisterPins number_of_74hc595s * 8
boolean registers[numOfRegisterPins];

void setup () {
Serial.begin(9600);
rf12_initialize(MYNODE, freq,group);
lastRF = millis()-40000; // setting lastRF back 40s is useful as it forces the code to run straight away

pinMode(SER_Pin, OUTPUT);
pinMode(RCLK_Pin, OUTPUT);
pinMode(SRCLK_Pin, OUTPUT);

pinMode(buttonLeft, INPUT);
pinMode(buttonRight, INPUT);

//reset all register pins
clearRegisters();
writeRegisters();
}

//set all register pins to LOW
void clearRegisters(){
for(int i = numOfRegisterPins - 1; i >= 0; i--){
setRegisterPin(i, LOW);

}
}

//Set and display registers
//Only call AFTER all values are set how you would like (slow otherwise)
void writeRegisters(){

digitalWrite(RCLK_Pin, LOW);

for(int i = numOfRegisterPins - 1; i >= 0; i--){
digitalWrite(SRCLK_Pin, LOW);

int val = registers[i];

digitalWrite(SER_Pin, val);
digitalWrite(SRCLK_Pin, HIGH);

}
digitalWrite(RCLK_Pin, HIGH);

}

//set an individual pin HIGH or LOW
void setRegisterPin(int index, int value){
registers[index] = value;
}

void loop () {

// if an instruction is received:
if (rf12_recvDone() && rf12_crc == 0 && (rf12_hdr & RF12_HDR_CTL) == 0)
{
Display=*(PayloadDisp*) rf12_data; // Get the payload for the display
RFerror=0; //reset RF error flag

String New = Display.instruction;
int length = New.length();

if (length > 1){
Serial.println("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
Serial.print("New instruction received: ");
Serial.println(Display.instruction); // print the complete instruction

char *p = Display.instruction;
char *str;
while ((str = strtok_r(p, ";", &p)) != NULL) // delimiter is the semicolon
{
storePart(str);
}
Serial.println("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
}

lastRF = millis(); // reset lastRF timer
#ifdef DEBUG
Serial.println("RF recieved");
#endif
}

// If no data is recieved from rf12 module the server is updated every 30s with RFfail = 1 indicator for debugging
if ((millis()-lastRF)>30000)
{
lastRF = millis(); // reset lastRF timer
Serial.println("no data received in the last 30 seconds"); // No RF received in 30 seconds so send failure
RFerror=1;
}

if ((millis()-update_sentence)>sentence_interval)
{
update_sentence = millis();
Serial.println("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
DisplayNext();
}

if ((millis()-update_user)>user_interval)
{
update_user = millis();
DisplayNextUser();
}

// read the state of the pushbutton value:
Left = digitalRead(buttonLeft);
Right = digitalRead(buttonRight);

// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (Left == HIGH) {
Serial.println("Left is pressed");
delay(300);
DisplayPrevious();
}

if (Right == HIGH) {
delay(300);
Serial.println("Right is pressed");
DisplayNext();
}

} // end loop


// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// VARIABLES
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

int int_A = 12;
int int_B = 34;
int int_C = 56;
int int_D = 78;
int int_E = 91;
int int_F = 82;
int int_G = 73;
int int_H = 64;
int int_I = 5;
int int_J = 0;
int int_K = 0;
int int_L = 0;

// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// STORE RECEIVING STRING IN DIFFERENT PARTS
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

void storePart(String str){
// Check if it starts with an 'A'
if (str.charAt(0) == 'A') {
Serial.print("instruction_A is: ");
String instruction_A = str.substring(1,str.length()); // remove first character and store the rest in the variable
Serial.println(instruction_A);
char this_char[instruction_A.length() + 1];
instruction_A.toCharArray(this_char, sizeof(this_char));
int_A = atoi(this_char);
}

// Check if it starts with a 'B'
if (str.charAt(0) == 'B') {
Serial.print("instruction_B is: ");
String instruction_B = str.substring(1,str.length()); // remove first character and store the rest in the variable
Serial.println(instruction_B);
char this_char[instruction_B.length() + 1];
instruction_B.toCharArray(this_char, sizeof(this_char));
int_B = atoi(this_char);
}

if (str.charAt(0) == 'C') {
Serial.print("instruction_C is: ");
String instruction_C = str.substring(1,str.length()); // remove first character and store the rest in the variable
Serial.println(instruction_C);
char this_char[instruction_C.length() + 1];
instruction_C.toCharArray(this_char, sizeof(this_char));
int_C = atoi(this_char);
}
if (str.charAt(0) == 'D') {
Serial.print("instruction_D is: ");
String instruction_D = str.substring(1,str.length()); // remove first character and store the rest in the variable
Serial.println(instruction_D);
char this_char[instruction_D.length() + 1];
instruction_D.toCharArray(this_char, sizeof(this_char));
int_D = atoi(this_char);
}
if (str.charAt(0) == 'E') {
Serial.print("instruction_E is: ");
String instruction_E = str.substring(1,str.length()); // remove first character and store the rest in the variable
Serial.println(instruction_E);
char this_char[instruction_E.length() + 1];
instruction_E.toCharArray(this_char, sizeof(this_char));
int_E = atoi(this_char);
}
if (str.charAt(0) == 'F') {
Serial.print("instruction_F is: ");
String instruction_F = str.substring(1,str.length()); // remove first character and store the rest in the variable
Serial.println(instruction_F);
char this_char[instruction_F.length() + 1];
instruction_F.toCharArray(this_char, sizeof(this_char));
int_F = atoi(this_char);
}
if (str.charAt(0) == 'G') {
Serial.print("instruction_G is: ");
String instruction_G = str.substring(1,str.length()); // remove first character and store the rest in the variable
Serial.println(instruction_G);
char this_char[instruction_G.length() + 1];
instruction_G.toCharArray(this_char, sizeof(this_char));
int_G = atoi(this_char);
}
if (str.charAt(0) == 'H') {
Serial.print("instruction_H is: ");
String instruction_H = str.substring(1,str.length()); // remove first character and store the rest in the variable
Serial.println(instruction_H);
char this_char[instruction_H.length() + 1];
instruction_H.toCharArray(this_char, sizeof(this_char));
int_H = atoi(this_char);
}
if (str.charAt(0) == 'I') {
Serial.print("instruction_I is: ");
String instruction_I = str.substring(1,str.length()); // remove first character and store the rest in the variable
Serial.println(instruction_I);
char this_char[instruction_I.length() + 1];
instruction_I.toCharArray(this_char, sizeof(this_char));
int_I = atoi(this_char);
}
if (str.charAt(0) == 'J') {
Serial.print("instruction_J is: ");
String instruction_J = str.substring(1,str.length()); // remove first character and store the rest in the variable
Serial.println(instruction_J);
char this_char[instruction_J.length() + 1];
instruction_J.toCharArray(this_char, sizeof(this_char));
int_J = atoi(this_char);
}
if (str.charAt(0) == 'K') {
Serial.print("instruction_K is: ");
String instruction_K = str.substring(1,str.length()); // remove first character and store the rest in the variable
Serial.println(instruction_K);
char this_char[instruction_K.length() + 1];
instruction_K.toCharArray(this_char, sizeof(this_char));
int_K = atoi(this_char);
}
if (str.charAt(0) == 'L') {
Serial.print("instruction_L is: ");
String instruction_L = str.substring(1,str.length()); // remove first character and store the rest in the variable
Serial.println(instruction_L);
char this_char[instruction_L.length() + 1];
instruction_L.toCharArray(this_char, sizeof(this_char));
int_L = atoi(this_char);
}

}

numeric values:

// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// DEFINE LEDS (NUMERIC)
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

//plus and min sign
const int plus_sign = 26;
const int min_sign = 24;
String sign ="empty";

//comma's
const int NumComma_one = 32;
const int NumComma_two = 41;
const int NumComma_three = 45;

//first numeric character
const int NumFirst_up = 31;
const int NumFirst_up_left = 28;
const int NumFirst_up_right = 35;
const int NumFirst_mid = 30;
const int NumFirst_down_left = 25;
const int NumFirst_down_right = 33;
const int NumFirst_down = 29;

//second numeric character
const int NumSecond_up = 38;
const int NumSecond_up_left = 37;
const int NumSecond_up_right = 43;
const int NumSecond_mid = 39;
const int NumSecond_down_left = 34;
const int NumSecond_down_right = 40;
const int NumSecond_down = 36;

//hird numeric character
const int NumThird_up = 9;
const int NumThird_up_left = 7;
const int NumThird_up_right = 11;
const int NumThird_mid = 8;
const int NumThird_down_left = 42;
const int NumThird_down_right = 10;
const int NumThird_down = 44;

//fourth numeric character
const int NumFourth_up = 1;
const int NumFourth_up_left = 14;
const int NumFourth_up_right = 17;
const int NumFourth_mid = 15;
const int NumFourth_down_left = 12;
const int NumFourth_down_right = 16;
const int NumFourth_down = 13;

// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// DISPLAY NUMERIC VALUES
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

void DisplayNumeric(int Number, int CommaPlace, String sign){

Serial.print(sign); Serial.print(Number);
Serial.print(" CommaPlace( "); Serial.print(CommaPlace);Serial.print(") ");

//Display sign
if (sign == "plus"){ setRegisterPin(plus_sign, HIGH);}
if (sign == "min"){ setRegisterPin(min_sign, HIGH);}
// else, display no sign

//Display Comma
if (CommaPlace == 3){ setRegisterPin(NumComma_three, HIGH);number_3(0);}
if (CommaPlace == 2){ setRegisterPin(NumComma_two, HIGH);number_2(0);number_3(0);}
if (CommaPlace == 1){ setRegisterPin(NumComma_one, HIGH);number_1(0);number_2(0);number_3(0);}
// else, display no comma

// What is the length of the Number?
int Length = 0;

if(Number > 999) {Length = 4;}
else if(Number > 99) {Length = 3;}
else if(Number > 9) {Length = 2;}
else if(Number >= 0) {Length = 1;}

if (Length == 1){
// immediately print number in the last possible place
number_4(Number);
}

if (Length == 2){
// we will have to retrieve two values
int Number_one = Number / 10;
number_3(Number_one);
int Number_two = Number - (Number_one * 10);
number_4(Number_two);
}

if (Length == 3){
// we will have to retrieve three values, eg 345
int Number_one = Number / 100;
number_2(Number_one);
int Number_two = (Number - (Number_one * 100)) / 10;
number_3(Number_two);
int Number_three = (Number - (Number_one * 100) - (Number_two * 10));
number_4(Number_three);
}

if (Length == 4){
// we will have to retrieve three values, eg 3145
int Number_one = Number / 1000;
number_1(Number_one);
int Number_two = (Number - (Number_one * 1000)) / 100;
number_2(Number_two);
int Number_three = (Number - (Number_one * 1000) - (Number_two * 100)) / 10;
number_3(Number_three);
int Number_four = (Number - (Number_one * 1000) - (Number_two * 100) - (Number_three * 10));
number_4(Number_four);
}
}

// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// FIRST NUMERIC CHARACTER
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
void number_1(int number){
//clear all, this is necessary because of the comma's
setRegisterPin(NumFirst_up_left, LOW);
setRegisterPin(NumFirst_up, LOW);
setRegisterPin(NumFirst_up_right, LOW);
setRegisterPin(NumFirst_mid, LOW);
setRegisterPin(NumFirst_down_left, LOW);
setRegisterPin(NumFirst_down, LOW);
setRegisterPin(NumFirst_down_right, LOW);

if (number == 0){
setRegisterPin(NumFirst_up_left, HIGH);
setRegisterPin(NumFirst_up, HIGH);
setRegisterPin(NumFirst_up_right, HIGH);
setRegisterPin(NumFirst_down_left, HIGH);
setRegisterPin(NumFirst_down, HIGH);
setRegisterPin(NumFirst_down_right, HIGH);
writeRegisters();
}

if (number == 1){
setRegisterPin(NumFirst_up_right, HIGH);
setRegisterPin(NumFirst_down_right, HIGH);
writeRegisters();
}

if (number == 2){
setRegisterPin(NumFirst_up, HIGH);
setRegisterPin(NumFirst_up_right, HIGH);
setRegisterPin(NumFirst_mid,HIGH);
setRegisterPin(NumFirst_down_left, HIGH);
setRegisterPin(NumFirst_down, HIGH);
writeRegisters();
}

if (number == 3){
setRegisterPin(NumFirst_up, HIGH);
setRegisterPin(NumFirst_up_right, HIGH);
setRegisterPin(NumFirst_mid, HIGH);
setRegisterPin(NumFirst_down, HIGH);
setRegisterPin(NumFirst_down_right, HIGH);
writeRegisters();
}

if (number == 4){
setRegisterPin(NumFirst_up_left, HIGH);
setRegisterPin(NumFirst_up_right, HIGH);
setRegisterPin(NumFirst_mid, HIGH);
setRegisterPin(NumFirst_down_right, HIGH);
writeRegisters();
}

if (number == 5){
setRegisterPin(NumFirst_up, HIGH);
setRegisterPin(NumFirst_up_left, HIGH);
setRegisterPin(NumFirst_mid, HIGH);
setRegisterPin(NumFirst_down, HIGH);
setRegisterPin(NumFirst_down_right, HIGH);
writeRegisters();
}

if (number == 6){
setRegisterPin(NumFirst_up, HIGH);
setRegisterPin(NumFirst_up_left, HIGH);
setRegisterPin(NumFirst_mid, HIGH);
setRegisterPin(NumFirst_down, HIGH);
setRegisterPin(NumFirst_down_right, HIGH);
setRegisterPin(NumFirst_down_left, HIGH);
writeRegisters();
}

if (number == 7){
setRegisterPin(NumFirst_up, HIGH);
setRegisterPin(NumFirst_up_right, HIGH);
setRegisterPin(NumFirst_down_right, HIGH);
writeRegisters();
}

if (number == 8){
setRegisterPin(NumFirst_up, HIGH);
setRegisterPin(NumFirst_up_left, HIGH);
setRegisterPin(NumFirst_up_right, HIGH);
setRegisterPin(NumFirst_mid, HIGH);
setRegisterPin(NumFirst_down, HIGH);
setRegisterPin(NumFirst_down_right, HIGH);
setRegisterPin(NumFirst_down_left, HIGH);
writeRegisters();
}

if (number == 9){
setRegisterPin(NumFirst_up, HIGH);
setRegisterPin(NumFirst_up_left, HIGH);
setRegisterPin(NumFirst_up_right, HIGH);
setRegisterPin(NumFirst_mid, HIGH);
setRegisterPin(NumFirst_down, HIGH);
setRegisterPin(NumFirst_down_right, HIGH);
writeRegisters();
}
}

// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// SECOND NUMERIC CHARACTER
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
void number_2(int number){
//clear all, this is necessary because of the comma's
setRegisterPin(NumSecond_up_left, LOW);
setRegisterPin(NumSecond_up, LOW);
setRegisterPin(NumSecond_up_right, LOW);
setRegisterPin(NumSecond_mid, LOW);
setRegisterPin(NumSecond_down_left, LOW);
setRegisterPin(NumSecond_down, LOW);
setRegisterPin(NumSecond_down_right, LOW);

if (number == 0){
setRegisterPin(NumSecond_up_left, HIGH);
setRegisterPin(NumSecond_up, HIGH);
setRegisterPin(NumSecond_up_right, HIGH);
setRegisterPin(NumSecond_down_left, HIGH);
setRegisterPin(NumSecond_down, HIGH);
setRegisterPin(NumSecond_down_right, HIGH);
writeRegisters();
}

if (number == 1){
setRegisterPin(NumSecond_up_right, HIGH);
setRegisterPin(NumSecond_down_right, HIGH);
writeRegisters();
}

if (number == 2){
setRegisterPin(NumSecond_up, HIGH);
setRegisterPin(NumSecond_up_right, HIGH);
setRegisterPin(NumSecond_mid,HIGH);
setRegisterPin(NumSecond_down_left, HIGH);
setRegisterPin(NumSecond_down, HIGH);
writeRegisters();
}

if (number == 3){
setRegisterPin(NumSecond_up, HIGH);
setRegisterPin(NumSecond_up_right, HIGH);
setRegisterPin(NumSecond_mid, HIGH);
setRegisterPin(NumSecond_down, HIGH);
setRegisterPin(NumSecond_down_right, HIGH);
writeRegisters();
}

if (number == 4){
setRegisterPin(NumSecond_up_left, HIGH);
setRegisterPin(NumSecond_up_right, HIGH);
setRegisterPin(NumSecond_mid, HIGH);
setRegisterPin(NumSecond_down_right, HIGH);
writeRegisters();
}

if (number == 5){
setRegisterPin(NumSecond_up, HIGH);
setRegisterPin(NumSecond_up_left, HIGH);
setRegisterPin(NumSecond_mid, HIGH);
setRegisterPin(NumSecond_down, HIGH);
setRegisterPin(NumSecond_down_right, HIGH);
writeRegisters();
}

if (number == 6){
setRegisterPin(NumSecond_up, HIGH);
setRegisterPin(NumSecond_up_left, HIGH);
setRegisterPin(NumSecond_mid, HIGH);
setRegisterPin(NumSecond_down, HIGH);
setRegisterPin(NumSecond_down_right, HIGH);
setRegisterPin(NumSecond_down_left, HIGH);
writeRegisters();
}

if (number == 7){
setRegisterPin(NumSecond_up, HIGH);
setRegisterPin(NumSecond_up_right, HIGH);
setRegisterPin(NumSecond_down_right, HIGH);
writeRegisters();
}

if (number == 8){
setRegisterPin(NumSecond_up, HIGH);
setRegisterPin(NumSecond_up_left, HIGH);
setRegisterPin(NumSecond_up_right, HIGH);
setRegisterPin(NumSecond_mid, HIGH);
setRegisterPin(NumSecond_down, HIGH);
setRegisterPin(NumSecond_down_right, HIGH);
setRegisterPin(NumSecond_down_left, HIGH);
writeRegisters();
}

if (number == 9){
setRegisterPin(NumSecond_up, HIGH);
setRegisterPin(NumSecond_up_left, HIGH);
setRegisterPin(NumSecond_up_right, HIGH);
setRegisterPin(NumSecond_mid, HIGH);
setRegisterPin(NumSecond_down, HIGH);
setRegisterPin(NumSecond_down_right, HIGH);
writeRegisters();
}
}

// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// THIRD NUMERIC CHARACTER
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
void number_3(int number){
//clear all, this is necessary because of the comma's
setRegisterPin(NumThird_up_left, LOW);
setRegisterPin(NumThird_up, LOW);
setRegisterPin(NumThird_up_right, LOW);
setRegisterPin(NumThird_mid, LOW);
setRegisterPin(NumThird_down_left, LOW);
setRegisterPin(NumThird_down, LOW);
setRegisterPin(NumThird_down_right, LOW);

if (number == 0){
setRegisterPin(NumThird_up_left, HIGH);
setRegisterPin(NumThird_up, HIGH);
setRegisterPin(NumThird_up_right, HIGH);
setRegisterPin(NumThird_down_left, HIGH);
setRegisterPin(NumThird_down, HIGH);
setRegisterPin(NumThird_down_right, HIGH);
writeRegisters();
}

if (number == 1){
setRegisterPin(NumThird_up_right, HIGH);
setRegisterPin(NumThird_down_right, HIGH);
writeRegisters();
}

if (number == 2){
setRegisterPin(NumThird_up, HIGH);
setRegisterPin(NumThird_up_right, HIGH);
setRegisterPin(NumThird_mid,HIGH);
setRegisterPin(NumThird_down_left, HIGH);
setRegisterPin(NumThird_down, HIGH);
writeRegisters();
}

if (number == 3){
setRegisterPin(NumThird_up, HIGH);
setRegisterPin(NumThird_up_right, HIGH);
setRegisterPin(NumThird_mid, HIGH);
setRegisterPin(NumThird_down, HIGH);
setRegisterPin(NumThird_down_right, HIGH);
writeRegisters();
}

if (number == 4){
setRegisterPin(NumThird_up_left, HIGH);
setRegisterPin(NumThird_up_right, HIGH);
setRegisterPin(NumThird_mid, HIGH);
setRegisterPin(NumThird_down_right, HIGH);
writeRegisters();
}

if (number == 5){
setRegisterPin(NumThird_up, HIGH);
setRegisterPin(NumThird_up_left, HIGH);
setRegisterPin(NumThird_mid, HIGH);
setRegisterPin(NumThird_down, HIGH);
setRegisterPin(NumThird_down_right, HIGH);
writeRegisters();
}

if (number == 6){
setRegisterPin(NumThird_up, HIGH);
setRegisterPin(NumThird_up_left, HIGH);
setRegisterPin(NumThird_mid, HIGH);
setRegisterPin(NumThird_down, HIGH);
setRegisterPin(NumThird_down_right, HIGH);
setRegisterPin(NumThird_down_left, HIGH);
writeRegisters();
}

if (number == 7){
setRegisterPin(NumThird_up, HIGH);
setRegisterPin(NumThird_up_right, HIGH);
setRegisterPin(NumThird_down_right, HIGH);
writeRegisters();
}

if (number == 8){
setRegisterPin(NumThird_up, HIGH);
setRegisterPin(NumThird_up_left, HIGH);
setRegisterPin(NumThird_up_right, HIGH);
setRegisterPin(NumThird_mid, HIGH);
setRegisterPin(NumThird_down, HIGH);
setRegisterPin(NumThird_down_right, HIGH);
setRegisterPin(NumThird_down_left, HIGH);
writeRegisters();
}

if (number == 9){
setRegisterPin(NumThird_up, HIGH);
setRegisterPin(NumThird_up_left, HIGH);
setRegisterPin(NumThird_up_right, HIGH);
setRegisterPin(NumThird_mid, HIGH);
setRegisterPin(NumThird_down, HIGH);
setRegisterPin(NumThird_down_right, HIGH);
writeRegisters();
}
}

// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// FOURTH NUMERIC CHARACTER
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
void number_4(int number){
if (number == 0){
setRegisterPin(NumFourth_up_left, HIGH);
setRegisterPin(NumFourth_up, HIGH);
setRegisterPin(NumFourth_up_right, HIGH);
setRegisterPin(NumFourth_down_left, HIGH);
setRegisterPin(NumFourth_down, HIGH);
setRegisterPin(NumFourth_down_right, HIGH);
writeRegisters();
}

if (number == 1){
setRegisterPin(NumFourth_up_right, HIGH);
setRegisterPin(NumFourth_down_right, HIGH);
writeRegisters();
}

if (number == 2){
setRegisterPin(NumFourth_up, HIGH);
setRegisterPin(NumFourth_up_right, HIGH);
setRegisterPin(NumFourth_mid,HIGH);
setRegisterPin(NumFourth_down_left, HIGH);
setRegisterPin(NumFourth_down, HIGH);
writeRegisters();
}

if (number == 3){
setRegisterPin(NumFourth_up, HIGH);
setRegisterPin(NumFourth_up_right, HIGH);
setRegisterPin(NumFourth_mid, HIGH);
setRegisterPin(NumFourth_down, HIGH);
setRegisterPin(NumFourth_down_right, HIGH);
writeRegisters();
}

if (number == 4){
setRegisterPin(NumFourth_up_left, HIGH);
setRegisterPin(NumFourth_up_right, HIGH);
setRegisterPin(NumFourth_mid, HIGH);
setRegisterPin(NumFourth_down_right, HIGH);
writeRegisters();
}

if (number == 5){
setRegisterPin(NumFourth_up, HIGH);
setRegisterPin(NumFourth_up_left, HIGH);
setRegisterPin(NumFourth_mid, HIGH);
setRegisterPin(NumFourth_down, HIGH);
setRegisterPin(NumFourth_down_right, HIGH);
writeRegisters();
}

if (number == 6){
setRegisterPin(NumFourth_up, HIGH);
setRegisterPin(NumFourth_up_left, HIGH);
setRegisterPin(NumFourth_mid, HIGH);
setRegisterPin(NumFourth_down, HIGH);
setRegisterPin(NumFourth_down_right, HIGH);
setRegisterPin(NumFourth_down_left, HIGH);
writeRegisters();
}

if (number == 7){
setRegisterPin(NumFourth_up, HIGH);
setRegisterPin(NumFourth_up_right, HIGH);
setRegisterPin(NumFourth_down_right, HIGH);
writeRegisters();
}

if (number == 8){
setRegisterPin(NumFourth_up, HIGH);
setRegisterPin(NumFourth_up_left, HIGH);
setRegisterPin(NumFourth_up_right, HIGH);
setRegisterPin(NumFourth_mid, HIGH);
setRegisterPin(NumFourth_down, HIGH);
setRegisterPin(NumFourth_down_right, HIGH);
setRegisterPin(NumFourth_down_left, HIGH);
writeRegisters();
}

if (number == 9){
setRegisterPin(NumFourth_up, HIGH);
setRegisterPin(NumFourth_up_left, HIGH);
setRegisterPin(NumFourth_up_right, HIGH);
setRegisterPin(NumFourth_mid, HIGH);
setRegisterPin(NumFourth_down, HIGH);
setRegisterPin(NumFourth_down_right, HIGH);
writeRegisters();
}
}

display specific:

// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// DEFINE LEDS (NUMERIC)
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

const int r1_Momenteel = 4;
const int r1_Verbruik = 23;
const int r2_Overwinningen = 2;
const int r2_Per = 5;
const int r2_Dag = 22;
const int r3_Vandaag = 6;
const int r3_Gisteren = 3;
const int r3_Uur = 21;

const int r6_Euro = 20;
const int r7_Watt = 19;
const int r8_Kwh = 18;

const int r10_Jezelf = 27;
const int r10_Tegenstrever = 46;

// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// NAVIGATION
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

void DisplayNext(){
sentence ++ ;
if (sentence > NumberOfSentences) {sentence = 1;}
}

void DisplayPrevious(){
sentence -- ;
if (sentence = 0) {sentence = NumberOfSentences;}
}

void DisplayNextUser(){
if (user=="You"){ user="Competitor";}
else { user="You";}
DisplaySentence(sentence);
}

// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// DISPLAY SENTENCE
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

void DisplaySentence(int sentence){
clearRegisters();

if (sentence == 1){ // Momenteel verbruik (watt)
Serial.print("MOMENTEEL VERBRUIK: ");
// static part
setRegisterPin(r1_Momenteel, HIGH);
setRegisterPin(r1_Verbruik, HIGH);
setRegisterPin(r7_Watt, HIGH);

//dynamic part
if (user == "You"){
setRegisterPin(r10_Jezelf, HIGH);
Serial.print("Jezelf: ");
DisplayNumeric(int_A, 0, "");
}
if (user == "Competitor"){
Serial.print("Tegenstrever: ");
setRegisterPin(r10_Tegenstrever, HIGH);
DisplayNumeric(int_B, 0, "");
}
Serial.println(" (Watt)");
writeRegisters();
}

if (sentence == 2){ // Momenteel verbruik per uur (kwh)
Serial.print("MOMENTEEL VERBRUIK PER UUR: ");
// static part
setRegisterPin(r1_Momenteel, HIGH);
setRegisterPin(r1_Verbruik, HIGH);
setRegisterPin(r2_Per, HIGH);
setRegisterPin(r3_Uur, HIGH);
setRegisterPin(r8_Kwh, HIGH);

//dynamic part
if (user == "You"){
setRegisterPin(r10_Jezelf, HIGH);
Serial.print("Jezelf: ");
DisplayNumeric(int_C, 1, "");
}
if (user == "Competitor"){
Serial.print("Tegenstrever: ");
setRegisterPin(r10_Tegenstrever, HIGH);
DisplayNumeric(int_D, 1, "");
}
Serial.println(" (kWh)");
writeRegisters();
}

if (sentence == 3){ // Momenteel verbruik per dag (kwh)
Serial.print("MOMENTEEL VERBRUIK PER DAG: ");
// static part
setRegisterPin(r1_Momenteel, HIGH);
setRegisterPin(r1_Verbruik, HIGH);
setRegisterPin(r2_Per, HIGH);
setRegisterPin(r2_Dag, HIGH);
setRegisterPin(r8_Kwh, HIGH);

//dynamic part
if (user == "You"){
setRegisterPin(r10_Jezelf, HIGH);
Serial.print("Jezelf: ");
DisplayNumeric(int_E, 1, "");
}
if (user == "Competitor"){
Serial.print("Tegenstrever: ");
setRegisterPin(r10_Tegenstrever, HIGH);
DisplayNumeric(int_F, 1, "");
}
Serial.println(" (kWh)");
writeRegisters();
}

/* if (sentence == 3){ // VERBRUIK VANDAAG (euro)
Serial.print("VERBRUIK VANDAAG: ");
// static part
setRegisterPin(r1_Verbruik, HIGH);
setRegisterPin(r3_Vandaag, HIGH);
setRegisterPin(r6_Euro, HIGH);

//dynamic part
if (user == "You"){
setRegisterPin(r10_Jezelf, HIGH);
Serial.print("Jezelf: ");
DisplayNumeric(int_G, 2, "");
}
if (user == "Competitor"){
Serial.print("Tegenstrever: ");
setRegisterPin(r10_Tegenstrever, HIGH);
DisplayNumeric(int_H, 2, "");
}
Serial.println(" (Euro)");
writeRegisters();
}
*/
if (sentence == 4){ // VERBRUIK Gisteren (euro)
Serial.print("VERBRUIK GISTEREN: ");
// static part
setRegisterPin(r1_Verbruik, HIGH);
setRegisterPin(r3_Gisteren, HIGH);
setRegisterPin(r6_Euro, HIGH);

//dynamic part
if (user == "You"){
setRegisterPin(r10_Jezelf, HIGH);
Serial.print("Jezelf: ");
DisplayNumeric(int_I, 2, "");
}
if (user == "Competitor"){
Serial.print("Tegenstrever: ");
setRegisterPin(r10_Tegenstrever, HIGH);
DisplayNumeric(int_J, 2, "");
}
Serial.println(" (Euro)");
writeRegisters();
}

if (sentence == 5){ // Overwinningen
Serial.print("Overwinningen: ");
// static part
setRegisterPin(r2_Overwinningen, HIGH);
number_1(int_K); Serial.print(int_K);
setRegisterPin(NumSecond_mid, HIGH);
Serial.print(" - ");
number_3(int_L); Serial.println(int_L);

writeRegisters();
}

}

Leave a Comment