Test version

Committer:
a2824256
Date:
Tue Mar 20 02:09:21 2018 +0000
Revision:
0:4be500de690c
test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
a2824256 0:4be500de690c 1 #include "LEDS.h"
a2824256 0:4be500de690c 2 #include "mbed.h"
a2824256 0:4be500de690c 3
a2824256 0:4be500de690c 4 BusOut ctrl(PA_9,PA_8,PB_10,PB_4);
a2824256 0:4be500de690c 5 BusOut leds(PA_13,PA_14,PA_15,PA_5,PA_6,PA_7,PB_6,PC_7);
a2824256 0:4be500de690c 6 int num_arr[10] = {252,96,218,242,102,182,190,224,254,250};
a2824256 0:4be500de690c 7
a2824256 0:4be500de690c 8 int pow(int num, int pow){
a2824256 0:4be500de690c 9 int res = 1;
a2824256 0:4be500de690c 10 if(pow<1){
a2824256 0:4be500de690c 11 return 1;
a2824256 0:4be500de690c 12 }
a2824256 0:4be500de690c 13 for(int i = 1;i<=pow;i++){
a2824256 0:4be500de690c 14 res *= num;
a2824256 0:4be500de690c 15 }
a2824256 0:4be500de690c 16 return res;
a2824256 0:4be500de690c 17 }
a2824256 0:4be500de690c 18
a2824256 0:4be500de690c 19 void LightLEDs(float num){
a2824256 0:4be500de690c 20 int a[4];
a2824256 0:4be500de690c 21 a[3] = num / 100;
a2824256 0:4be500de690c 22 a[2] = num / 10 - a[3] * 10;
a2824256 0:4be500de690c 23 a[1] = num - a[3] * 100 - a[2] * 10;
a2824256 0:4be500de690c 24 a[0] = num * 10 - a[3] * 1000 - a[2] * 100 - a[1] * 10;
a2824256 0:4be500de690c 25 for (int i = 3; i > 0; i--)
a2824256 0:4be500de690c 26 {
a2824256 0:4be500de690c 27 ctrl = pow(2,i);
a2824256 0:4be500de690c 28 if(i == 1){
a2824256 0:4be500de690c 29 leds = num_arr[a[i]] + 1;
a2824256 0:4be500de690c 30 }else{
a2824256 0:4be500de690c 31 leds = num_arr[a[i]];
a2824256 0:4be500de690c 32 }
a2824256 0:4be500de690c 33 wait(0.01);
a2824256 0:4be500de690c 34 }
a2824256 0:4be500de690c 35 }
a2824256 0:4be500de690c 36