For years I have always been adamantly against using pre-existing project code with students. In the past the way I have usually taught coding is a "I do, You do" mentality where students are sitting at their computer and follow along as write code on my computer and explain what the code does while they madly try to keep up, and ignore all of the wonderful wisdom coming from my mouth. I also found that due to the varying speed at which students type I was either having to stop and wait, or end up losing about 30% of my students.
To make things worse, at the middle school level and with the allotted time that I have my students, it is hard to teach serial communication between Processing and Arduino from scratch. A lot of the setup code doesn't make sense to students. What doesn't make sense to them they deem "useless" and ignore it.
So, I tried something new. I tried teaching from the Example code in Arduino. I works pretty well and allows for the students who get it to move on, and for me to help those who need to have access to me. I usually start by showing students how to cut and paste their code from Arduino to Processing as well as get the correct serial port. After that, it is trouble shooting on my part. I give students about 10 minutes to work on the base example and then I ask them to "hack" the code...to make changes to what they understand and see how it changes the project, as well as play with what they don't understand and see how that changes the sketches. Swapping out sensors, and/ or adding more LEDs etc. to whatever the example keeps the advanced students busy and learning something at all times.
It has been amazing to watch students who have in the past struggle with just getting a sketch working without errors really play with code and jump in with both feet really trying to manipulate the example beyond what I ever thought they could. It is amazing how much learning comes from just playing and exploring for some students. For others I do interrupt class from time to time to to show examples of coding and changes they can make...I usually thief off of students in the classroom and give them props for getting it working.
I am going to try to find a good balance between direct instruction and playing with examples in the coming term, it is a balancing act between letting kids play and losing them!