This mixed methods sequential explanatory study explored how computational thinking influences elementary students' attitudes by engaging the students in coding a music composition with an autonomous robot. Pre and post tests were used to document students’ attitudes toward music composition and coding over the course of six weeks. Eighty fifth-grade students participated in the music composition project, coding for one hour each week in an engineering class. The students were randomly organized into four study groups: individualized, collaborative, traditional, and Use-Modify-Create (UMC). Findings indicate that students experienced a significant increase in positive attitudes toward music composition after the robotics coding activity. Both the individualized and collaborative groups reported enhanced enthusiasm for music composition, while the UMC group showed increased positivity towards coding and greater confidence in their coding abilities. These results suggest that music educators can enhance student attitudes toward both computational thinking and music composition by integrating robotics into the music curriculum. The main contributions of this study include: (1) empirical evidence of positive attitude changes toward music and coding through robotics; (2) comparative analysis of four instructional modes; and (3) a practical framework for integrating robotics into elementary music education.