Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
LED-Button-Polling.cpp
00001 // Tested: NUCLE-L476RG 00002 00003 #include "mbed.h" 00004 00005 // crea oggetti Button, LED e serialPC 00006 DigitalIn myButton(USER_BUTTON); 00007 DigitalOut myLed(LED1); 00008 DigitalIn InMIMA(PA_0); //PC_1; PB_0; PA_1; PA_0 00009 DigitalOut OutSC(PC_0); 00010 DigitalIn InSC(PA_10); 00011 DigitalOut OutMIMA(PA_9); //PB_3; PB_6; PC_7; PA_9 00012 00013 00014 Serial pc(USBTX, USBRX, 921600); 00015 00016 00017 /********/ 00018 /* MAIN */ 00019 /********/ 00020 int main() 00021 { 00022 // messaggio di benvenuto 00023 pc.printf("\r\nHello World \r\n"); 00024 myLed = 1; // Accendi LED 00025 wait_ms(1000); 00026 myLed = 0; // Accendi LED 00027 wait_ms(1000); 00028 00029 00030 //imposta il funzionamento del pulsante come "PullDown": Aperto = '0'. L'altra modalità di funzinamento è PullUp 00031 myButton.mode(PullUp); 00032 InMIMA.mode(PullUp); 00033 InSC.mode(PullUp); 00034 00035 // POLLING: replica sul LED myLED lo stato del pulsante myButton 00036 while(true) 00037 { 00038 //+++++ INIZIO Comunicazione da STM32 verso MIMA ++++++++++++++ 00039 OutSC=myButton; 00040 if (InMIMA == 0) 00041 { 00042 // Button is pressed 00043 myLed = 1; // Accendi LED 00044 pc.printf("InMIMA = 0 \r\n"); 00045 } 00046 else 00047 { 00048 // Button i released 00049 myLed = 0; // Spegni LED 00050 pc.printf("InMIMA = 1 \r\n"); 00051 } 00052 //+++++ FINE Comunicazione da STM32 verso MIMA ++++++++++++++ 00053 00054 //+++++ INIZIO Comunicazione da S/C verso STM32 ++++++++++++++ 00055 OutMIMA=myButton; 00056 if (InSC == 0) 00057 { 00058 // Button is pressed 00059 myLed = 1; // Accendi LED 00060 pc.printf("InSC = 0 \r\n"); 00061 } 00062 else 00063 { 00064 // Button i released 00065 myLed = 0; // Spegni LED 00066 pc.printf("InSC = 1 \r\n"); 00067 } 00068 //+++++ FINE Comunicazione da S/C verso STM32 ++++++++++++++ 00069 00070 pc.printf("\r\n"); // per facilità di lettura 00071 wait_ms(200); 00072 00073 } 00074 00075 }
Generated on Tue Aug 23 2022 18:55:28 by
1.7.2