Use long-hand write on Digital I/O

Dependencies:   mbed SLCD

Fork of blink_kl46z by Stanley Cohen

main.cpp

Committer:
scohennm
Date:
2014-09-03
Revision:
2:24090ed5f981
Parent:
0:e23fffd4b9a7
Child:
3:f445e67012ee

File content as of revision 2:24090ed5f981:

#include "mbed.h"
#define LEDON false
#define LEDOFF true
#define PWMDWELL 50// milliseconds
#define DFDELTA 0.01

// slightly more interesting blinky 140814 sc
// Change to use PWM

float dutyFactor = 0.0;
PwmOut greenColor(LED_GREEN);
PwmOut redColor(LED_RED);

int main() {
    while(true) {
        redColor.write(dutyFactor);
        greenColor.write(1.0 - dutyFactor);
        dutyFactor += DFDELTA; 
        if(dutyFactor >= 1.0) dutyFactor = 0.0;  
        wait_ms(PWMDWELL);
    }
}