Sadly i am not really experienced with electronics, i have recently obtained an Arduino and a motor driver and i am trying to hookup some lego motors. My motor driver outputs 2 signals, one for direction (high/low) and one for speed (PWM). My lego motor (Power functions medium) has 2 inputs for PWM signals, one forward and one reverse. So i was thinking i could connect these by sending my PWM signal from the motor driver to one of the two inputs based on the direction signal voltage from the motor driver. What kind of component could do this job? I have been looking into using a transistor as a switch but i am not sure if i will be able to make it work like i want.
So upon looking at that motor, I believe you can not power it directly with Arduino PWM power, you need to buffer the signal because the PWM is directly powering the motor.
The problem here is that digital pins on an Arduino (Atmega 328p and all other microcontolers) are designed to only provide a small amount of current (typically < 20mA). What you really want is an H Bridge system, this is a chip or device that typically takes a single PWM signal and a direction signal. An example of one that would work for you is the L293, Sparkfun and Adafruit have both information and motor control boards based on these chips. The good news is that they still are made in DIP packages so you can buy some and drop them in a bread board.
Here is an example using the L293 chip mentioned:
Assuming these PWM outputs are 5v TTL-like on both the Arduino and Lego sides, I'd go for something like a 4016 transmission gate with an inverter arranged so that with your direction line high, the PWM signal will be routed to this motor; with it low, it'll get routed to that motor.
This will leave the 'inactive' motor with a floating input, which may not be what it's expecting.
I'd advise that you get the Arduino/Lego interface working in one direction to start with (using just one of the motors and ignoring the direction line) before trying to get a bidirectional circuit going.
Hopefully I interpreted your question correctly.
It can be made with "logical gates" (shown at the top),
or it can be built from scratch with N-channel MOSFET transistors (shown at the bottom).