       
       Serial.print("Posicoes: ");
       Serial.print(receivedControls);
-      
-      
+      j1y=hextodecimal(receivedControls[1]);
+      Serial.print("Valor: ");
+      Serial.print(j1y);
+      j1y=map(j1y,0,15,0,180);
+      j1y=180-j1y;
+      myservo.write(j1y);
+      Serial.print("Servo: ");
+      Serial.print(j1y);
       // First, stop listening so we can talk
       radio.stopListening();
 
       
       // Send the final one back.
       Serial.println(" ... Enviando resposta.");
-      radio.write( &receivedControls, sizeof(nadave) );
+      radio.write( &receivedControls, sizeof(receivedControls) );
       
       // Now, resume listening so we catch the next packets.
       radio.startListening();


//Variables needed
char receivedControls[6] = "aaaa;";
char nadave[6] = "CUCU;";


void setup(void)
{

  //Listen to Radio and print details about it.
  radio.startListening();
  radio.printDetails();
  myservo.attach(3);
  pinMode(4,OUTPUT);
  digitalWrite(4,HIGH);
}
int hextodecimal(char c){
  switch (c){
    case 48: return 0; break;
    case 49: return 1; break;
    case 50: return 2; break;
    case 51: return 3; break;
    case 52: return 4; break;
    case 53: return 5; break;
    case 54: return 6; break;
    case 55: return 7; break;
    case 56: return 8; break;
    case 57: return 9; break;
    case 97: return 10; break;
    case 98: return 11; break;
    case 99: return 12; break;
    case 100: return 13; break;
    case 101: return 14; break;
    case 102: return 15; break;
    default: return -1; break;
    
  }
  
}

