Skip to content

Instantly share code, notes, and snippets.

@OtacilioN
Created September 10, 2020 12:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OtacilioN/fe52864ef0ee0802ddb36de8630feb19 to your computer and use it in GitHub Desktop.
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. *
#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