Initial setup for different sensations on the MBED

Dependencies:   mbed

main.cpp

Committer:
mfrede
Date:
2015-11-05
Revision:
0:f9023577fa6b

File content as of revision 0:f9023577fa6b:

#include "mbed.h"

Serial pc(USBTX,USBRX);
DigitalOut port1(p21);
DigitalOut port2(p22);
DigitalOut port3(p20);
DigitalOut port4(p19);
DigitalOut port5(p25);
DigitalOut port6(p26);

int main() {
    char buffer;
    while(1) {
        pc.printf("Press any key to generate a sensation\r\n");
        buffer = pc.getc();
        if (buffer == 'c') {
            port1 = 1;
            wait_ms(200);
            port2 = 1;
            port1 = 0;
            wait_ms(200);
            port3 = 1;
            port2 = 0;
            wait_ms(200);
            port4 = 1;
            port3 = 0;
            wait_ms(200);
            port5 = 1;
            port4 = 0;
            wait_ms(200);
            port6 = 1;
            port5 = 0;
            wait_ms(200);
            port6 = 0;
        } else {
            port1 = 1;
            port2 = 1;
            port3 = 1;
            port4 = 1;
            port5 = 1;
            port6 = 1;
            wait_ms(1000);
            port1 = 0;
            port2 = 0;
            port3 = 0;
            port4 = 0;
            port5 = 0;
            port6 = 0;
            wait_ms(100);
            port1 = 1;
            port2 = 1;
            port3 = 1;
            port4 = 1;
            port5 = 1;
            port6 = 1;
            wait_ms(1000);
            port1 = 0;
            port2 = 0;
            port3 = 0;
            port4 = 0;
            port5 = 0;
            port6 = 0;
        }
    }
}