     			production = true;
     		}
     	}
+    	
+    	
+    	// SEND RF24 //
+		String theMessage = "Hello there!";
+		int messageSize = theMessage.length();
+		for (int i = 0; i < messageSize; i++) 
+		{
+    		int charToSend[1];
+    		charToSend[0] = theMessage.charAt(i);
+    		radio.write(charToSend,1);
+  		}  
+ 
+		msg[0] = 2; 
+    	radio.write(msg,1);
+    
     }
   
 }

    expander.pinMode(5, OUTPUT);
    expander.pinMode(6, OUTPUT);
    expander.pinMode(7, OUTPUT);
    
    Serial.println("Booting successful !");
    Serial.println("====================");
	
}

void loop()
{
	/* SEND
	String theMessage = "Hello there!";
	int messageSize = theMessage.length();
	for (int i = 0; i < messageSize; i++) 
	{
    	int charToSend[1];
    	charToSend[0] = theMessage.charAt(i);
    	radio.write(charToSend,1);
  	}  
 
	msg[0] = 2; 
    radio.write(msg,1);
    */
    
    if (radio.available())
    {
    	bool done = false;  

        			int val = atoi(p + 1);
        			switch (*p)
        			{
          				case 'a': speedA  = val; break;
          				case 'b': speedB  = val; break;
      	  				case 'c': dirA    = val; break;
      					case 'd': dirB    = val; break;
        			}
      			}
    		}
       		
       		if (strcmp(strtok(msg, " "), "HEADSET") == 0)
    		{
        		Serial.println("UPDATE SETPOINT");
      			// trouvé le message
      			char *p;
      			while ((p = strtok(NULL, " ")) != NULL)
      			{
        			int val = atoi(p + 1);
        			switch (*p)
        			{
          				case 'x': setpointX  = val; break;
          				case 'y': setpointY  = val; break;
      	  				case 'm': multiplier = val; break;
      					case 'i': invertXY   = val; break;
      					case 'j': invertX    = val; break;
      					case 'k': invertY    = val; break;
      					case 'h': hysteresis = val; break;
        			}
      			}
    		}
    		Serial.print("SET x");
    		Serial.print(setpointX);
    		Serial.print(" y");
    		Serial.print(setpointY);
    		Serial.print(" m");
    		Serial.print(multiplier);
    		Serial.print(" i");
    		Serial.print(invertXY);
    		Serial.print(" j");
    		Serial.print(invertX);
    		Serial.print(" k");
    		Serial.print(invertY);
    		Serial.print(" h");
    		Serial.println(hysteresis);
       		
       		
       		if (strcmp(strtok(msg, " "), "HEADROTATE") == 0)
    		{
        		Serial.println("UPDATE SETPOINT");
      			// trouvé le message
      			char *p;
      			while ((p = strtok(NULL, " ")) != NULL)
      			{
        			int val = atoi(p + 1);
        			switch (*p)
        			{
          				case 'd': setpointX  = val; break;
          				case 's': setpointY  = val; break;
        			}
      			}
    		}
    		Serial.print("ROTATE d");
    		Serial.print(setpointX);
    		Serial.print(" y");
    		Serial.print(setpointY);
    		Serial.print(" m");
    		Serial.print(multiplier);
    		Serial.print(" i");
    		Serial.print(invertXY);
    		Serial.print(" j");
    		Serial.print(invertX);
    		Serial.print(" k");
    		Serial.print(invertY);
    		Serial.print(" h");
    		Serial.println(hysteresis);
       		
       		theMessage= ""; 
      	}
   }
   
   
	// MOTOR A (Left)
	// Run the motor
	if(speedA > 0) runA = true;
	else runA = false;
	speedA = 1000 / speedA;
	
	// Motor direction / With inversion
	if(invertA) 
  	{
    	if(dirA) dirA = false;
    	else dirA = true;
  	}
	digitalWrite(pinDirA, dirA); // Set the direction
	
	// Send Step inpultion to the motor
	unsigned long currentA = millis(); // millis();
   	if (currentA - previousMillisA >= speedA) 
   	{
      	previousMillisA = currentA;
      
      	if(runA)
      	{
        	digitalWrite(pinStepA, 1);
        	delayMicroseconds( 500 );
        	digitalWrite(pinStepA, 0);
        	delayMicroseconds( 500 );
      	}
  	} 

	// MOTOR B (Right)
	// Run the motor
	if(speedB > 0) runB = true;
	else runB = false;
	speedB = 1000 / speedB;
	
	// Motor direction / With inversion
	if(invertB) 
  	{
    	if(dirB) dirB = false;
    	else dirB = true;
  	}
	digitalWrite(pinDirB, dirB); // Set the direction
	
	// Send Step inpultion to the motor
	unsigned long currentB = millis(); // millis();
   	if (currentB - previousMillisB >= speedB) 
   	{
      	previousMillisB = currentB;
      
      	if(runB)
      	{
        	digitalWrite(pinStepB, 1);
        	delayMicroseconds( 500 );
        	digitalWrite(pinStepB, 0);
        	delayMicroseconds( 500 );
      	}
  	} 
	
   
   
   
