For cycle example using PWM outputs to create diferent colors with the on board RGB Led

Dependencies:   mbed

Committer:
gcarmonar
Date:
Wed Oct 09 21:07:52 2013 +0000
Revision:
0:ea0651d11ca4
Ver1.0;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gcarmonar 0:ea0651d11ca4 1 /*
gcarmonar 0:ea0651d11ca4 2 - Descripcion -
gcarmonar 0:ea0651d11ca4 3 Controlar la intensidad de un led RGB y hacer conbinaciones
gcarmonar 0:ea0651d11ca4 4 de colores utilizando diferentes tonos.
gcarmonar 0:ea0651d11ca4 5
gcarmonar 0:ea0651d11ca4 6 - AYUDA -
gcarmonar 0:ea0651d11ca4 7 PwmOut : Configura un puerto como salida PWM, puedes establece el ciclo
gcarmonar 0:ea0651d11ca4 8 trabajo con numeros entre 0 (para 0%) y 1 (para 100%) con decimales
gcarmonar 0:ea0651d11ca4 9 float : Tipo de variable que utiliza numeros decimales
gcarmonar 0:ea0651d11ca4 10 */
gcarmonar 0:ea0651d11ca4 11
gcarmonar 0:ea0651d11ca4 12 #include "mbed.h"
gcarmonar 0:ea0651d11ca4 13
gcarmonar 0:ea0651d11ca4 14 PwmOut bled(LED1);
gcarmonar 0:ea0651d11ca4 15 PwmOut gled(LED2);
gcarmonar 0:ea0651d11ca4 16 PwmOut rled(LED3);
gcarmonar 0:ea0651d11ca4 17
gcarmonar 0:ea0651d11ca4 18 int main() {
gcarmonar 0:ea0651d11ca4 19 // Todos apagados
gcarmonar 0:ea0651d11ca4 20 bled = 1;
gcarmonar 0:ea0651d11ca4 21 gled = 1;
gcarmonar 0:ea0651d11ca4 22 rled = 1;
gcarmonar 0:ea0651d11ca4 23
gcarmonar 0:ea0651d11ca4 24 while(1) {
gcarmonar 0:ea0651d11ca4 25 for (float i = 0; i <= 1; i = i + 0.2){
gcarmonar 0:ea0651d11ca4 26 for (float j = 0; j <= 1; j = j + 0.2){
gcarmonar 0:ea0651d11ca4 27 for (float k = 0; k <= 1; k = k + 0.2){
gcarmonar 0:ea0651d11ca4 28 bled = i;
gcarmonar 0:ea0651d11ca4 29 gled = j;
gcarmonar 0:ea0651d11ca4 30 rled = k;
gcarmonar 0:ea0651d11ca4 31 wait(0.25);
gcarmonar 0:ea0651d11ca4 32 }
gcarmonar 0:ea0651d11ca4 33 }
gcarmonar 0:ea0651d11ca4 34 }
gcarmonar 0:ea0651d11ca4 35 }
gcarmonar 0:ea0651d11ca4 36 }