
Opdracht 1 met de motor. Functioneert nog niet.
Dependencies: mbed
main.cpp@1:2a6e34a26b8a, 2017-09-19 (annotated)
- Committer:
- Annelotte
- Date:
- Tue Sep 19 15:05:55 2017 +0000
- Revision:
- 1:2a6e34a26b8a
- Parent:
- 0:3231a9b1147f
- Child:
- 2:1e290f8bc775
led dimmen met drukknopjes;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Annelotte | 0:3231a9b1147f | 1 | #include "mbed.h" |
Annelotte | 1:2a6e34a26b8a | 2 | AnalogIn button2(A2); |
Annelotte | 1:2a6e34a26b8a | 3 | AnalogIn button1(A3); //Analog input of the button1 |
Annelotte | 0:3231a9b1147f | 4 | AnalogIn potmeter(A1); //Analog input of the potmeter |
Annelotte | 1:2a6e34a26b8a | 5 | PwmOut led2(D6); //Biorobotics LED2 connect (D6) |
Annelotte | 1:2a6e34a26b8a | 6 | PwmOut led1(D5); //Biorobotics LED1 connect (D5) |
Annelotte | 0:3231a9b1147f | 7 | |
Annelotte | 0:3231a9b1147f | 8 | float PwmPeriod = 1.0/5000.0; //PWM period (5000 Hz) |
Annelotte | 0:3231a9b1147f | 9 | |
Annelotte | 0:3231a9b1147f | 10 | int mmain() { |
Annelotte | 0:3231a9b1147f | 11 | led2.period(PwmPeriod); //Set PWM period at 5000 Hz |
Annelotte | 1:2a6e34a26b8a | 12 | led2 = 0.5; //Omdat het in 0 en 1 werkt, nu een startwaarde die ertussen ligt |
Annelotte | 0:3231a9b1147f | 13 | |
Annelotte | 0:3231a9b1147f | 14 | while(true){ |
Annelotte | 1:2a6e34a26b8a | 15 | if (button1 == 0) { |
Annelotte | 1:2a6e34a26b8a | 16 | led2 = led2 + 0.1; //De led krijgt een hogere waarde wanneer button 1 wordt ingedrukt |
Annelotte | 1:2a6e34a26b8a | 17 | } |
Annelotte | 1:2a6e34a26b8a | 18 | if (button2 == 0) { //De led krijgt een lagere waarde wanneer button 2 wordt ingedrukt |
Annelotte | 1:2a6e34a26b8a | 19 | led2 = led2 - 0.1; |
Annelotte | 1:2a6e34a26b8a | 20 | } |
Annelotte | 1:2a6e34a26b8a | 21 | else { |
Annelotte | 1:2a6e34a26b8a | 22 | } |
Annelotte | 0:3231a9b1147f | 23 | wait(0.1f); |
Annelotte | 0:3231a9b1147f | 24 | } |
Annelotte | 0:3231a9b1147f | 25 | } |