Functions Part 1

Dependencies:   mbed

main.cpp

Committer:
gcarmonar
Date:
2013-11-07
Revision:
0:ed67004d6053

File content as of revision 0:ed67004d6053:

#include "mbed.h"

DigitalOut bled(LED1);
DigitalOut gled(LED2);
DigitalOut rled(LED3);

float t = 0.5;

// Todas las funciones se tienen que declarar al inicio
void red();
void green();
void blue();
void pink();
void cyan();
void yellow();
void white();
void colors_off();

int main() {
    while(1) {
        red(); // Manda a llamar la funcion red()
        wait(t);
        blue();       wait(t);
        green();      wait(t);
        cyan();       wait(t);
        yellow();     wait(t);
        pink();       wait(t);
        white();      wait(t);
        colors_off(); wait(t);
    }
}


void red(){ // Código de la funcion red()
    rled = 0;
    gled = 1;
    bled = 1;
}

void green(){
    rled = 1;
    gled = 0;
    bled = 1;
}

void blue(){
    rled = 1;
    gled = 1;
    bled = 0;
}

void cyan(){
    rled = 1;
    gled = 0;
    bled = 0;
}

void pink(){
    rled = 0;
    gled = 1;
    bled = 0;
}

void white(){
    rled = 0;
    gled = 0;
    bled = 0;
}

void colors_off(){
    rled = 1;
    gled = 1;
    bled = 1;
}

void yellow(){
    rled = 0;
    gled = 0;
    bled = 1;
}