PWM is fairly complicated to do from scratch. much easier to just buy a switching regulator, unless you have a good understanding of electronics (in addition to voltage, current, resistance, using an inductor also brings inductance, reactance and capacitance into the picture, many more variables...