ok
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2019 ARM Limited 00003 * SPDX-License-Identifier: Apache-2.0 00004 */ 00005 00006 #include "mbed.h" 00007 #include "platform/mbed_thread.h" 00008 00009 00010 00011 DigitalOut direccion(D2); 00012 PwmOut PWM_velocidad(D3); 00013 00014 00015 //Interfaces para USER_BUTTON 00016 //DigitalIn userButton(USER_BUTTON); 00017 //bool buttonDown = false; 00018 00019 int main() 00020 { 00021 00022 direccion = 0; // En direccion de las manecillas del reloj. 00023 00024 float valor_velocidad = 0; //representa un 0% 00025 00026 PWM_velocidad.period(0.0001f); //Declaramos el periodo 00027 PWM_velocidad.write(1.0f); 00028 00029 00030 thread_sleep_for(5000); 00031 00032 PWM_velocidad.write(0.0f); 00033 00034 00035 /* 00036 if (userButton) { // button is pressed 00037 if (!buttonDown) { // a new button press 00038 00039 //valor_velocidad = valor_velocidad + 0.004; //Representa un aumento de un 10%. 00040 //PWM_velocidad.write(valor_velocidad); 00041 00042 buttonDown = true; // record that the button is now down so we don't count one press lots of times 00043 thread_sleep_for(10); // ignore anything for 10ms, a very basic way to de-bounce the button. 00044 } 00045 00046 } else { // button isn't pressed 00047 buttonDown = false; 00048 } 00049 */ 00050 00051 } 00052 00053
Generated on Fri Jul 15 2022 18:31:49 by
1.7.2