victor gomez
/
7-Controlador-Motor-DC
ok
Diff: main.cpp
- Revision:
- 0:f9baa136dbc3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Jul 01 20:02:37 2021 +0000 @@ -0,0 +1,53 @@ +/* mbed Microcontroller Library + * Copyright (c) 2019 ARM Limited + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "mbed.h" +#include "platform/mbed_thread.h" + + + +DigitalOut direccion(D2); +PwmOut PWM_velocidad(D3); + + +//Interfaces para USER_BUTTON +//DigitalIn userButton(USER_BUTTON); +//bool buttonDown = false; + +int main() +{ + + direccion = 0; // En direccion de las manecillas del reloj. + + float valor_velocidad = 0; //representa un 0% + + PWM_velocidad.period(0.0001f); //Declaramos el periodo + PWM_velocidad.write(1.0f); + + + thread_sleep_for(5000); + + PWM_velocidad.write(0.0f); + + + /* + if (userButton) { // button is pressed + if (!buttonDown) { // a new button press + + //valor_velocidad = valor_velocidad + 0.004; //Representa un aumento de un 10%. + //PWM_velocidad.write(valor_velocidad); + + buttonDown = true; // record that the button is now down so we don't count one press lots of times + thread_sleep_for(10); // ignore anything for 10ms, a very basic way to de-bounce the button. + } + + } else { // button isn't pressed + buttonDown = false; + } + */ + +} + +