lololololol

Dependencies:   mbed QEI HIDScope biquadFilter MODSERIAL FastPWM

main.cpp

Committer:
Hendrikvg
Date:
2019-09-23
Revision:
14:20f11bb58244
Parent:
9:12b9865e7373
Child:
15:80b3ac2b8448

File content as of revision 14:20f11bb58244:

#include "mbed.h"
#include "FastPWM.h"

// Motor 1 aan zetten en uit zetten dmv button 1 en 2 werkt.
// Snelheid aansturen nog niet.

Serial pc(USBTX,USBRX);
InterruptIn BUT1(D1);
InterruptIn BUT2(D0);
FastPWM lichtje(D3);
AnalogIn   ain(A0);
DigitalOut direction(D6);
DigitalOut speed(D7);

float getal;
int n=5;

void plus()
{
    n++; // n=n+1
    direction = 1;
    if (n>10){
        n=10;
        }
    }
    
void min()
{
    n--;
    direction = 0;
    if (n<0){
        n=0;
        }
    }

int main() {
    pc.baud(115200);
    lichtje=1;
    BUT1.fall(plus);
    BUT2.fall(min);
        while(true)
            {
                    getal = 0.1*n*ain.read();
                    speed = 0.1*n*ain.read();
                    lichtje.period_ms(20);  // 4 second period
                    lichtje.write(getal);  // duty cycle
                    speed.write(getal);
                    pc.printf("%3.3f%\n\r", getal);
        
    }
}