![](/media/cache/profiles/004acbc8eefec9fe0629b15f52b94bcf.50x50_q85.jpg)
Peter's version
Fork of ScoreCount by
transmitter.cpp@5:a50e02fc49cd, 2013-05-02 (annotated)
- Committer:
- gcme93
- Date:
- Thu May 02 21:18:42 2013 +0000
- Revision:
- 5:a50e02fc49cd
- Parent:
- 4:7cec137649a0
Thursday Night (receiver and transmitter code too)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gcme93 | 4:7cec137649a0 | 1 | #include "mbed.h" |
gcme93 | 4:7cec137649a0 | 2 | #include "TSISensor.h" |
gcme93 | 4:7cec137649a0 | 3 | |
gcme93 | 4:7cec137649a0 | 4 | |
gcme93 | 4:7cec137649a0 | 5 | Serial pc(USBTX,USBRX); |
gcme93 | 4:7cec137649a0 | 6 | PwmOut clk(PTD4); |
gcme93 | 5:a50e02fc49cd | 7 | DigitalOut blueled(LED1); |
gcme93 | 5:a50e02fc49cd | 8 | Serial myserial(PTC4, PTC3); |
gcme93 | 5:a50e02fc49cd | 9 | |
gcme93 | 4:7cec137649a0 | 10 | |
gcme93 | 4:7cec137649a0 | 11 | TSISensor tsi; |
gcme93 | 4:7cec137649a0 | 12 | |
gcme93 | 4:7cec137649a0 | 13 | //PTD4----->|-------PTC4 (serial TX) |
gcme93 | 4:7cec137649a0 | 14 | |
gcme93 | 4:7cec137649a0 | 15 | char c[4] = "011"; //011 for Team A; 012 for Pack B; 013 for Pack C; 014 for Pack D |
gcme93 | 4:7cec137649a0 | 16 | float a; |
gcme93 | 4:7cec137649a0 | 17 | char ldriv; |
gcme93 | 4:7cec137649a0 | 18 | |
gcme93 | 4:7cec137649a0 | 19 | |
gcme93 | 4:7cec137649a0 | 20 | char msg[5]; |
gcme93 | 4:7cec137649a0 | 21 | |
gcme93 | 4:7cec137649a0 | 22 | int Fire() |
gcme93 | 4:7cec137649a0 | 23 | { |
gcme93 | 4:7cec137649a0 | 24 | |
gcme93 | 4:7cec137649a0 | 25 | sprintf(msg,"\r"); |
gcme93 | 4:7cec137649a0 | 26 | int i=0; |
gcme93 | 4:7cec137649a0 | 27 | int j=0; |
gcme93 | 4:7cec137649a0 | 28 | ldriv=1; |
gcme93 | 4:7cec137649a0 | 29 | myserial.baud(1200); |
gcme93 | 4:7cec137649a0 | 30 | clk.period(26e-6); |
gcme93 | 4:7cec137649a0 | 31 | clk=0.5; |
gcme93 | 4:7cec137649a0 | 32 | while(1) |
gcme93 | 4:7cec137649a0 | 33 | { |
gcme93 | 4:7cec137649a0 | 34 | blueled = 1; |
gcme93 | 4:7cec137649a0 | 35 | a = tsi.readPercentage(); |
gcme93 | 4:7cec137649a0 | 36 | if(a>0.1) |
gcme93 | 4:7cec137649a0 | 37 | { |
gcme93 | 4:7cec137649a0 | 38 | for(j = 0; j < 5; j++) |
gcme93 | 4:7cec137649a0 | 39 | { |
gcme93 | 4:7cec137649a0 | 40 | blueled = 0; |
gcme93 | 4:7cec137649a0 | 41 | i=(i+1) % 3; |
gcme93 | 4:7cec137649a0 | 42 | myserial.putc(c[i]); |
gcme93 | 4:7cec137649a0 | 43 | if(i==0) |
gcme93 | 4:7cec137649a0 | 44 | { |
gcme93 | 4:7cec137649a0 | 45 | ldriv=0; |
gcme93 | 4:7cec137649a0 | 46 | wait(0.1); |
gcme93 | 4:7cec137649a0 | 47 | ldriv=1; |
gcme93 | 4:7cec137649a0 | 48 | } |
gcme93 | 4:7cec137649a0 | 49 | } |
gcme93 | 4:7cec137649a0 | 50 | myserial.putc(msg[0]); |
gcme93 | 4:7cec137649a0 | 51 | blueled = 1; |
gcme93 | 4:7cec137649a0 | 52 | while(tsi.readPercentage() > 0.1){} |
gcme93 | 4:7cec137649a0 | 53 | } |
gcme93 | 4:7cec137649a0 | 54 | } |
gcme93 | 4:7cec137649a0 | 55 | } |