Shape algorithm for location mapping.
Fork of Orientation_PerTile by
main.cpp@0:8a61e3541a5e, 2018-02-19 (annotated)
- Committer:
- el15tcd
- Date:
- Mon Feb 19 12:40:15 2018 +0000
- Revision:
- 0:8a61e3541a5e
- Child:
- 1:c573caf40864
Array Demonstration (single line)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
el15tcd | 0:8a61e3541a5e | 1 | #include "mbed.h" |
el15tcd | 0:8a61e3541a5e | 2 | |
el15tcd | 0:8a61e3541a5e | 3 | //DigitalIn trigger(p22); |
el15tcd | 0:8a61e3541a5e | 4 | //DigitalOut transmit(p28); |
el15tcd | 0:8a61e3541a5e | 5 | |
el15tcd | 0:8a61e3541a5e | 6 | DigitalIn tl(p17); //change to correct board |
el15tcd | 0:8a61e3541a5e | 7 | DigitalIn tr(p18); |
el15tcd | 0:8a61e3541a5e | 8 | DigitalIn bl(p19); |
el15tcd | 0:8a61e3541a5e | 9 | DigitalIn br(p20); |
el15tcd | 0:8a61e3541a5e | 10 | |
el15tcd | 0:8a61e3541a5e | 11 | Serial device(p28,p27); //tx,rx |
el15tcd | 0:8a61e3541a5e | 12 | |
el15tcd | 0:8a61e3541a5e | 13 | BusOut myleds(LED4, LED3, LED2, LED1); |
el15tcd | 0:8a61e3541a5e | 14 | |
el15tcd | 0:8a61e3541a5e | 15 | int buffer[4]; |
el15tcd | 0:8a61e3541a5e | 16 | int temp1; |
el15tcd | 0:8a61e3541a5e | 17 | |
el15tcd | 0:8a61e3541a5e | 18 | int row; |
el15tcd | 0:8a61e3541a5e | 19 | int columns; |
el15tcd | 0:8a61e3541a5e | 20 | |
el15tcd | 0:8a61e3541a5e | 21 | char array[4]; |
el15tcd | 0:8a61e3541a5e | 22 | int i; |
el15tcd | 0:8a61e3541a5e | 23 | |
el15tcd | 0:8a61e3541a5e | 24 | void Array(); |
el15tcd | 0:8a61e3541a5e | 25 | |
el15tcd | 0:8a61e3541a5e | 26 | int main() |
el15tcd | 0:8a61e3541a5e | 27 | { |
el15tcd | 0:8a61e3541a5e | 28 | |
el15tcd | 0:8a61e3541a5e | 29 | myleds = 0; |
el15tcd | 0:8a61e3541a5e | 30 | |
el15tcd | 0:8a61e3541a5e | 31 | device.baud(19200); |
el15tcd | 0:8a61e3541a5e | 32 | buffer[0] = 1; |
el15tcd | 0:8a61e3541a5e | 33 | buffer[1] = 0; |
el15tcd | 0:8a61e3541a5e | 34 | buffer[2] = 1; |
el15tcd | 0:8a61e3541a5e | 35 | buffer[3] = 0; |
el15tcd | 0:8a61e3541a5e | 36 | // buffer[4] = 0; |
el15tcd | 0:8a61e3541a5e | 37 | // buffer[5] = 0; |
el15tcd | 0:8a61e3541a5e | 38 | // buffer[6] = 1; |
el15tcd | 0:8a61e3541a5e | 39 | // buffer[7] = 0; |
el15tcd | 0:8a61e3541a5e | 40 | |
el15tcd | 0:8a61e3541a5e | 41 | array[0] = 0; |
el15tcd | 0:8a61e3541a5e | 42 | array[1] = 0; |
el15tcd | 0:8a61e3541a5e | 43 | array[2] = 0; |
el15tcd | 0:8a61e3541a5e | 44 | array[3] = 0; |
el15tcd | 0:8a61e3541a5e | 45 | |
el15tcd | 0:8a61e3541a5e | 46 | while(1) { |
el15tcd | 0:8a61e3541a5e | 47 | |
el15tcd | 0:8a61e3541a5e | 48 | if (tl > 0) { |
el15tcd | 0:8a61e3541a5e | 49 | myleds = 1; |
el15tcd | 0:8a61e3541a5e | 50 | } else { |
el15tcd | 0:8a61e3541a5e | 51 | myleds = 0; |
el15tcd | 0:8a61e3541a5e | 52 | } |
el15tcd | 0:8a61e3541a5e | 53 | |
el15tcd | 0:8a61e3541a5e | 54 | Array(); |
el15tcd | 0:8a61e3541a5e | 55 | device.putc(1); |
el15tcd | 0:8a61e3541a5e | 56 | for (int i=0; i<5; i++) { |
el15tcd | 0:8a61e3541a5e | 57 | |
el15tcd | 0:8a61e3541a5e | 58 | //device.printf("%i",buffer[i]); |
el15tcd | 0:8a61e3541a5e | 59 | |
el15tcd | 0:8a61e3541a5e | 60 | //device.putc(buffer[i]); |
el15tcd | 0:8a61e3541a5e | 61 | device.putc(array[i]); |
el15tcd | 0:8a61e3541a5e | 62 | } |
el15tcd | 0:8a61e3541a5e | 63 | //wait(1); |
el15tcd | 0:8a61e3541a5e | 64 | } |
el15tcd | 0:8a61e3541a5e | 65 | |
el15tcd | 0:8a61e3541a5e | 66 | } |
el15tcd | 0:8a61e3541a5e | 67 | |
el15tcd | 0:8a61e3541a5e | 68 | void Array() |
el15tcd | 0:8a61e3541a5e | 69 | { |
el15tcd | 0:8a61e3541a5e | 70 | for(i=0; i<=1 ; i=i+1) { |
el15tcd | 0:8a61e3541a5e | 71 | if (i == 0) { |
el15tcd | 0:8a61e3541a5e | 72 | if (tl > 0) { |
el15tcd | 0:8a61e3541a5e | 73 | array[0] = 1; |
el15tcd | 0:8a61e3541a5e | 74 | } else { |
el15tcd | 0:8a61e3541a5e | 75 | array[0] = 0; |
el15tcd | 0:8a61e3541a5e | 76 | } |
el15tcd | 0:8a61e3541a5e | 77 | } else if (i == 1) { |
el15tcd | 0:8a61e3541a5e | 78 | if (tr > 0) { |
el15tcd | 0:8a61e3541a5e | 79 | array[1] = 1; |
el15tcd | 0:8a61e3541a5e | 80 | } else { |
el15tcd | 0:8a61e3541a5e | 81 | array[1] = 0; |
el15tcd | 0:8a61e3541a5e | 82 | } |
el15tcd | 0:8a61e3541a5e | 83 | } |
el15tcd | 0:8a61e3541a5e | 84 | } |
el15tcd | 0:8a61e3541a5e | 85 | for(i=0; i<=1 ; i=i+1) { |
el15tcd | 0:8a61e3541a5e | 86 | if (i == 0) { |
el15tcd | 0:8a61e3541a5e | 87 | if (bl > 0) { |
el15tcd | 0:8a61e3541a5e | 88 | array[2] = 1; |
el15tcd | 0:8a61e3541a5e | 89 | } else { |
el15tcd | 0:8a61e3541a5e | 90 | array[2] = 0; |
el15tcd | 0:8a61e3541a5e | 91 | } |
el15tcd | 0:8a61e3541a5e | 92 | } else if (i == 1) { |
el15tcd | 0:8a61e3541a5e | 93 | if (br > 0) { |
el15tcd | 0:8a61e3541a5e | 94 | array[3] = 1; |
el15tcd | 0:8a61e3541a5e | 95 | } else { |
el15tcd | 0:8a61e3541a5e | 96 | array[3] = 0; |
el15tcd | 0:8a61e3541a5e | 97 | } |
el15tcd | 0:8a61e3541a5e | 98 | } |
el15tcd | 0:8a61e3541a5e | 99 | } |
el15tcd | 0:8a61e3541a5e | 100 | /* |
el15tcd | 0:8a61e3541a5e | 101 | for (row=0; row<2; row++) { |
el15tcd | 0:8a61e3541a5e | 102 | for(columns=0; columns<2; columns++) { |
el15tcd | 0:8a61e3541a5e | 103 | printf("%d ", array[row][columns]); |
el15tcd | 0:8a61e3541a5e | 104 | } |
el15tcd | 0:8a61e3541a5e | 105 | printf("\n"); |
el15tcd | 0:8a61e3541a5e | 106 | }*/ |
el15tcd | 0:8a61e3541a5e | 107 | //printf("\n"); |
el15tcd | 0:8a61e3541a5e | 108 | } |