part1

Dependencies:   mbed

main.cpp

Committer:
jaredwil
Date:
2015-01-27
Revision:
2:671afb80dc9b
Parent:
1:3aa59818cdce

File content as of revision 2:671afb80dc9b:

#include "mbed.h"
#include "math.h"

Serial pc(USBTX, USBRX);

DigitalOut myled1(LED1);
DigitalOut myled2(LED2);
DigitalOut myled3(LED3);

int main() {
        srand(time(NULL));
        float a = (rand()%8)/10.0;
        float b = (rand()%8)/10.0;
        float c = 1.8 - a - b;
        
        pc.printf("A: %f, %f, %f",a,b,c);

    while(1) {
        
        for(float i = 0.0; i < 1.0 ; i += 0.1) {
            float p = 3 * i;
            myled1 = (p < 1.0) ? 1: (p > 2.0) ? b: 0;
            wait(a);
            myled1 = 0;
            myled2 = (p < 1.0) ? 0 : (p > 3.0) ? 1 : 0;
            wait(b);
            myled2 = 0;
            myled3 = (p < 1.0) ? 1 : (p > 3.0) ? a : 1;
            wait(c);
            myled3=0;
            }
        }
}