![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
02/07/15
Dependencies: mbed
main.cpp@4:e61cd14ec4f0, 2015-07-01 (annotated)
- Committer:
- aidanPJG
- Date:
- Wed Jul 01 11:02:10 2015 +0000
- Revision:
- 4:e61cd14ec4f0
- Parent:
- 3:1ef4740c5a64
- Child:
- 7:d6f78ba7c5f7
Before I go making radical changes to calculate the speed.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
aidanPJG | 0:7f5f4575bc6f | 1 | #include "mbed.h" |
aidanPJG | 4:e61cd14ec4f0 | 2 | #include <time.h> |
aidanPJG | 4:e61cd14ec4f0 | 3 | #include <string> |
aidanPJG | 4:e61cd14ec4f0 | 4 | #include <iostream> |
aidanPJG | 0:7f5f4575bc6f | 5 | |
aidanPJG | 4:e61cd14ec4f0 | 6 | Serial pc(USBTX, USBRX); // tx, rx //defines the communication between MBed and pc |
aidanPJG | 4:e61cd14ec4f0 | 7 | DigitalIn input(p8); //input from diode. Digital 1 is beam unbroken? |
aidanPJG | 4:e61cd14ec4f0 | 8 | DigitalOut led(LED1); //testing purposes |
aidanPJG | 4:e61cd14ec4f0 | 9 | |
aidanPJG | 4:e61cd14ec4f0 | 10 | |
aidanPJG | 0:7f5f4575bc6f | 11 | int main() { |
aidanPJG | 4:e61cd14ec4f0 | 12 | int line = 0; //line counter |
aidanPJG | 4:e61cd14ec4f0 | 13 | pc.printf("new program \n"); //lert user of initialisation |
aidanPJG | 4:e61cd14ec4f0 | 14 | |
aidanPJG | 4:e61cd14ec4f0 | 15 | while(1) { //loops continuously |
aidanPJG | 4:e61cd14ec4f0 | 16 | if (input) //checks the digital input from the diode. |
aidanPJG | 0:7f5f4575bc6f | 17 | { |
aidanPJG | 4:e61cd14ec4f0 | 18 | pc.printf("Message %d : \t", line); |
aidanPJG | 4:e61cd14ec4f0 | 19 | pc.printf("DigitalIn: 1 \n"); |
aidanPJG | 2:7d53e9959b8f | 20 | led = 1; |
aidanPJG | 4:e61cd14ec4f0 | 21 | line = line + 1; |
aidanPJG | 4:e61cd14ec4f0 | 22 | |
aidanPJG | 0:7f5f4575bc6f | 23 | } |
aidanPJG | 2:7d53e9959b8f | 24 | else |
aidanPJG | 2:7d53e9959b8f | 25 | { |
aidanPJG | 4:e61cd14ec4f0 | 26 | pc.printf("Message %d : \t", line); |
aidanPJG | 4:e61cd14ec4f0 | 27 | pc.printf("DigitalIn 0\n"); |
aidanPJG | 3:1ef4740c5a64 | 28 | led = 0; |
aidanPJG | 4:e61cd14ec4f0 | 29 | line = line + 1 ; |
aidanPJG | 4:e61cd14ec4f0 | 30 | |
aidanPJG | 0:7f5f4575bc6f | 31 | } |
aidanPJG | 0:7f5f4575bc6f | 32 | } |
aidanPJG | 0:7f5f4575bc6f | 33 | } |