Tuesday, November 10, 2015

Arduino's and 5th Graders

I started co-teaching with Mrs. Hagar today. We were introducing Arduino's to the 5th graders. The students had worked with them last year, but many of the students transferred in this year. As you can imagine, there was a wide mix of ability and comfort levels.
Mrs. Hagar asked me to help strengthen the students' understanding of the coding side of Arduino's. So, we started with a simple blinking sketch. The first class used the Sparkfun "Circuit_1" sketch. This is a good sketch and it is VERY detailed with explanations. In the classroom setting though, these explanations actually made it harder to use the sketch. There were 200+ lines of comments with <10 lines of actual code. The comments are good if you are self-teaching, but they became a distraction when trying to teach.

The 2nd class comes in and I changed tactics. We loaded the built-in "Blink" sketch that comes preloaded with the Arduino software. This is the exact same sketch, minus all the superfluous explanation. This sketch worked much better.

We started with just the Arduino and  and the computer. I walked to the students through the few lines of code and explained what each one did. We talked about the different between analog and digital. I described what the { } meant and did. We learned how to read the comments to get a better understanding of the code. All was going well. I then had them Verify and Upload the sketch to the Arduino so we could see how the LED #13 flash. I challenged the students to speed up the flashing and then slow down the flashing. The students simply changed the delays in the code. But, they were changing both of the delays (on and off). So I challenged them to have a long ON with a short OFF blink pattern. The final step was the challenge of Morse Code.
I originally wanted SOS (. . . _ _ _ . . .), but shortened it to just (. . _ _) The students completed this with 80-90% success. They were still struggling with the difference between the ON and OFF delays and many of them still had them "tied" together.

Now was time to build a circuit. We used the first example in the Sparkfun Inventors Kit Codes book (SIK Codes). They wired in an LED with a 330 ohm resistor to digital pin 13. This LED was now blinking with the onboard LED. We discussed why that was (because they are both pin 13). We then discussed how we could change them so that they blinked at separate times. The last challenge was to make the necessary changes to the code and wiring to have the LED's blink separately. (don't forget to add a pinMode(xx, OUTPUT) for the new pin used, otherwise the LED will not be very bright.

This is code from the sketch we were using:

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 13 as an output.
  pinMode(13, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second
}

No comments:

Post a Comment