Encender un led con un pulsador
ENCENDER UN LED POR MEDIO DE UN PULSADOR
El sistema consiste en accionar un led por medio de un pulsador, en la grafica siguiente observamos la conexion del circuito con la tarjeta STMF407.
Materiales a utilizar
1 tarjeta STM32F407 1 Protoboard 1 Cable USB Mini 1 Led 1 Resistencia 220 Ω 1 Pulsador Normalmente Abierto (NA)
Desarrollo de la practica
Al desarrollar este proyecto utilizaremos la tarjeta STM32F407, en la cual conectaremos al PD4 a la resistencia que esta en el diodo led y para el pulsador en el pin PD3, para activar el circuito es decir que circule corriente pulsamos el pulsadora activando el led.
Revision 0:1796418c9965, committed 2020-02-17
- Comitter:
- fpachays
- Date:
- Mon Feb 17 05:09:44 2020 +0000
- Commit message:
- Encender un led
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Feb 17 05:09:44 2020 +0000 @@ -0,0 +1,34 @@ +#include "mbed.h" + +// LED connected Pin PC_0 +DigitalOut led(PC_0); + +// Push-Button connected Pin PC_3 +DigitalIn pushButton(PC_3); + +// Main Loop runs in its own thread in the OS +int main() { + + // Active Pull-Up Resistor + pushButton.mode(PullUp); + + // Inifite Loop + while(1) { + + // Check Push-Button + if(pushButton == 0) { + + // LED Turn-On + led = 1; + + } else { + + // LED Turn-Off + led = 0; + } + } +} + + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Feb 17 05:09:44 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file