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@27:681516f418e5, 2020-04-12 (annotated)
- Committer:
- montse
- Date:
- Sun Apr 12 02:49:53 2020 +0000
- Revision:
- 27:681516f418e5
- Parent:
- 26:0abd50bf69ae
Ejercicio 3 correspondiente a la practica 5.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
montse | 26:0abd50bf69ae | 1 | #include "mbed.h" //libreria que nos permite utilizar comandos y sentencias propias de mbed |
montse | 25:2c225aab91ae | 2 | |
montse | 26:0abd50bf69ae | 3 | /*Diseñar un programa que permita adquirir el valor de un botón de la tarjeta (elegir cualquiera) y dependiendo de si está en alto o en bajo enviar un mensaje de botón |
montse | 26:0abd50bf69ae | 4 | presionado o botón no presionado. (Utilizar una función con argumentos y sin retorno de valor)*/ |
dan | 0:7dec7e9ac085 | 5 | |
montse | 25:2c225aab91ae | 6 | Serial com1(USBTX, USBRX); |
montse | 27:681516f418e5 | 7 | DigitalIn boton1(PTC6); |
dan | 0:7dec7e9ac085 | 8 | |
montse | 26:0abd50bf69ae | 9 | void Boton(int Si, int No) |
montse | 25:2c225aab91ae | 10 | { |
montse | 26:0abd50bf69ae | 11 | int pulsado; |
montse | 27:681516f418e5 | 12 | int sinpulsar; |
montse | 26:0abd50bf69ae | 13 | pulsado = Si; |
montse | 26:0abd50bf69ae | 14 | sinpulsar = No; |
montse | 26:0abd50bf69ae | 15 | |
montse | 27:681516f418e5 | 16 | if(Si==1) |
montse | 27:681516f418e5 | 17 | { |
montse | 27:681516f418e5 | 18 | com1.printf("El boton esta pulsado \n", pulsado); |
montse | 27:681516f418e5 | 19 | } |
montse | 27:681516f418e5 | 20 | |
montse | 27:681516f418e5 | 21 | else |
montse | 27:681516f418e5 | 22 | { |
montse | 26:0abd50bf69ae | 23 | com1.printf("El boton no esta pulsado \n", sinpulsar); |
montse | 27:681516f418e5 | 24 | } |
montse | 27:681516f418e5 | 25 | |
montse | 25:2c225aab91ae | 26 | } |
montse | 27:681516f418e5 | 27 | |
montse | 26:0abd50bf69ae | 28 | int main () |
montse | 26:0abd50bf69ae | 29 | { |
montse | 26:0abd50bf69ae | 30 | int e1,e2; |
montse | 26:0abd50bf69ae | 31 | |
montse | 27:681516f418e5 | 32 | e1 = boton1; |
montse | 26:0abd50bf69ae | 33 | e2 = !e1; |
montse | 26:0abd50bf69ae | 34 | |
montse | 26:0abd50bf69ae | 35 | Boton(e1,e2); |
montse | 26:0abd50bf69ae | 36 | |
montse | 26:0abd50bf69ae | 37 | |
montse | 26:0abd50bf69ae | 38 | } |