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@28:990ab89d08d2, 2020-04-24 (annotated)
- Committer:
- montse
- Date:
- Fri Apr 24 23:18:40 2020 +0000
- Revision:
- 28:990ab89d08d2
- Parent:
- 27:8678c21abbeb
Es el correcto de P4.Ej3
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
montse | 25:32acf45398b4 | 1 | #include "mbed.h" //libreria que nos permite utilizar comandos y sentencias propias de mbed |
montse | 25:32acf45398b4 | 2 | #include <iostream> |
dan | 0:7dec7e9ac085 | 3 | |
montse | 25:32acf45398b4 | 4 | //Mediante el uso del condicional if implementar un programa que permita imprimir diferentes mensajes cuando se presionan al menos tres diferentes teclas. |
montse | 25:32acf45398b4 | 5 | |
montse | 25:32acf45398b4 | 6 | Serial com1(USBTX, USBRX); |
montse | 25:32acf45398b4 | 7 | |
montse | 25:32acf45398b4 | 8 | using namespace std; |
dan | 0:7dec7e9ac085 | 9 | |
montse | 25:32acf45398b4 | 10 | int main() |
montse | 25:32acf45398b4 | 11 | { |
montse | 28:990ab89d08d2 | 12 | while(1){ |
montse | 28:990ab89d08d2 | 13 | |
montse | 25:32acf45398b4 | 14 | int tecla; |
montse | 25:32acf45398b4 | 15 | com1.printf("Cuantas veces al dia te lavas las manos? \n\n"); |
montse | 27:8678c21abbeb | 16 | com1.scanf("%d",&tecla); |
montse | 28:990ab89d08d2 | 17 | |
montse | 25:32acf45398b4 | 18 | if ((tecla <= 9)&&(tecla >= 3)){ |
montse | 25:32acf45398b4 | 19 | com1.printf("Eso es genial. \n"); |
montse | 25:32acf45398b4 | 20 | |
montse | 26:c1f837b137f8 | 21 | com1.printf("Ojala mas personas sean responsables como tu :) \n\n"); |
dan | 0:7dec7e9ac085 | 22 | } |
montse | 25:32acf45398b4 | 23 | |
montse | 26:c1f837b137f8 | 24 | if ((tecla <3)&&(tecla >= 0)){ |
montse | 25:32acf45398b4 | 25 | com1.printf("Eso es triste :( \n"); |
montse | 25:32acf45398b4 | 26 | |
montse | 25:32acf45398b4 | 27 | com1.printf("Hazlo mas seguido y no olvides usar gel antibacterial. \n\n"); |
montse | 25:32acf45398b4 | 28 | } |
montse | 25:32acf45398b4 | 29 | |
montse | 25:32acf45398b4 | 30 | if (tecla >=10){ |
montse | 25:32acf45398b4 | 31 | com1.printf("Vaya! Tu si que te cuidas. \n"); |
montse | 25:32acf45398b4 | 32 | |
montse | 25:32acf45398b4 | 33 | } |
montse | 25:32acf45398b4 | 34 | |
montse | 26:c1f837b137f8 | 35 | com1.printf("Recuerda: Si te cuidas tu, nos cuidamos todos."); |
montse | 28:990ab89d08d2 | 36 | |
montse | 28:990ab89d08d2 | 37 | } |
montse | 25:32acf45398b4 | 38 | } |
montse | 25:32acf45398b4 | 39 |