WappAutomation 2 : - WITH RESET - WITHOUT Switch Cable Tested on TEL50

Dependencies:   MFRC522

main.cpp

Committer:
dalbanf
Date:
2017-08-23
Revision:
2:50210204232a
Parent:
1:24db8b26b816

File content as of revision 2:50210204232a:

#include "mbed.h"

float delay = 0.5; // 1 sec

InterruptIn userBtn(USER_BUTTON);

DigitalOut TagLED(D3);
DigitalOut GndLED(D8);
DigitalOut PE2(PE_2);
DigitalOut Relay(D4);
DigitalOut red(LED3);
DigitalOut blue(LED2);
DigitalOut green(LED1);
DigitalOut PE4(PE_4);

DigitalIn PE6(PE_6);
DigitalIn PE5(PE_5);

bool blink = true;
int testval[2];


void pressed()
{
    blink = false;
    red = 0;
    
    //Test 3.3v, GND, Relay, D3, D4 and D8 ==> Test cover leds will be blinked if wiring is OK
    TagLED = 0; //D3
    GndLED = 1; //D8
    Relay = 0; //D4
    
    //Test PE_2 and PE_6 pins ==> Green user led on Nucleo board will be blinked if wiring is OK
    PE2 = 0;
    testval[0] = PE6;
    PE2 = 1;
    testval[1] = PE6;
    if (testval[0] == 0 && testval[1] == 1) green = 1;
    
    //Test PE_5 and PE_4 pins ==> Blue user led on Nucleo board will be blinked if wiring is OK
    PE4 = 0;
    testval[0] = PE5;
    PE4 = 1;
    testval[1] = PE5;
    if (testval[0] == 0 && testval[1] == 1) blue = 1;
    
}


int main() {
    green = 0;
    red = 1;
    blue = 0;
    GndLED = 0; 
    PE2 = 0;
    PE4 = 0;
    TagLED = 1;
    Relay = 1; //Relay interrupt will be opened
        
    userBtn.fall(&pressed);
    while (1) {
        if (blink){
            red = !red;
            wait(delay);
        }
        else {
            red = 0;
        }
    }     
}