lab1 part2
Dependencies: PinDetect lab1_part2 mbed
main.cpp
- Committer:
- mus3
- Date:
- 2022-09-08
- Revision:
- 10:00a557218002
- Parent:
- 9:e5c16d5c49d7
File content as of revision 10:00a557218002:
#include "mbed.h" #include "PinDetect.h" PwmOut led(LED1); PinDetect pbdim(p7); PinDetect pbbright(p6); float volatile brightness = 0.5f; void pbdim_hit_callback (void) { if(1.0f > brightness || brightness >= 0.0f) { brightness+= 0.1f; } } void pbbright_hit_callback (void) { if (0.0f < brightness || brightness <= 1.0f) { brightness -= 0.1f; } } int main() { pbdim.mode(PullUp); pbbright.mode(PullUp); wait(0.001); pbdim.attach_deasserted(&pbdim_hit_callback); pbdim.setSampleFrequency(); pbbright.attach_deasserted(&pbbright_hit_callback); pbbright.setSampleFrequency(); while(1) { led = brightness; wait(.2); } }