Feb 7, 2018 #1 V vead Full Member level 5 Joined Nov 27, 2011 Messages 285 Helped 3 Reputation 6 Reaction score 3 Trophy points 1,298 Location india Activity points 3,815 define statement is use for constant value #define TRUE 1 #define FALSE 0 what is difference between define port P0 and define Pin1 P0^0 ? Code: #include <reg51.h> #define port P0 #define Pin1 P0^0 #define Pin2 P0^1 #define Pin3 P0^2 #define Pin4 P0^3 char value(void) { unsigned char value; char i; for (i=0; i<4; i++) { value = 0x1110 1111; if(!Pin1) valueReturn = A; if(!Pin2) valueReturn = B; if(!Pin3) valueReturn = C; if(!Pin4) valueReturn = D; value <<= 1; value ++; } return valueReturn; }
define statement is use for constant value #define TRUE 1 #define FALSE 0 what is difference between define port P0 and define Pin1 P0^0 ? Code: #include <reg51.h> #define port P0 #define Pin1 P0^0 #define Pin2 P0^1 #define Pin3 P0^2 #define Pin4 P0^3 char value(void) { unsigned char value; char i; for (i=0; i<4; i++) { value = 0x1110 1111; if(!Pin1) valueReturn = A; if(!Pin2) valueReturn = B; if(!Pin3) valueReturn = C; if(!Pin4) valueReturn = D; value <<= 1; value ++; } return valueReturn; }
Feb 7, 2018 #2 andre_luis Super Moderator Staff member Joined Nov 7, 2006 Messages 9,593 Helped 1,190 Reputation 2,399 Reaction score 1,207 Trophy points 1,403 Location Brazil Activity points 55,670 what is difference between define port P0 and define Pin1 P0^0 ? Click to expand... The P0 statement represents a byte that maps all 8 pins of the port P0, whereas P0^0 represents a bit ( actualy the pin 0 of the port P0 ).
what is difference between define port P0 and define Pin1 P0^0 ? Click to expand... The P0 statement represents a byte that maps all 8 pins of the port P0, whereas P0^0 represents a bit ( actualy the pin 0 of the port P0 ).
Feb 7, 2018 #3 V vead Full Member level 5 Joined Nov 27, 2011 Messages 285 Helped 3 Reputation 6 Reaction score 3 Trophy points 1,298 Location india Activity points 3,815 if (a != 0) mean's 'if a is not equal to zero'. what is meaning of if(!Pin1)
Feb 7, 2018 #4 andre_luis Super Moderator Staff member Joined Nov 7, 2006 Messages 9,593 Helped 1,190 Reputation 2,399 Reaction score 1,207 Trophy points 1,403 Location Brazil Activity points 55,670 Different functions: ! NOT opperator ( logic inverse of the variable at right side ) != inequality evaluation ( returns true if both sides are different )
Different functions: ! NOT opperator ( logic inverse of the variable at right side ) != inequality evaluation ( returns true if both sides are different )
Feb 7, 2018 #5 V vead Full Member level 5 Joined Nov 27, 2011 Messages 285 Helped 3 Reputation 6 Reaction score 3 Trophy points 1,298 Location india Activity points 3,815 andre_teprom said: Different functions: ! NOT opperator ( logic inverse of the variable at right side ) != inequality evaluation ( returns true if both sides are different ) Click to expand... I know that but I don't understand if(!Pin1) in program
andre_teprom said: Different functions: ! NOT opperator ( logic inverse of the variable at right side ) != inequality evaluation ( returns true if both sides are different ) Click to expand... I know that but I don't understand if(!Pin1) in program
Feb 7, 2018 #6 andre_luis Super Moderator Staff member Joined Nov 7, 2006 Messages 9,593 Helped 1,190 Reputation 2,399 Reaction score 1,207 Trophy points 1,403 Location Brazil Activity points 55,670 vead said: I know that but I don't understand if(!Pin1) in program Click to expand... Code: if ([I]condition_is_true[/I]) { do_this(); } else { do_that(); } Were: condition_is_true => !Pin1 The above condition is true when Pin1==0
vead said: I know that but I don't understand if(!Pin1) in program Click to expand... Code: if ([I]condition_is_true[/I]) { do_this(); } else { do_that(); } Were: condition_is_true => !Pin1 The above condition is true when Pin1==0