Opdracht 1 met de motor. Functioneert nog niet.

Dependencies:   mbed

Committer:
Annelotte
Date:
Thu Sep 21 08:49:31 2017 +0000
Revision:
2:1e290f8bc775
Parent:
1:2a6e34a26b8a
Opdracht 1 met de motor. Functioneert nog niet.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Annelotte 0:3231a9b1147f 1 #include "mbed.h"
Annelotte 2:1e290f8bc775 2
Annelotte 1:2a6e34a26b8a 3 AnalogIn button2(A2);
Annelotte 1:2a6e34a26b8a 4 AnalogIn button1(A3); //Analog input of the button1
Annelotte 0:3231a9b1147f 5 AnalogIn potmeter(A1); //Analog input of the potmeter
Annelotte 1:2a6e34a26b8a 6 PwmOut led2(D6); //Biorobotics LED2 connect (D6)
Annelotte 1:2a6e34a26b8a 7 PwmOut led1(D5); //Biorobotics LED1 connect (D5)
Annelotte 0:3231a9b1147f 8
Annelotte 0:3231a9b1147f 9 float PwmPeriod = 1.0/5000.0; //PWM period (5000 Hz)
Annelotte 0:3231a9b1147f 10
Annelotte 0:3231a9b1147f 11 int mmain() {
Annelotte 0:3231a9b1147f 12 led2.period(PwmPeriod); //Set PWM period at 5000 Hz
Annelotte 1:2a6e34a26b8a 13 led2 = 0.5; //Omdat het in 0 en 1 werkt, nu een startwaarde die ertussen ligt
Annelotte 0:3231a9b1147f 14
Annelotte 0:3231a9b1147f 15 while(true){
Annelotte 1:2a6e34a26b8a 16 if (button1 == 0) {
Annelotte 1:2a6e34a26b8a 17 led2 = led2 + 0.1; //De led krijgt een hogere waarde wanneer button 1 wordt ingedrukt
Annelotte 1:2a6e34a26b8a 18 }
Annelotte 2:1e290f8bc775 19 else if (button2 == 0) { //De led krijgt een lagere waarde wanneer button 2 wordt ingedrukt
Annelotte 1:2a6e34a26b8a 20 led2 = led2 - 0.1;
Annelotte 1:2a6e34a26b8a 21 }
Annelotte 1:2a6e34a26b8a 22 else {
Annelotte 1:2a6e34a26b8a 23 }
Annelotte 0:3231a9b1147f 24 wait(0.1f);
Annelotte 0:3231a9b1147f 25 }
Annelotte 0:3231a9b1147f 26 }