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.
main.cpp@0:00e9a2a6f73a, 2018-06-29 (annotated)
- 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?
User | Revision | Line number | New 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 | } |