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
Fork of Amaldi_3_Exercise_LED-Button_Polling by
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 Serial pc(USBTX, USBRX); 00009 00010 00011 /********/ 00012 /* MAIN */ 00013 /********/ 00014 int main() 00015 { 00016 // imposta velocità della comunicazione con il PC 00017 pc.baud(921600); 00018 00019 // messaggio di benvenuto 00020 pc.printf("\r\nHallo Amaldi Students - Exercise 3 \r\n"); 00021 00022 //imposta il funzionamento del pulsante come "PullDown": Aperto = '0'. L'altra modalità di funzinamento è PullUp 00023 myButton.mode(PullDown); 00024 00025 // POLLING: replica sul LED myLED lo stato del pulsante myButton 00026 while(true) 00027 { 00028 if (myButton == 1) 00029 { 00030 // Button is pressed 00031 myLed = 1; // Accendi LED 00032 } 00033 else 00034 { 00035 // Button i released 00036 myLed = 0; // Spegni LED 00037 } 00038 } 00039 } 00040
Generated on Wed Jul 13 2022 04:08:30 by
1.7.2
