user6549: I recently read this piece of code and I dont know what is the use of "<<=" in the for loop:
for (mask = 0x01; mask>0; mask <<= 1) {
    if (data & mask){ // choose bit

This is the entire code:
//Created August 23 2006
//Heather Dewey-Hagborg
//http://www.arduino.cc

#include <ctype.h>

#define bit9600Delay 100  
#define halfBit9600Delay 500
#define bit4800Delay 188 
#define halfBit4800Delay 94 

byte rx = 6;
byte tx = 7;
byte SWval;

void setup() {
  pinMode(rx,INPUT);
  pinMode(tx,OUTPUT);
  digitalWrite(tx,HIGH);
  delay(2);
  digitalWrite(13,HIGH); //turn on debugging LED
  SWprint('h');  //debugging hello
  SWprint('i');
  SWprint(10); //carriage return
}

void SWprint(int data)
{
  byte mask;
  //startbit
  digitalWrite(tx,LOW);
  delayMicroseconds(bit9600Delay);
  for (mask = 0x01; mask>0; mask <<= 1) {
    if (data & mask){ // choose bit
     digitalWrite(tx,HIGH); // send 1
    }
    else{
     digitalWrite(tx,LOW); // send 0
    }
    delayMicroseconds(bit9600Delay);
  }
  //stop bit
  digitalWrite(tx, HIGH);
  delayMicroseconds(bit9600Delay);
}

int SWread()
{
  byte val = 0;
  while (digitalRead(rx));
  //wait for start bit
  if (digitalRead(rx) == LOW) {
    delayMicroseconds(halfBit9600Delay);
    for (int offset = 0; offset < 8; offset++) {
     delayMicroseconds(bit9600Delay);
     val |= digitalRead(rx) << offset;
    }
    //wait for stop bit + extra
    delayMicroseconds(bit9600Delay); 
    delayMicroseconds(bit9600Delay);
    return val;
  }
}

void loop()
{
    SWval = SWread(); 
    SWprint(toupper(SWval));
}


user42: << is the left bit-shift operator. That means it takes the binary contents of a number and moves everything left by a certain number of binary places (1 place in this case). <<= simply combines the left bit-shift with an assignment, so it takes the current value of mask, shifts it left, and then stores the result back in mask.
In this situation, the mask variable starts with a value of 1. The second time round the loop, it will be 10 (binary). Next time, it will be 100, and so on. Since mask is a byte (which is 8 bits), it will go all the way up to 10000000 and then stop. After that, the 1 effectively falls-off the left and mask ends up with a value of 0.
The purpose of this in the code you provided is to test each individual bit within the data parameter. It basically goes through from least- to most-significant and checks if each bit is 1 or 0. It will then pull an output pin HIGH or LOW (respectively) to match. This allows it to send the contents of the variable digitally to some other device.
Doing low-level binary (aka bit-wise) operations like this is very common in microcontroller programming. If you're not familiar with it then I'd definitely recommend looking up some tutorials online. It opens up a huge range of new possibilities for your projects.

user5168: As stated in the other answers, the <<= operator shifts the byte to the left; however, the number '1'  after it specifies how far to shift it - so, 2 <<= 2 == 8.
Possibly clearer in binary:
00000001 <<= 1 == 00000010
00000010 <<= 1 == 00000100
00000001 <<= 2 == 00000100

user3879: In simpler terms mask <<= 1 is shorthand for mask = mask << 1
In general 
variable operator= operand

is the augmented assignment operator which means 
variable = variable operator operand 


6549: <p>I recently read this piece of code and I dont know what is the use of "&lt;&lt;=" in the for loop:</p>

<pre><code>for (mask = 0x01; mask&gt;0; mask &lt;&lt;= 1) {
    if (data &amp; mask){ // choose bit
</code></pre>

<p>This is the entire code:</p>

<pre><code>//Created August 23 2006
//Heather Dewey-Hagborg
//http://www.arduino.cc

#include &lt;ctype.h&gt;

#define bit9600Delay 100  
#define halfBit9600Delay 500
#define bit4800Delay 188 
#define halfBit4800Delay 94 

byte rx = 6;
byte tx = 7;
byte SWval;

void setup() {
  pinMode(rx,INPUT);
  pinMode(tx,OUTPUT);
  digitalWrite(tx,HIGH);
  delay(2);
  digitalWrite(13,HIGH); //turn on debugging LED
  SWprint('h');  //debugging hello
  SWprint('i');
  SWprint(10); //carriage return
}

void SWprint(int data)
{
  byte mask;
  //startbit
  digitalWrite(tx,LOW);
  delayMicroseconds(bit9600Delay);
  for (mask = 0x01; mask&gt;0; mask &lt;&lt;= 1) {
    if (data &amp; mask){ // choose bit
     digitalWrite(tx,HIGH); // send 1
    }
    else{
     digitalWrite(tx,LOW); // send 0
    }
    delayMicroseconds(bit9600Delay);
  }
  //stop bit
  digitalWrite(tx, HIGH);
  delayMicroseconds(bit9600Delay);
}

int SWread()
{
  byte val = 0;
  while (digitalRead(rx));
  //wait for start bit
  if (digitalRead(rx) == LOW) {
    delayMicroseconds(halfBit9600Delay);
    for (int offset = 0; offset &lt; 8; offset++) {
     delayMicroseconds(bit9600Delay);
     val |= digitalRead(rx) &lt;&lt; offset;
    }
    //wait for stop bit + extra
    delayMicroseconds(bit9600Delay); 
    delayMicroseconds(bit9600Delay);
    return val;
  }
}

void loop()
{
    SWval = SWread(); 
    SWprint(toupper(SWval));
}
</code></pre>
 42: <p><code>&lt;&lt;</code> is the left bit-shift operator. That means it takes the binary contents of a number and moves everything left by a certain number of binary places (1 place in this case). <code>&lt;&lt;=</code> simply combines the left bit-shift with an assignment, so it takes the current value of <code>mask</code>, shifts it left, and then stores the result back in <code>mask</code>.</p>

<p>In this situation, the <code>mask</code> variable starts with a value of <code>1</code>. The second time round the loop, it will be <code>10</code> (binary). Next time, it will be <code>100</code>, and so on. Since <code>mask</code> is a byte (which is 8 bits), it will go all the way up to <code>10000000</code> and then stop. After that, the 1 effectively falls-off the left and <code>mask</code> ends up with a value of 0.</p>

<p>The purpose of this in the code you provided is to test each individual bit within the <code>data</code> parameter. It basically goes through from least- to most-significant and checks if each bit is 1 or 0. It will then pull an output pin HIGH or LOW (respectively) to match. This allows it to send the contents of the variable digitally to some other device.</p>

<p>Doing low-level binary (aka bit-wise) operations like this is very common in microcontroller programming. If you're not familiar with it then I'd definitely recommend looking up some tutorials online. It opens up a huge range of new possibilities for your projects.</p>
 5168: <p>As stated in the other answers, the <code>&lt;&lt;=</code> operator shifts the byte to the left; however, the number '1'  after it specifies how far to shift it - so, <code>2 &lt;&lt;= 2</code> == 8.
Possibly clearer in binary:</p>

<p><code>00000001 &lt;&lt;= 1</code> == <code>00000010</code></p>

<p><code>00000010 &lt;&lt;= 1</code> == <code>00000100</code></p>

<p><code>00000001 &lt;&lt;= 2</code> == <code>00000100</code></p>
 3879: <p>In simpler terms <code>mask &lt;&lt;= 1</code> is shorthand for <code>mask = mask &lt;&lt; 1</code></p>

<p>In general </p>

<pre><code>variable operator= operand
</code></pre>

<p>is the augmented assignment operator which means </p>

<pre><code>variable = variable operator operand 
</code></pre>
