José Neto / Mbed 2 deprecated ProjetoFinal

Dependencies:   mbed-rtos mbed

Committer:
zeneto
Date:
Fri Jun 29 17:25:06 2018 +0000
Revision:
0:00e9a2a6f73a
Child:
1:e7d2231abccc
test buzzer

Who changed what in which revision?

UserRevisionLine numberNew contents of line
zeneto 0:00e9a2a6f73a 1 #include "mbed.h"
zeneto 0:00e9a2a6f73a 2
zeneto 0:00e9a2a6f73a 3 const int pushButton = 16;
zeneto 0:00e9a2a6f73a 4 const int buzzer = 1;
zeneto 0:00e9a2a6f73a 5
zeneto 0:00e9a2a6f73a 6 void setup() {
zeneto 0:00e9a2a6f73a 7 pinMode(pushButton, INPUT); //DEFINE A PORTA COMO ENTRADA
zeneto 0:00e9a2a6f73a 8 pinMode(buzzer, OUTPUT); //DEFINE A PORTA COMO SAÍDA
zeneto 0:00e9a2a6f73a 9 }
zeneto 0:00e9a2a6f73a 10 void loop(){
zeneto 0:00e9a2a6f73a 11 leitura = digitalRead(pushButton); //LÊ O VALOR NA PORTA DIGITAL E ARMAZENA NA VARIÁVEL
zeneto 0:00e9a2a6f73a 12
zeneto 0:00e9a2a6f73a 13 if(leitura == 0){ //SE O VALOR LIDO FOR IGUAL A 0, FAZ
zeneto 0:00e9a2a6f73a 14 digitalWrite(buzzer, HIGH); //LED ACESO
zeneto 0:00e9a2a6f73a 15 }else{ //SENÃO, FAZ
zeneto 0:00e9a2a6f73a 16 digitalWrite(buzzer, LOW); //LED APAGADO
zeneto 0:00e9a2a6f73a 17 }
zeneto 0:00e9a2a6f73a 18 }