
Opdracht 1 met de motor. Functioneert nog niet.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 1:2a6e34a26b8a
- Parent:
- 0:3231a9b1147f
- Child:
- 2:1e290f8bc775
--- a/main.cpp Tue Sep 19 14:18:48 2017 +0000 +++ b/main.cpp Tue Sep 19 15:05:55 2017 +0000 @@ -1,16 +1,25 @@ #include "mbed.h" - +AnalogIn button2(A2); +AnalogIn button1(A3); //Analog input of the button1 AnalogIn potmeter(A1); //Analog input of the potmeter -PwmOut led2(D6); //Biorobotics LED connect (D6) -PwmOut led1(D5); //Biorobotics LED connect (D5) +PwmOut led2(D6); //Biorobotics LED2 connect (D6) +PwmOut led1(D5); //Biorobotics LED1 connect (D5) float PwmPeriod = 1.0/5000.0; //PWM period (5000 Hz) int mmain() { led2.period(PwmPeriod); //Set PWM period at 5000 Hz + led2 = 0.5; //Omdat het in 0 en 1 werkt, nu een startwaarde die ertussen ligt while(true){ - led2 = potmeter.read(); //Set brightness of let (0,1) + if (button1 == 0) { + led2 = led2 + 0.1; //De led krijgt een hogere waarde wanneer button 1 wordt ingedrukt + } + if (button2 == 0) { //De led krijgt een lagere waarde wanneer button 2 wordt ingedrukt + led2 = led2 - 0.1; + } + else { + } wait(0.1f); } } \ No newline at end of file