![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Mode_swither
Dependencies: MODSERIAL Servo mbed
Revision 0:0b992ae0bfd9, committed 2017-10-31
- Comitter:
- DBerendsen
- Date:
- Tue Oct 31 14:24:40 2017 +0000
- Commit message:
- mode_switcher
Changed in this revision
diff -r 000000000000 -r 0b992ae0bfd9 MODSERIAL.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MODSERIAL.lib Tue Oct 31 14:24:40 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/Sissors/code/MODSERIAL/#a3b2bc878529
diff -r 000000000000 -r 0b992ae0bfd9 Servo.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Servo.lib Tue Oct 31 14:24:40 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/simon/code/Servo/#36b69a7ced07
diff -r 000000000000 -r 0b992ae0bfd9 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Oct 31 14:24:40 2017 +0000 @@ -0,0 +1,99 @@ +#include "mbed.h" +#include "Servo.h" +#include "MODSERIAL.h" + +MODSERIAL pc(USBTX, USBRX); +InterruptIn mbut(PTA4); +InterruptIn sbut(PTC6); +DigitalOut mode_signal(D2); +DigitalOut led_rood(LED_RED); +DigitalOut led_groen(LED_GREEN); +DigitalOut led_blauw(LED_BLUE); + +int mode = 1; + +void mode_switcher() { + + switch(mode){ + case 1: mode_signal = 1; + mode_signal = 0; + led_rood = 0; + led_groen = 1; + led_blauw = 1; + break; + case 2: mode_signal = 1; + mode_signal = 0; + led_rood = 1; + led_groen = 0; + led_blauw = 1; + break; + case 3: mode_signal = 1; + mode_signal = 0; + led_rood = 1; + led_groen = 1; + led_blauw = 0; + break; + case 4: mode_signal = 1; + mode_signal = 0; + led_rood = 0; + led_groen = 0; + led_blauw = 0; + break; + case 5: mode_signal = 1; + mode_signal = 0; + led_rood = 1; + led_groen = 0; + led_blauw = 0; + break; + case 6: mode_signal = 1; + mode_signal = 0; + led_rood = 0; + led_groen = 0; + led_blauw = 1; + break; + } + + pc.printf("The system is in mode %i\r\n", mode); + + mode += 1; + + if (mode==7) { + mode = 1; + } + +} + + +//------------------------------------------------------------------------------ +//--------------------------------Servo----------------------------------------- +//------------------------------------------------------------------------------ +Servo MyServo(D9); +InterruptIn But1(D8); +int k=0; + +void servo_control (){ + if (k==0){ + MyServo = 0; + k=1; + } + else{ + MyServo = 2; + k=0; + } +} +//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ + + + +int main() +{ + led_rood = 1; + led_groen = 1; + led_blauw = 1; + + pc.baud(115200); + mbut.rise(&mode_switcher); + sbut.rise(&servo_control); +} \ No newline at end of file
diff -r 000000000000 -r 0b992ae0bfd9 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Oct 31 14:24:40 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/fb8e0ae1cceb \ No newline at end of file