arduino UNO and mega and USB shield

guys i wanna help i have USB shield on UNO and i have MEGA i wanna make the UNO with the USB shield Master and the mega Slave and i wanna Send commands By PS3 controller to UNO to command the mega to Light a led for example i tried to combine the Wire library with USB host shield library but i faild Any help please

You need to post a schematic or at least a block diagram. It sounds like you want two things on the USB bus, the Mega and the PS3, is that right? If so you will also need a hub and some hub driving siftware.

Grumpy_Mike:
You need to post a schematic or at least a block diagram.
It sounds like you want two things on the USB bus, the Mega and the PS3, is that right? If so you will also need a hub and some hub driving siftware.

//master

#include <Wire.h> 
#include<PS3BT.h>
#include <SPI.h>
USB Usb;
BTD Btd(&Usb);
PS3BT PS3(&Btd);

 

void setup() {
 Serial.begin(115200);
if (Usb.Init() == -1) {
   Serial.print(F("\r\nOSC did not start"));
   while (1); //halt
 }
 Serial.print(F("\r\nPS3 Bluetooth Library Started"));
  Wire.begin();
 delay(20);
}
void loop() {
 Usb.Task();
 if(PS3.PS3Connected){
        if (PS3.getButtonPress(CROSS)){
         Wire.beginTransmission(5);
         
 Wire.write('h');
 Wire.endTransmission();
        }
        else{
         Wire.beginTransmission(5);
 Wire.write('l');
 Wire.endTransmission();
        }
 } }

thats for the slave the preview code for the master :smiley: please help whats wrong
//slave

#include <Wire.h>
#include<PS3BT.h>
#include <SPI.h>
USB Usb;
BTD Btd(&Usb);
PS3BT PS3(&Btd);

void setup() {
 //Usb.Task();
 Wire.begin(5);
Wire.onReceive(receiveEvent);
 pinMode(52,OUTPUT);
 digitalWrite(52,LOW);

}

void loop() {
 /*while (Wire.available())
 {
   char c=Wire.read();
   if (c=='h')
     digitalWrite(7,HIGH);
   else 
   digitalWrite(7,HIGH);*/
   
     
  
 }


void receiveEvent (int howmany){
 
 while(Wire.available()){
   char c=Wire.read();
   if (c=='h')
   {
     digitalWrite(52,HIGH);
   }
   else if (c=='l')
   digitalWrite(52,LOW);
   
 }
}

Please read this:- How to use this forum Because your post is breaking the rules about posting code.

Also what about that diagram? Your original post did not mention bluetooth.