#define in an IF statement


hi there,

trying use potentiometer change colour used in led strips, i've written not sure if should work or not? there similar use?

code: [select]
  if(val < 341){
  #define colour red
  }
  else if(val < 682 ){
  #define colour blue
  }
  else{ 
  #define colour yellow
  }
  serial.println(val);



no, won't work, preprocesor directives global, , evaluated @ compile time-
a simple variable assignment work.


Arduino Forum > Using Arduino > Programming Questions > #define in an IF statement


arduino

Comments

Popular posts from this blog

invalid use of void expresion in FlexiTimer2 library

error: a function-definition is not allowed here before '{' token

LED Strip Code