George Cochrane
/
ScoreCount2
Peter's version
Fork of ScoreCount by
Revision 4:7cec137649a0, committed 2013-05-02
- Comitter:
- gcme93
- Date:
- Thu May 02 16:07:04 2013 +0000
- Parent:
- 3:8e42915e7375
- Child:
- 5:a50e02fc49cd
- Commit message:
- Yo
Changed in this revision
--- a/main.cpp Thu May 02 13:35:41 2013 +0000 +++ b/main.cpp Thu May 02 16:07:04 2013 +0000 @@ -2,6 +2,7 @@ #include "TSISensor.h" #include "TextLCD.h" #include "process_signal.h" +#include "reciever.h" TSISensor tsi; @@ -63,7 +64,7 @@ int signal; //Signal input here! - signal=1; + signal=Interrogate(); hit= process_signal(signal); @@ -102,6 +103,7 @@ end: Blue=0; +Green=0; lcd.cls(); lcd.locate(0,0); lcd.printf(" - GAME OVER - ...you suck");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/reciever.cpp Thu May 02 16:07:04 2013 +0000 @@ -0,0 +1,60 @@ +#include "mbed.h" + +char string[64]; +int p; + + +int Interrogate() +{ +Serial myserial(PTC4,PTC3); +myserial.baud(1200); +DigitalOut blueled(LED1); + + + + + + + while(1) + { + while(!myserial.readable()) + { + blueled=1; + } + + if(myserial.readable()) + { + blueled=0; + myserial.scanf("%s",string); + + + + if((strstr (string,"011")) != NULL) + { + p = 1; + } + if((strstr (string,"012")) != NULL) + { + p = 2; + } + if((strstr (string,"013")) != NULL) + { + p = 3; + } + if((strstr (string,"014")) != NULL) + { + p = 4; + } + for(int f=0;f<5;f++) + { + blueled=!blueled; + wait(0.2); + return p; + + } + + + } + + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/reciever.h Thu May 02 16:07:04 2013 +0000 @@ -0,0 +1,1 @@ +int Interrogate(void); \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/transmitter.cpp Thu May 02 16:07:04 2013 +0000 @@ -0,0 +1,52 @@ +#include "mbed.h" +#include "TSISensor.h" + + +Serial pc(USBTX,USBRX); +PwmOut clk(PTD4); + +TSISensor tsi; + +//PTD4----->|-------PTC4 (serial TX) + +char c[4] = "011"; //011 for Team A; 012 for Pack B; 013 for Pack C; 014 for Pack D +float a; +char ldriv; + + +char msg[5]; + +int Fire() +{ + +sprintf(msg,"\r"); +int i=0; +int j=0; +ldriv=1; +myserial.baud(1200); +clk.period(26e-6); +clk=0.5; + while(1) + { + blueled = 1; + a = tsi.readPercentage(); + if(a>0.1) + { + for(j = 0; j < 5; j++) + { + blueled = 0; + i=(i+1) % 3; + myserial.putc(c[i]); + if(i==0) + { + ldriv=0; + wait(0.1); + ldriv=1; + } + } + myserial.putc(msg[0]); + blueled = 1; + while(tsi.readPercentage() > 0.1){} + } + } +}