Bitmanipulation mit Stick

Dependencies:   mbed

main.cpp

Committer:
haunsi
Date:
7 weeks ago
Revision:
0:da2c2685a56c
Child:
1:d2cce2700a45

File content as of revision 0:da2c2685a56c:

#include "mbed.h"

BusOut leds(LED1, LED2, LED3, LED4);
DigitalIn btndown(p12);
DigitalIn btnleft(p13);
DigitalIn btnpush(p14);
DigitalIn btnup(p15);
DigitalIn btnright(p16);

void ledsreset(uint8_t mask);
void shiftlinks();

int main() 
{
    uint8_t mask = 0b00001111;
    uint8_t value = 0b01010101;
    while(1)
    {      
       //leds = mask & value;
       ledsreset(mask);
       
       if(btnleft)
        {
            shiftlinks();
        } 
    }
}
void ledsreset(uint8_t mask)
{
    if(btnpush == 1)
        {
            leds = mask;
        }
}
void shiftlinks()
{
    leds = leds << 1;
    wait_ms(500);
}