Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp@26:0d2df6a1ed26, 2020-04-15 (annotated)
- Committer:
- montse
- Date:
- Wed Apr 15 20:42:25 2020 +0000
- Revision:
- 26:0d2df6a1ed26
- Parent:
- 25:869f212440f8
Programa que enciende un led al presionar un boton
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| montse | 25:869f212440f8 | 1 | #include "mbed.h" //libreria que nos permite utilizar comandos y sentencias propias de mbed |
| montse | 25:869f212440f8 | 2 | #include <iostream> |
| montse | 25:869f212440f8 | 3 | #include <stdio.h> |
| dan | 0:7dec7e9ac085 | 4 | |
| montse | 25:869f212440f8 | 5 | //Crear un programa el cual al presionar un botón encienda un LED y al dejar de presionar que lo apague. |
| montse | 25:869f212440f8 | 6 | |
| montse | 25:869f212440f8 | 7 | Serial com1(USBTX, USBRX); |
| montse | 25:869f212440f8 | 8 | DigitalIn boton1(PTC6); |
| dan | 0:7dec7e9ac085 | 9 | DigitalOut myled(LED1); |
| dan | 0:7dec7e9ac085 | 10 | |
| montse | 25:869f212440f8 | 11 | int main() |
| montse | 25:869f212440f8 | 12 | { |
| montse | 26:0d2df6a1ed26 | 13 | while(1) |
| montse | 25:869f212440f8 | 14 | { |
| montse | 26:0d2df6a1ed26 | 15 | if (boton1.read()==0) |
| montse | 26:0d2df6a1ed26 | 16 | { |
| montse | 26:0d2df6a1ed26 | 17 | myled=1; |
| montse | 26:0d2df6a1ed26 | 18 | } |
| montse | 26:0d2df6a1ed26 | 19 | |
| montse | 26:0d2df6a1ed26 | 20 | else{ |
| montse | 26:0d2df6a1ed26 | 21 | myled=0; |
| montse | 26:0d2df6a1ed26 | 22 | } |
| montse | 25:869f212440f8 | 23 | } |
| dan | 0:7dec7e9ac085 | 24 | } |
| montse | 25:869f212440f8 | 25 | |
| montse | 25:869f212440f8 | 26 | |
| montse | 25:869f212440f8 | 27 | |
| montse | 25:869f212440f8 | 28 |