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.
Dependencies: mbed
main.cpp@1:c79ac0240e88, 2014-06-26 (annotated)
- Committer:
- lina94
- Date:
- Thu Jun 26 02:12:57 2014 +0000
- Revision:
- 1:c79ac0240e88
- Parent:
- 0:1644c3e66842
prueba 2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lina94 | 0:1644c3e66842 | 1 | #include "mbed.h" |
lina94 | 0:1644c3e66842 | 2 | |
lina94 | 0:1644c3e66842 | 3 | Ticker visualiza; |
lina94 | 0:1644c3e66842 | 4 | Ticker cuenta; |
lina94 | 0:1644c3e66842 | 5 | Ticker Led_Test; |
lina94 | 0:1644c3e66842 | 6 | |
lina94 | 0:1644c3e66842 | 7 | DigitalOut Testigo1(LED_RED); |
lina94 | 0:1644c3e66842 | 8 | DigitalOut Testigo2(LED_GREEN); |
lina94 | 0:1644c3e66842 | 9 | DigitalOut SALIDA(D7); |
lina94 | 0:1644c3e66842 | 10 | |
lina94 | 0:1644c3e66842 | 11 | BusOut transistores(D8,D9); |
lina94 | 0:1644c3e66842 | 12 | BusOut segmentos ( D0, D1, D2, D3, D4, D5, D6); |
lina94 | 0:1644c3e66842 | 13 | // tabla de segmentos |
lina94 | 0:1644c3e66842 | 14 | //para d6 a d0 |
lina94 | 0:1644c3e66842 | 15 | const char camino1[32] = {0x3F, 0x5F, 0x7E, 0x7B, 0x77, 0x6F, 0x7D, 0x5F, 0x7E, 0x03, 0x03, 0x03, 0x03, 0x7E, 0x6F, 0x77, 0x7B, 0x7D, 0x03, 0x03, 0x03, 0x03, 0x03, 0x7E, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}; |
lina94 | 0:1644c3e66842 | 16 | const char camino2[32] = {0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x7E, 0x7B, 0x5F, 0x6F, 0x03, 0x03, 0x03, 0x03, 0x03, 0x3F, 0x7E, 0x7E, 0x7D, 0x7E, 0x03, 0x3F, 0x7D, 0x7E, 0x6F, 0x77, 0x7B, 0x7E, 0x5F}; |
lina94 | 0:1644c3e66842 | 17 | // const char camino1[32] = {0x01, 0x02, 0x3f, 0x6f, 0x77, 0x04, 0x5f, 0x02, 0x3f, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x04, 0x77, 0x6f, 0x5f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; |
lina94 | 0:1644c3e66842 | 18 | //const char camino2[32] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x6f, 0x02, 0x04, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x5f, 0x3f, 0x5f, 0x3f, 0xff, 0x01, 0x5f, 0x3f, 0x04, 0x77, 0x6f, 0x3f, 0x02}; |
lina94 | 0:1644c3e66842 | 19 | |
lina94 | 0:1644c3e66842 | 20 | |
lina94 | 0:1644c3e66842 | 21 | char unidades,decenas, aumento; |
lina94 | 0:1644c3e66842 | 22 | |
lina94 | 0:1644c3e66842 | 23 | void cambio(){ |
lina94 | 0:1644c3e66842 | 24 | static bool bandera; |
lina94 | 0:1644c3e66842 | 25 | static char cont_estado; |
lina94 | 0:1644c3e66842 | 26 | cont_estado ++; |
lina94 | 0:1644c3e66842 | 27 | bandera = !bandera; |
lina94 | 0:1644c3e66842 | 28 | if (bandera){ |
lina94 | 0:1644c3e66842 | 29 | transistores = 0x3; |
lina94 | 0:1644c3e66842 | 30 | segmentos = camino1[unidades]; |
lina94 | 0:1644c3e66842 | 31 | transistores = 0x2; |
lina94 | 0:1644c3e66842 | 32 | } |
lina94 | 0:1644c3e66842 | 33 | else { |
lina94 | 0:1644c3e66842 | 34 | transistores = 0x3; |
lina94 | 0:1644c3e66842 | 35 | segmentos = camino2[decenas]; |
lina94 | 0:1644c3e66842 | 36 | transistores = 0x1; |
lina94 | 0:1644c3e66842 | 37 | } |
lina94 | 0:1644c3e66842 | 38 | |
lina94 | 0:1644c3e66842 | 39 | } |
lina94 | 0:1644c3e66842 | 40 | void conteo () |
lina94 | 0:1644c3e66842 | 41 | { |
lina94 | 0:1644c3e66842 | 42 | unidades++; |
lina94 | 1:c79ac0240e88 | 43 | |
lina94 | 0:1644c3e66842 | 44 | if (unidades > 32) |
lina94 | 0:1644c3e66842 | 45 | { |
lina94 | 0:1644c3e66842 | 46 | unidades = 0; |
lina94 | 0:1644c3e66842 | 47 | } |
lina94 | 1:c79ac0240e88 | 48 | |
lina94 | 0:1644c3e66842 | 49 | |
lina94 | 0:1644c3e66842 | 50 | void prueba_led() |
lina94 | 0:1644c3e66842 | 51 | { |
lina94 | 1:c79ac0240e88 | 52 | Testigo2 = 0; |
lina94 | 0:1644c3e66842 | 53 | } |
lina94 | 0:1644c3e66842 | 54 | |
lina94 | 0:1644c3e66842 | 55 | int main(void) |
lina94 | 0:1644c3e66842 | 56 | { |
lina94 | 0:1644c3e66842 | 57 | SALIDA = 1; |
lina94 | 0:1644c3e66842 | 58 | transistores = 0x3; |
lina94 | 0:1644c3e66842 | 59 | visualiza.attach(&cambio,0.008333); // tiempo de visualizacion |
lina94 | 0:1644c3e66842 | 60 | cuenta.attach(&conteo,1); // tiempo de incremento de la variable |
lina94 | 0:1644c3e66842 | 61 | Led_Test.attach(&prueba_led,1.7); |
lina94 | 1:c79ac0240e88 | 62 | Testigo1 = 0; |
lina94 | 1:c79ac0240e88 | 63 | Testigo2 = 0; |
lina94 | 0:1644c3e66842 | 64 | while(1) |
lina94 | 0:1644c3e66842 | 65 | { |
lina94 | 0:1644c3e66842 | 66 | |
lina94 | 1:c79ac0240e88 | 67 | Testigo1 = 0; |
lina94 | 0:1644c3e66842 | 68 | |
lina94 | 0:1644c3e66842 | 69 | } |
lina94 | 0:1644c3e66842 | 70 | } |