Met kinematics

Dependencies:   MODSERIAL QEI mbed-dsp mbed

Fork of Motorcode by ProjectGroep23

main.cpp

Committer:
SimonRez
Date:
2018-09-12
Revision:
3:40a25c2c24ba
Parent:
2:52b3c0b95388
Child:
4:651d06e860e7

File content as of revision 3:40a25c2c24ba:

#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 if (c == NULL)
    {
        ledr = 1;
        ledg = 1;
        ledb = 1;
    }
    else
    {
        pc.printf("Character %c is not valid \r\n",c);
        c = color;
        
        ledr = 0;
        ledg = 0;
        ledb = 0;
        wait(0.1f);
        ledr = 1;
        ledg = 1;
        ledb = 1;
        wait(0.1f);
        ledr = 0;
        ledg = 0;
        ledb = 0;
        wait(0.1f);
        ledr = 1;
        ledg = 1;
        ledb = 1;
        wait(0.1f);
        ledr = 0;
        ledg = 0;
        ledb = 0;
        wait(0.1f);
        ledr = 1;
        ledg = 1;
        ledb = 1;
        wait(0.1f);        
    }     
    
    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();
        
        
    }
    
}