Hi, that’s a great question! As far as I know, there are two ways for the brain to control robotic limbs.
The first one is for people to have an implant in their brain in the region that would normally control their movement. The electric impulses in this area are recorded and collected by a computer that process them and figures out what muscles and movements those electric impulses would produce if they could get to the muscles. Then this information is transmitted to the robotic limb that recreates those movements. There is a video and more details about how it works here: https://www.nature.com/news/mind-controlled-robot-arms-show-promise-1.10652
The second one is for the robotic limb to have some sensors in the part that gets attached to the body. Those sensors can detect the electric impulse the brain is sending towards the muscles that would normally do the movement. The robotic limb then ‘translates’ this information into moving the bits of it that correspond to the muscles that would have gotten the electric impulse. There is a video of how this works at the bottom of the article in Nature: https://www.nature.com/news/rewired-nerves-control-robotic-leg-1.13818
Hope this answers your question! Looking forward to the next one!