How to control motor direction with the L298N H bridge and RCWL-0516 sensor

Hi,

I am a beginner when it comes to programming an arduino and have been learning mostly through videos on Youtube but so far have not found what I need to know for my next project.

Specifically, I am wanting to change the direction that a dc motor turns every time my RCWL-0516 proximity sensor is activated. I haven't found anything online that explains how to alternate between pins each time the sensor goes high.

Any help would be greatly appreciated.

C

Welcome to the forums. Check out this tutorial here

They use a button to change direction. You will have to modify the code to read your proximity sensor instead, but the idea is the same.

Thanks, I'll check out the link you sent.