some syntax not in arduino refernce guide?


i looking through tutorial on interfacing arduino qt401 sensor.  there commands , syntaxes totally don't understand , can't seem find in reference guide.  is able explain me mean?

the complete segment of code i'm quoting included below if want see context...

ok, first up:
code: [select]
byte qt401_transfer(byte data_out)

what bit in brackets refer to?  i thought variable declaration took format type variabletodefine = value; - the example above looks me kind of nested declaration or function call...

second question:
code: [select]
while(0 < i) {

   mask = 0x01 << --i

hmmmm... i'm stumped on one.  what "<<" , "--" mean?

third question:
code: [select]
if(data_out & mask){
i couldn't find reference "&" logical operator in reference guide...  how work?

number four:
code: [select]
data_in |= mask
is error , meant "!=" (ie, not equal to)...?

lastly, number five:
code: [select]
return data_in;
i can't find reference "return" command.... :(


well, sorry these such basic questions.  but bit of code looks useful project i'm starting, i'd love able understand properly...

is there more extensive arduino 0007 reference guide somewhere?

thanks can me out!

jon.




(here's snippet of code i'm referencing)
code: [select]

//
//  exchange byte sensor
//

byte qt401_transfer(byte data_out)
{
 byte = 8;

 byte mask = 0;
 byte data_in = 0;

 digitalwrite(qt401_ss,low); // select slave lowering ss pin
 delaymicroseconds(75); //wait 75 microseconds

 while(0 < i) {

   mask = 0x01 << --i; // generate bitmask appropriate bit msb first

   // set out byte
   if(data_out & mask){ // choose bit

     digitalwrite(qt401_do,high); // send 1

   }
   else{

     digitalwrite(qt401_do,low); // send 0

   }

   // lower clock pin, tells sensor read bit put out
   digitalwrite(qt401_clk,low); // tick

   // give sensor time read data

   delaymicroseconds(75);

   // bring clock up

   digitalwrite(qt401_clk,high); // tock

   // give sensor time think

   delaymicroseconds(20);

   // read bit coming sensor
   if(digitalread(qt401_di)){

     data_in |= mask;

   }

   //  give sensor time think

     delaymicroseconds(20);

 }

 delaymicroseconds(75); //  give sensor time think
 digitalwrite(qt401_ss,high); // acquisition burst

 return data_in;
}

for now, see: http://www.arduino.cc/playground/code/bitmath

the reasons operations aren't in reference because seem advanced features don't want confuse people with.  but seems should reconsider.  they added reference, or split reference, processing has done, regular , complete versions.  or maybe add functions replace of operations.  we'll have think it.


Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > some syntax not in arduino refernce guide?


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums