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.
Revision 0:045fa418afc7, committed 2020-02-01
- Comitter:
- mvillamar
- Date:
- Sat Feb 01 17:49:02 2020 +0000
- Commit message:
- UPS; Contador del 1 al 256 el cual muestra el valor decimal, hexadecimal y ascii por el puerto serie
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 Sat Feb 01 17:49:02 2020 +0000
@@ -0,0 +1,91 @@
+//ENVIA UNCONTADOR DEL 1 AL 256 Y LO MUESTRA POR EL PUERTO SRIAL EN FORMATO DIGITAL ASCII Y HEXADECIMAL.
+
+
+#include "mbed.h"
+
+int i = 0; //Inicializa la variable i con el valor de 1
+bool a; //Crea la variable a como booleana
+//short b=10; //2^8
+//int c,d,f,t,u; //2^32
+DigitalOut Bled(PD_15); //LED AZUL
+DigitalOut Vled(PD_12); //LED VERDE
+DigitalOut Nled(PD_13); //LED NARANJA
+DigitalOut Rled(PD_14); //LED ROJO
+
+Serial device (PA_2,PA_3);
+
+int avance();
+int retroceso();
+
+int main() //Inicializa programa principal
+{
+
+ while(i<=256) {
+ //device.printf("Hola \n"); // \n es un enter
+ //device.printf("e"); //el envio es en ASCII
+ device.baud(115200);
+ device.printf("%d",i);
+ device.printf(" ");
+ wait(0.03);
+ //avance();
+ //retroceso();
+ i++;
+ }
+ device.printf("\n");
+ i=0;
+
+ while(i<=256) {
+ device.baud(115200);
+ device.printf("%c",i);
+ device.printf(" ");
+ wait(0.03);
+ i++;
+ }
+ device.printf("\r\n");
+ i=0;
+
+ while(i<=256) {
+ device.baud(115200);
+ device.printf("%x",i);
+ device.printf(" ");
+ wait(0.03);
+ i++;
+ }
+
+}
+
+int avance()
+{
+ Bled = 1; // NIVEL HIGH
+ wait(0.1); // ESPERA 1 SEGUNDO
+ Bled = 0; // NIVEL LOW
+ Vled = 1; // NIVEL HIGH
+ wait(0.1); // ESPERA 1 SEGUNDO
+ Vled = 0; // NIVEL LOW
+ Nled = 1; // NIVEL HIGH
+ wait(0.1); // ESPERA 1 SEGUNDO
+ Nled = 0; // NIVEL LOW
+ Rled = 1; // NIVEL HIGH
+ wait(0.1); // ESPERA 1 SEGUNDO
+ Rled = 0; // NIVEL LOW
+ Bled = 1; // NIVEL HIGH
+ wait(0.1); // ESPERA 1 SEGUNDO
+ Bled = 0; // NIVEL LOW
+}
+
+int retroceso()
+{
+ Rled = 1; // NIVEL HIGH
+ wait(0.1); // ESPERA 1 SEGUNDO
+ Rled = 0; // NIVEL LOW
+ Nled = 1; // NIVEL HIGH
+ wait(0.1); // ESPERA 1 SEGUNDO
+ Nled = 0; // NIVEL LOW
+ Vled = 1; // NIVEL HIGH
+ wait(0.1); // ESPERA 1 SEGUNDO
+ Vled = 0; // NIVEL LOW
+ Bled = 1; // NIVEL HIGH
+ wait(0.1); // ESPERA 1 SEGUNDO
+ Bled = 0; // NIVEL LOW
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Feb 01 17:49:02 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file