![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
now when you turn the draaiknop the lampje will dim
Diff: main.cpp
- Branch:
- knopjes
- Revision:
- 1:c6776cafbfd9
- Parent:
- 0:ead43c4234c9
- Child:
- 2:aca5a168a6d3
--- a/main.cpp Tue Sep 19 14:12:56 2017 +0000 +++ b/main.cpp Tue Sep 19 14:34:47 2017 +0000 @@ -7,13 +7,26 @@ DigitalOut gpo(D0); PwmOut led2(D6); PwmOut led1(D5); -float PwmPeriod= 1/5000.0; + +int a=5000; +float PwmPeriod= 1/a; int main() { - led2.period(PwmPeriod); - while (true) { - led2= Pot1.read(); - wait(0.1f); + while (true) + { + if (But1==true) + { + a=a+100; + } + else if (But2==true) + { + a=a-100; + } + else + {} + wait(0.1f); + led1.period(PwmPeriod); } } +