sdsd

Dependencies:   mbed

Fork of mbed5a_testy by Robert Labuz

Committer:
Robsonik16
Date:
Fri May 05 20:01:41 2017 +0000
Revision:
1:b8d65b5745d1
a

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Robsonik16 1:b8d65b5745d1 1 #include "led.h"
Robsonik16 1:b8d65b5745d1 2 #include "mbed.h"
Robsonik16 1:b8d65b5745d1 3
Robsonik16 1:b8d65b5745d1 4 DigitalOut led_0(PA_4);
Robsonik16 1:b8d65b5745d1 5 DigitalOut led_1(PA_5);
Robsonik16 1:b8d65b5745d1 6 DigitalOut led_2(PA_6);
Robsonik16 1:b8d65b5745d1 7 DigitalOut led_3(PA_7);
Robsonik16 1:b8d65b5745d1 8
Robsonik16 1:b8d65b5745d1 9 enum Step{LEFT, RIGHT};
Robsonik16 1:b8d65b5745d1 10
Robsonik16 1:b8d65b5745d1 11 void LedInt(void){
Robsonik16 1:b8d65b5745d1 12 //IO1DIR=IO1DIR|(LED0_bm|LED1_bm|LED2_bm|LED3_bm);
Robsonik16 1:b8d65b5745d1 13 //IO1SET= LED0_bm;
Robsonik16 1:b8d65b5745d1 14 }
Robsonik16 1:b8d65b5745d1 15
Robsonik16 1:b8d65b5745d1 16 void LedOn(unsigned char ucLedIndeks){
Robsonik16 1:b8d65b5745d1 17
Robsonik16 1:b8d65b5745d1 18
Robsonik16 1:b8d65b5745d1 19 //IO1CLR = LED0_bm|LED1_bm|LED2_bm|LED3_bm;
Robsonik16 1:b8d65b5745d1 20 led_0=0;
Robsonik16 1:b8d65b5745d1 21 led_1=0;
Robsonik16 1:b8d65b5745d1 22 led_2=0;
Robsonik16 1:b8d65b5745d1 23 led_3=0;
Robsonik16 1:b8d65b5745d1 24 switch (ucLedIndeks) {
Robsonik16 1:b8d65b5745d1 25 case 0:
Robsonik16 1:b8d65b5745d1 26 led_0=1;
Robsonik16 1:b8d65b5745d1 27 break;
Robsonik16 1:b8d65b5745d1 28 case 1:
Robsonik16 1:b8d65b5745d1 29 led_1=1;
Robsonik16 1:b8d65b5745d1 30 break;
Robsonik16 1:b8d65b5745d1 31 case 2:
Robsonik16 1:b8d65b5745d1 32 led_2=1;
Robsonik16 1:b8d65b5745d1 33 break;
Robsonik16 1:b8d65b5745d1 34 case 3:
Robsonik16 1:b8d65b5745d1 35 led_3=1;
Robsonik16 1:b8d65b5745d1 36 break;
Robsonik16 1:b8d65b5745d1 37 default:
Robsonik16 1:b8d65b5745d1 38 break;
Robsonik16 1:b8d65b5745d1 39 }
Robsonik16 1:b8d65b5745d1 40
Robsonik16 1:b8d65b5745d1 41
Robsonik16 1:b8d65b5745d1 42 }
Robsonik16 1:b8d65b5745d1 43 void Led_Step(enum Step Direction){
Robsonik16 1:b8d65b5745d1 44
Robsonik16 1:b8d65b5745d1 45 static unsigned int uiDioda;
Robsonik16 1:b8d65b5745d1 46
Robsonik16 1:b8d65b5745d1 47 if (Direction == RIGHT ){
Robsonik16 1:b8d65b5745d1 48 uiDioda++;
Robsonik16 1:b8d65b5745d1 49 }else{
Robsonik16 1:b8d65b5745d1 50 uiDioda--;
Robsonik16 1:b8d65b5745d1 51 }
Robsonik16 1:b8d65b5745d1 52 LedOn(uiDioda%4);
Robsonik16 1:b8d65b5745d1 53 }
Robsonik16 1:b8d65b5745d1 54
Robsonik16 1:b8d65b5745d1 55 void Led_StepLeft(void){
Robsonik16 1:b8d65b5745d1 56 Led_Step(LEFT);
Robsonik16 1:b8d65b5745d1 57 }
Robsonik16 1:b8d65b5745d1 58
Robsonik16 1:b8d65b5745d1 59 void Led_StepRight(void){
Robsonik16 1:b8d65b5745d1 60 Led_Step(RIGHT);
Robsonik16 1:b8d65b5745d1 61 }