Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "mbed.h"
- #include "PinDetect.h"
- //DigitalOut blaled(p21);
- PwmOut led(p21);
- PinDetect pb(p8);
- PinDetect pb1(p15);
- float floaty = 0.1f;
- // SPST Pushbutton demo using internal PullUp function
- // no external PullUp resistor needed
- // Pushbutton from P8 to GND.
- int main() {
- pb.mode(PullUp);
- pb1.mode(PullUp);
- while(1) {
- //blaled = pb;
- if(pb){
- wait(0.1);
- if (floaty < 1.0f){
- floaty = floaty + 0.1f;
- led=floaty;
- }
- }
- if(pb1){
- wait(0.1);
- if (floaty > 0.0f){
- floaty = floaty - 0.1f;
- led=floaty;
- }
- }
- //for(float p = 0.0f; p < 1.0f; p += 0.1f) {
- // led = p; //dim led using PWM
- // wait(0.1); //0.1 second time delay-so a human can see it
- //}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement