About the "int" data type variable
i looking @ example code , noticed these lines:
my question is, if "int" type stores integers, why being used store "low?" why not make compiler error?
later in program use this:
so question is, int variable lets store "low" or "high" in it, , not number?
second question wouldn't program better (more memory efficient) change ledstate , do, example:
thanks!
code: [select]
// constants won't change. used here
// set pin numbers:
const int ledpin = 13; // number of led pin
// variables change:
int ledstate = low; // ledstate used set led
long previousmillis = 0; // store last time led updated
my question is, if "int" type stores integers, why being used store "low?" why not make compiler error?
later in program use this:
code: [select]
if(currentmillis - previousmillis > interval) {
// save last time blinked led
previousmillis = currentmillis;
// if led off turn on , vice-versa:
if (ledstate == low)
ledstate = high;
else
ledstate = low;
// set led ledstate of variable:
digitalwrite(ledpin, ledstate);
so question is, int variable lets store "low" or "high" in it, , not number?
second question wouldn't program better (more memory efficient) change ledstate , do, example:
code: [select]
boolean ledon=true;
thanks!
Arduino Forum > Using Arduino > Programming Questions > About the "int" data type variable
arduino
Comments
Post a Comment