Werkcollege opgave 23 september BMT K9

Dependencies:   Encoder HIDScope MODSERIAL mbed QEI biquadFilter

main.cpp

Committer:
bscheltinga
Date:
2015-09-30
Revision:
4:96e47998d495
Parent:
3:2785a945b654
Child:
5:d60a42727a3e

File content as of revision 4:96e47998d495:

#include "mbed.h"
#include "encoder.h"
#include "MODSERIAL.h"

//Motor 2
DigitalOut motor2direction(D4); //D4 en D5 zijn motor 2 (op het motorshield)
PwmOut motor2speed(D5);
DigitalIn buttonL1(PTC6);
DigitalIn buttonL2(PTA4);
DigitalIn buttonH1(D2);
DigitalIn buttonH2(D6);

//dit kan worden gebruikt om de verschillende slagnelheden toe te passen door de buttons te veranderen in thresholds

int main()
{
    while(true) {
        if (buttonL1.read() <0.5) {
            motor2speed = 0.1;
            motor2direction = 0;
        }
        if (buttonL2.read() <0.5) {
            motor2speed = 0.4;
            motor2direction = 0;
        }
        if (buttonH1.read() <0.5) {
            motor2speed = 0.7;
            motor2direction = 0;
        }
        if (buttonH2.read() <0.5) {
            motor2speed = 0.99999;
            motor2direction = 0;
        } else {
            motor2speed =0;
        }
    }
}