José Neto / Mbed 2 deprecated ProjetoFinal

Dependencies:   mbed-rtos mbed

Revision:
1:e7d2231abccc
Parent:
0:00e9a2a6f73a
Child:
2:82e0ae145867
--- a/main.cpp	Fri Jun 29 17:25:06 2018 +0000
+++ b/main.cpp	Tue Jul 03 18:06:29 2018 +0000
@@ -1,18 +1,14 @@
 #include "mbed.h"
-
-const int pushButton = 16;
-const int buzzer = 1;
-
-void setup() {
-    pinMode(pushButton, INPUT); //DEFINE A PORTA COMO ENTRADA
-    pinMode(buzzer, OUTPUT); //DEFINE A PORTA COMO SAÍDA
+ 
+InterruptIn btn(D7);
+DigitalOut led(LED_BLUE);
+ 
+void button_pressed() {
+  led = !led; // toggle the LED
 }
-void loop(){
-leitura = digitalRead(pushButton); //LÊ O VALOR NA PORTA DIGITAL E ARMAZENA NA VARIÁVEL
  
-  if(leitura == 0){ //SE O VALOR LIDO FOR IGUAL A 0, FAZ
-      digitalWrite(buzzer, HIGH); //LED ACESO
-  }else{ //SENÃO, FAZ
-    digitalWrite(buzzer, LOW); //LED APAGADO
-  }
+int main(int, char**) {
+  btn.fall(&button_pressed); // whenever the button falls, execute button_pressed function
+ 
+  while (1) {}
 }
\ No newline at end of file