hi raco, your last posted code is what i am using now.... it's very nice and efficient..
hi alexan, I added delay because i just want to delay and see the simulation properly....
as what i have said, my programming skill is not good enough to create good algorithm for my programs. I only knew basic style of codding.. as of now, it is okay to me if i see my code working as it should be but i dont know hot to write a code efficiently like what raco did to my code..
yesterday I am tired of using a
very long switch cases just to get all of the combination of 8bits and my code exceeds 2kb of memory which is not enough if i will use AT89c2051.
it is so funny to think about yesterday this was my code of getting the low bits... :-D:-D
Code C - [expand] |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| void main()
{
while(1)
{
switch(P1)
{
case 0:
case 1:
.
.
.
.
case 255:
}
}
} |
and then after now the equivalent to my long cases of switch is just like this.. very short compared to my style... :-D:-D Im very thankful guys... thanks for helping
Code C - [expand] |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| void main()
{
char i;
P3=0x00;
P1=0xFF;
while(1)
{
for(i = 0; i<8; i++)
{
if(~P1 & (0x01 << i))
{
Delay_ms(100);
P3 += i + 1;
Delay_ms(100);
}
if(~P1 == 0)
Delay_ms(100);
P3 = 0;
}
}
} |
---------- Post added at 01:51 ---------- Previous post was at 01:44 ----------
thanks all of you guys for contributing my learning