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
- Committer:
- Jajo
- Date:
- 2016-04-10
- Revision:
- 0:5bf0672c12fc
File content as of revision 0:5bf0672c12fc:
#include "mbed.h"
#include "TextLCD.h"
Serial pc(USBTX,USBRX);
//TextLCD lcd(PTB9, PTB10, PTE2, PTE3, PTE4, PTE5);
TextLCD lcd(D0, D1, D2, D3, D4, D5);
DigitalIn boton1(D6);
DigitalIn boton2(D7);
DigitalIn boton3(D8);
DigitalIn boton4(D9);
DigitalIn boton6(D10);
DigitalIn boton5(D11);
DigitalOut alarma(D12);
int horas;
int minutos=0;
int segundos=0;
int segundos2=25;
//int segundoss=0;
int x=0;
Timer t;
Timer s;
int v=0;
int l=0;
int p=-1;
int z=0;
int b,w;
void reloj(){
if(x==1){
s.start();
segundos2 =25- s.read();
if(segundos2 == 0){
segundos2=25;
s.reset();
s.start();
}
t.start();
segundos = t.read();
if(segundos == 60){
segundos=0;
t.reset();
minutos++;
}
if(minutos==60){
minutos=0;
horas++;
}
}
}
int main(){
while(1){
if(p==1){
if(minutos==1){
alarma=1;
wait(1);
alarma=0;
}
}
if(p==2){
if(minutos==1){
alarma=1;
wait(1);
alarma=0;
}
}
if(p==3){
if(minutos==1){
alarma=1;
wait(1);
alarma=0;
}
}
if(p==4){
if(minutos==1){
alarma=1;
lcd.cls();
w=1;
lcd.locate(0, 0);
lcd.printf("FIN DEL PARTIDO");
t.stop();
s.stop();
s.reset();
t.reset();
lcd.locate(4, 1);
lcd.printf("-L");
lcd.locate(11, 1);
lcd.printf("V-");
lcd.locate(13, 1);
lcd.printf("%d",v);
lcd.locate(0, 1);
lcd.printf("%d",l);
}
}else{
lcd.locate(0, 0);
lcd.printf("T-");
lcd.locate(4, 1);
lcd.printf("-L");
lcd.locate(11, 1);
lcd.printf("V-");
}
if(boton1==1){
x=1;
}
if(boton2==1){
x=0;
t.stop();
s.stop();
s.reset();
segundos2=0;
lcd.locate(14, 0);
lcd.printf("00");
}
if(w==1){
wait(60);
}else{
lcd.locate(14, 0);
lcd.printf("%d",segundos2);
if(boton3==1){
lcd.locate(12,0);
lcd.printf(">");
}else{
lcd.locate(12,0);
lcd.printf("<");
}
}
if(boton2==1){
wait(2);
if(boton2==1){
s.reset();
t.reset();
minutos=0;
segundos=0;
segundos2=0;
lcd.locate(2,0);//unidades de minuto
lcd.printf("%d",minutos);
lcd.locate(5,0);//unidades de segundo
lcd.printf("0%d", segundos);
lcd.locate(4,0);
lcd.printf(":");
//imprimir ceros
}
}
if(minutos<10){
lcd.locate(2,0);//unidades de minuto
lcd.printf("0%d",minutos);
reloj();
}else{
lcd.locate(2,0);//unidades de minuto
lcd.printf("%d",minutos);
}
reloj();
if(segundos<10){
lcd.locate(5,0);//unidades de segundo
lcd.printf("0%d", segundos);
lcd.locate(4,0);
lcd.printf(":");
reloj();
}else{
lcd.locate(5,0);//unidades de segundo
lcd.printf("%d", segundos);
lcd.locate(4,0);
lcd.printf(":");
reloj();
}
if(segundos2<10){
lcd.locate(14, 0);
lcd.printf("0%d",segundos2);
//reloj();
reloj();
}
if(boton4==1){
l++;
wait(.3);
lcd.locate(0, 1);
lcd.printf("%d",l);
}
if(boton5==1){
v++;
wait(.3);
lcd.locate(13, 1);
lcd.printf("%d",v);
}
if(boton6==1){
p++;
wait(.3);
lcd.locate(8, 1);
lcd.printf("%d",p);
}
if(p==5){
p=-1;
}
}
}
