vjezba 8.2

Dependencies:   mbed

main.cpp

Committer:
lgotic
Date:
2016-11-17
Revision:
0:29aa850ca724

File content as of revision 0:29aa850ca724:

#include "mbed.h"
BusOut myleds(LED4, LED3, LED2, LED1);
char x=1;
int main() {
while(1) {
for(int i=0; i<3; i++) { // x = a << b then x = a*2^b;
x = x << 1; // x=1,2,4,8 or x=0001,0010,0100,1000
myleds=x; // sweep left
wait(0.2);
}
for(int i=0; i<3; i++) { // x = a >> b then x = a/2^b;
x = x >> 1; // x=8,4,2,1 or x=1000,0100,0010,0001
myleds=x; // sweep right
wait(0.2);
}
}
}