Automatic Water Pump System
ok you are mentioning that it is better to use port addresses instead of using sbit????coolmirza143
no,, i dont know how to call that.. hehe lol
what IN trying to say is u may also use that to make your code short...
instead of declaring sbit for 8times in 1 port it can be declare in one line
like
#define level P0 for port zero.. hehe lets wait for the others i dont know how to call that.. i just learned that in some example code.. hehe.. try it also..
level2=P0^1;
so how it is possible to define these in one line????
# define level P0 ....it will not work for me coz i wanna use each bit separately.....
@romel i dont think it is possible if coz i am defining seperate variable for each pin like level1=P0^0;
level2=P0^1;
so how it is possible to define these in one line????
# define level P0 ....it will not work for me coz i wanna use each bit separately.....coolmirza143
u can also use that.. here are the equivalents to your sbit.
P0.0 = 0x01 P0.1 = 0x02 P0.2 = 0x04 P0.3 = 0x08 P0.4 = 0x10 P0.5 = 0x20 P0.6 = 0x40 P0.7 = 0x80
if u want to check the P0.5 if it is high then u can say like this
let say u use this #define level P0
if(level==0x20) // meaning P0.5 is high /* your condition here */
it is the same if u say
sbit level5=P0^5
[ Edited Mon Nov 29 2010, 03:29 pm ]
Firstly the main intention should be fulfilled i.e solution to the problem.
In later stages code can be optimized.
The Programmer writes the code a/c to his understanding towards the problem not towards the length of the code, r unwanted varibles and all..
first i will test my code on hardware , will check my logic and then will change or modify code in necessary ........
@ Romel,
Firstly the main intention should be fulfilled i.e solution to the problem.
In later stages code can be optimized.
The Programmer writes the code a/c to his understanding towards the problem not towards the length of the code, r unwanted varibles and all..kirangowle
hi kirang
it's just a suggestion and it happened that mirza ask me if possible in that way so what i did is explained how it does..
i did not criticized the way he did the code because I am also not an expert in programming I only just a beginner in this field..
do u agree with me mirza?
[ Edited Mon Nov 29 2010, 05:03 pm ]
coz i know a russian scholar said never trust weeping girl....
beside that i agree both of u.......
@romel Don't Blackmail me
coz i know a russian scholar said never trust weeping girl....
beside that i agree both of u.......coolmirza143
waheheh lol.. hekhkehke
do u know pacman>?? hehe