Created
September 10, 2020 12:13
-
-
Save OtacilioN/fe52864ef0ee0802ddb36de8630feb19 to your computer and use it in GitHub Desktop.
5 - Utilizando a biblioteca mbed.h para a placa STM Núcleo desenvolva um programa que faça um led piscar a cada 500 milissegundos, e ao pressionar o botão do usuário o led passe a piscar a cada 1 segundo. Poste o código fonte nesta questão. *
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "mbed.h" | |
DigitalOut led(LED1); | |
InterruptIn button(USER_BUTTON, PullUp); | |
int delay = 500; | |
void pressed() | |
{ | |
led = !led; | |
// Run one cycle inside to make sure that in the very first cycle it turns to 1 sec | |
delay = 1000; | |
wait_ms(delay); | |
} | |
int main() | |
{ | |
button.fall(&pressed); | |
while(1) | |
{ | |
led = !led; | |
wait_ms(delay); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment