Irreversible pollution by heavy metals such as lead (Pb) and cadmium (Cd) adversely affects the ecological environment and human health. Due to its high adsorption, microporosity, and specific surface area, biochar possesses excellent potential for use in heavy metal pollution remediation. The preparation of mixed-based biochar from sludge and cotton stalk can solve the problems inherent to pure sludge biochar, such as undeveloped pore structure and a small specific surface area, while resourcefully utilizing both waste biomass types. This study investigated the adsorption capacity for Pb2+ and Cd2+ of mixed-based biochar prepared at different pyrolysis temperatures, different pyrolysis residence times, and different cotton stalks percentages. Response surface experiments revealed the optimum process conditions for preparing mixed-based biochar, which included a pyrolysis temperature of 638 °C, a pyrolysis residence time of 86 min, and an addition ratio of 50% for cotton stalks. The isothermal adsorption experiments revealed that the maximum adsorption capacities of mixed-based biochar for Pb2+ and Cd2+ were 111.11 and 86.21 mg/g, respectively. Our findings suggest the co-pyrolysis of sludge and cotton stalk as a green and sustainable method for safely disposing of Pb and Cd.