Advertisement
Guest User

Untitled

a guest
Jan 24th, 2020
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. #include "mbed.h"
  2. #include "PinDetect.h"
  3. //DigitalOut blaled(p21);
  4. PwmOut led(p21);
  5. PinDetect pb(p8);
  6. PinDetect pb1(p15);
  7. float floaty = 0.1f;
  8. // SPST Pushbutton demo using internal PullUp function
  9. // no external PullUp resistor needed
  10. // Pushbutton from P8 to GND.
  11. int main() {
  12. pb.mode(PullUp);
  13. pb1.mode(PullUp);
  14. while(1) {
  15. //blaled = pb;
  16. if(pb){
  17. wait(0.1);
  18. if (floaty < 1.0f){
  19. floaty = floaty + 0.1f;
  20. led=floaty;
  21. }
  22. }
  23. if(pb1){
  24. wait(0.1);
  25. if (floaty > 0.0f){
  26. floaty = floaty - 0.1f;
  27. led=floaty;
  28. }
  29. }
  30.  
  31.  
  32. //for(float p = 0.0f; p < 1.0f; p += 0.1f) {
  33. // led = p; //dim led using PWM
  34. // wait(0.1); //0.1 second time delay-so a human can see it
  35. //}
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement