a

Dependencies:   LM75B mbed

main.cpp

Committer:
bulmenwt
Date:
2015-01-28
Revision:
0:628a777a56a7

File content as of revision 0:628a777a56a7:

/*M0-BOARD LPC11U24 VERSION 1.0 WF 01_2015
BULME Graz / Elektronik
RGB - LED
Datei: WF_RGB_Taster_V2/main.cpp
*/

#include "mbed.h"
PwmOut g(p5); // Definition LED grün, PWM
PwmOut b(p34); // Definition LED blau, PWM
PwmOut r(p36); // Definition LED rot, PWM

// Definition der Taster (Switches)
DigitalIn  sw1(P0_15);  // SW1 -> sein IO Pin ist laut Schaltplan der P0_15
DigitalIn  sw2(P0_10);  // Die Pins werden hier mit DigitalIn belegt ! 
DigitalIn  sw3(P0_23);  // Die Pins werden hier mit DigitalIn belegt !

int main()
{
    int code;
    while(1)
    {       
    code = (sw3 * 4) + (sw2 * 2) + (sw1); //binary encoded buttons
    switch (code) {
            case 1:
                g=0; // LED on   
                b=1; // LED off
                r=1; // LED off
                break;
                
            case 2:
                g=1; // LED off   
                b=0; // LED on
                r=1; // LED off
                break;
                
            case 4:
                g=1; // LED off   
                b=1; // LED off
                r=0; // LED on
                break;   
                
            default:
                g=1; // LED on   
                b=1; // LED off
                r=1; // LED of
                break;
            }          
    }
}