Lab1

Dependencies:   mbed Joystick MPR121_Demo

main.cpp

Committer:
rmaran6
Date:
2016-09-02
Revision:
3:20f5b0f9ad3e
Parent:
1:a8881b932dd3

File content as of revision 3:20f5b0f9ad3e:

#include "mbed.h"

DigitalIn dip(p13);
DigitalIn PB1(p11);
DigitalIn PB2(p12);
PwmOut red_light(p21); 
//PwmOut green_light(p22); 
//PwmOut blue_light(p23); 

//void RGB_light(int r, int g, int b) {
//  red_light = r;
//  green_light = g;
//  blue_light = b;
//}
int main() {
    float brightness = 0.5;
    while(1) {
        if(dip){
            red_light = 0.0;
        }
        else {
            red_light = brightness;
        }
        if(!PB1 && brightness < 1) {
            brightness = brightness + .1;
            wait(.5);
        }
        if(!PB2 && brightness > 0) {
            brightness = brightness - .1;
            wait(.5);
        }
    }
}