![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Initial setup for different sensations on the MBED
Dependencies: mbed
main.cpp@0:f9023577fa6b, 2015-11-05 (annotated)
- Committer:
- mfrede
- Date:
- Thu Nov 05 21:38:00 2015 +0000
- Revision:
- 0:f9023577fa6b
Initial code
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mfrede | 0:f9023577fa6b | 1 | #include "mbed.h" |
mfrede | 0:f9023577fa6b | 2 | |
mfrede | 0:f9023577fa6b | 3 | Serial pc(USBTX,USBRX); |
mfrede | 0:f9023577fa6b | 4 | DigitalOut port1(p21); |
mfrede | 0:f9023577fa6b | 5 | DigitalOut port2(p22); |
mfrede | 0:f9023577fa6b | 6 | DigitalOut port3(p20); |
mfrede | 0:f9023577fa6b | 7 | DigitalOut port4(p19); |
mfrede | 0:f9023577fa6b | 8 | DigitalOut port5(p25); |
mfrede | 0:f9023577fa6b | 9 | DigitalOut port6(p26); |
mfrede | 0:f9023577fa6b | 10 | |
mfrede | 0:f9023577fa6b | 11 | int main() { |
mfrede | 0:f9023577fa6b | 12 | char buffer; |
mfrede | 0:f9023577fa6b | 13 | while(1) { |
mfrede | 0:f9023577fa6b | 14 | pc.printf("Press any key to generate a sensation\r\n"); |
mfrede | 0:f9023577fa6b | 15 | buffer = pc.getc(); |
mfrede | 0:f9023577fa6b | 16 | if (buffer == 'c') { |
mfrede | 0:f9023577fa6b | 17 | port1 = 1; |
mfrede | 0:f9023577fa6b | 18 | wait_ms(200); |
mfrede | 0:f9023577fa6b | 19 | port2 = 1; |
mfrede | 0:f9023577fa6b | 20 | port1 = 0; |
mfrede | 0:f9023577fa6b | 21 | wait_ms(200); |
mfrede | 0:f9023577fa6b | 22 | port3 = 1; |
mfrede | 0:f9023577fa6b | 23 | port2 = 0; |
mfrede | 0:f9023577fa6b | 24 | wait_ms(200); |
mfrede | 0:f9023577fa6b | 25 | port4 = 1; |
mfrede | 0:f9023577fa6b | 26 | port3 = 0; |
mfrede | 0:f9023577fa6b | 27 | wait_ms(200); |
mfrede | 0:f9023577fa6b | 28 | port5 = 1; |
mfrede | 0:f9023577fa6b | 29 | port4 = 0; |
mfrede | 0:f9023577fa6b | 30 | wait_ms(200); |
mfrede | 0:f9023577fa6b | 31 | port6 = 1; |
mfrede | 0:f9023577fa6b | 32 | port5 = 0; |
mfrede | 0:f9023577fa6b | 33 | wait_ms(200); |
mfrede | 0:f9023577fa6b | 34 | port6 = 0; |
mfrede | 0:f9023577fa6b | 35 | } else { |
mfrede | 0:f9023577fa6b | 36 | port1 = 1; |
mfrede | 0:f9023577fa6b | 37 | port2 = 1; |
mfrede | 0:f9023577fa6b | 38 | port3 = 1; |
mfrede | 0:f9023577fa6b | 39 | port4 = 1; |
mfrede | 0:f9023577fa6b | 40 | port5 = 1; |
mfrede | 0:f9023577fa6b | 41 | port6 = 1; |
mfrede | 0:f9023577fa6b | 42 | wait_ms(1000); |
mfrede | 0:f9023577fa6b | 43 | port1 = 0; |
mfrede | 0:f9023577fa6b | 44 | port2 = 0; |
mfrede | 0:f9023577fa6b | 45 | port3 = 0; |
mfrede | 0:f9023577fa6b | 46 | port4 = 0; |
mfrede | 0:f9023577fa6b | 47 | port5 = 0; |
mfrede | 0:f9023577fa6b | 48 | port6 = 0; |
mfrede | 0:f9023577fa6b | 49 | wait_ms(100); |
mfrede | 0:f9023577fa6b | 50 | port1 = 1; |
mfrede | 0:f9023577fa6b | 51 | port2 = 1; |
mfrede | 0:f9023577fa6b | 52 | port3 = 1; |
mfrede | 0:f9023577fa6b | 53 | port4 = 1; |
mfrede | 0:f9023577fa6b | 54 | port5 = 1; |
mfrede | 0:f9023577fa6b | 55 | port6 = 1; |
mfrede | 0:f9023577fa6b | 56 | wait_ms(1000); |
mfrede | 0:f9023577fa6b | 57 | port1 = 0; |
mfrede | 0:f9023577fa6b | 58 | port2 = 0; |
mfrede | 0:f9023577fa6b | 59 | port3 = 0; |
mfrede | 0:f9023577fa6b | 60 | port4 = 0; |
mfrede | 0:f9023577fa6b | 61 | port5 = 0; |
mfrede | 0:f9023577fa6b | 62 | port6 = 0; |
mfrede | 0:f9023577fa6b | 63 | } |
mfrede | 0:f9023577fa6b | 64 | } |
mfrede | 0:f9023577fa6b | 65 | } |