Space / Mbed 2 deprecated DORA-myTest

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers DORA-myTest.cpp Source File

DORA-myTest.cpp

00001 
00002 #include "mbed.h"
00003 #include<stdlib.h>
00004 
00005 // Definizione periferica USB seriale del PC
00006 Serial pc(USBTX, USBRX, 921600); // seriale di comunicazione con il PC. Associati a PA_11 e PA_12
00007 
00008 // User Button, LED  
00009 DigitalIn myButton(USER_BUTTON); // pulsante Blu sulla scheda. Associato a PC_13
00010 DigitalOut myLed(LED2); // LED verde sulla scheda. Associato a PA_5
00011 
00012 
00013 // digital Out di Prova
00014 DigitalOut Relay5V (PA_10);
00015 
00016 /**********/
00017 /*  MAIN  */
00018 /**********/
00019 int main()
00020 {
00021    
00022     // messaggio di benvenuto
00023     pc.printf("\r\n************  Hallo ************** \r\n");
00024     pc.printf("************* Test ***************\r\n");
00025 
00026     // out di prova
00027     Relay5V = 0;
00028     
00029      // Ciclo principale
00030     while(true)
00031     {
00032         /*
00033         Relay5V=0;
00034         wait(1);
00035         Relay5V=1;
00036         wait(1);
00037         */
00038         
00039         // accende alimentatore se è premuto lo User Button
00040         if(myButton == 0)
00041         {
00042             // accendi LED su scheda
00043             myLed = 1;
00044             
00045             // accendi relay a 5V
00046             Relay5V = 1;
00047         }
00048         else
00049         {
00050             // spegni LED su scheda
00051             myLed = 0;
00052             
00053             // spegni relay a 5V
00054             Relay5V = 0;
00055             
00056         } // if(myButton==0)
00057         
00058     } // while(true) Principale
00059 }