pot controller voor positie, kp handmatig instellen, werkt met motor 1 en 2

Dependencies:   MODSERIAL QEI mbed-dsp mbed

Fork of PI_controller_verbeteringen by ProjectGroep23

main.cpp

Committer:
SimonRez
Date:
2018-09-12
Revision:
2:52b3c0b95388
Parent:
1:40470bc517f1
Child:
3:40a25c2c24ba

File content as of revision 2:52b3c0b95388:

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

Ticker Blinker;

DigitalOut ledr(LED_RED);
DigitalOut ledg(LED_GREEN);
DigitalOut ledb(LED_BLUE);
DigitalIn   sw2(PTC6);

MODSERIAL pc(USBTX, USBRX);

volatile char c;
volatile char  color;

void ButtonpressCheck()
{    
    if (c == 'r')
    {
        color = 'r';
    }
    else if (c == 'g')
    {
        color = 'g';        
    }
    else if (c == 'b')
    {
        color = 'b';
    }
    else
    {
        pc.printf("Character %c is not valid \r\n",c);
        c = color;
    }     
    
    if (color == 'r')
    {
        ledr = !ledr;
        ledg = 1;
        ledb = 1;
    }
    else if (color == 'g')
    {
        ledr = 1;
        ledg = !ledg;
        ledb = 1;
    }
    else if (color == 'b')
    {
        ledr = 1;
        ledg = 1;
        ledb = !ledb;
    }
    wait(0.25f);
    ledr = 1;
    ledg = 1;
    ledb = 1;
       
}

int main()
{
    ledr = 1;
    ledg = 1;
    ledb = 1;
    
    pc.printf("\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n ~~~Pu$$Y~~~ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n");
    
    pc.baud(115200);
    Blinker.attach(ButtonpressCheck, 0.5);
    
    
    
    while (true)
    {
        c = pc.getc();
    }
    
}