prova

Dependencies:   mbed

DORA-myTest.cpp

Committer:
pinofal
Date:
2022-05-03
Revision:
2:64e3ac1c2786
Parent:
TestPWM.cpp@ 1:762bbfe2fc71

File content as of revision 2:64e3ac1c2786:


#include "mbed.h"
#include<stdlib.h>

// Definizione periferica USB seriale del PC
Serial pc(USBTX, USBRX, 921600); // seriale di comunicazione con il PC. Associati a PA_11 e PA_12

// User Button, LED  
DigitalIn myButton(USER_BUTTON); // pulsante Blu sulla scheda. Associato a PC_13
DigitalOut myLed(LED2); // LED verde sulla scheda. Associato a PA_5


// digital Out di Prova
DigitalOut Relay5V (PA_10);

/**********/
/*  MAIN  */
/**********/
int main()
{
   
    // messaggio di benvenuto
    pc.printf("\r\n************  Hallo ************** \r\n");
    pc.printf("************* Test ***************\r\n");

    // out di prova
    Relay5V = 0;
    
     // Ciclo principale
    while(true)
    {
        /*
        Relay5V=0;
        wait(1);
        Relay5V=1;
        wait(1);
        */
        
        // accende alimentatore se è premuto lo User Button
        if(myButton == 0)
        {
            // accendi LED su scheda
            myLed = 1;
            
            // accendi relay a 5V
            Relay5V = 1;
        }
        else
        {
            // spegni LED su scheda
            myLed = 0;
            
            // spegni relay a 5V
            Relay5V = 0;
            
        } // if(myButton==0)
        
    } // while(true) Principale
}