Prototype

Dependencies:   mbed ButtonEventDemo

Lauflicht.cpp

Committer:
Kelrath1984
Date:
2020-01-13
Revision:
15:b7025faf0571
Parent:
14:0ccc3d5ca8ce
Child:
16:acf89f757b1b

File content as of revision 15:b7025faf0571:

#include "mbed.h"

//#define  BUTTON1 p14
#define INIT 0x03;


int modifyBit(int x, unsigned char position, bool state);
int lauflicht(bool richtung, int time, int &anz);
void nibbleLeds(int value);
//void printb(uint_t x);

BusOut myleds(LED1, LED2, LED3, LED4);
DigitalIn button(BUTTON1);

int main(){
    uint8_t value=INIT;
    int anz;
    
    lauflicht(0,400,anz=0);
}

int lauflicht(bool richtung, int time, int &anz){
    int i=0;
    uint8_t lauf=0x01;
    
    
    if(!richtung){
        lauf= 0x08;
    }
    while(1){
        nibbleLeds(lauf&0x0F);
        if(richtung){
            lauf=lauf<<1;
            if(lauf>8){
                lauf=0x01;
            }
        }
        else {
            lauf=lauf>>1;
            if(lauf==0){
                lauf=0x08;
            }   
        }
        if(button){
            break;   
        }
        wait_ms(time);
        anz++;
    }
    return anz;
}

void nibbleLeds(int value){
    myleds=value%16;
}