2016 Term 1: Arduino: Circuits and programming

  • Posted on: 6 April 2016
  • By: MelvaGill

Discuss the basic ideas of electrical flow, using the example of the flow of water then applying it to electricity. (A water source = a positive electrical charge, a resistor is like a water tap set to a specific setting and an LED light uses the flow of electricity in the same way that a water wheel uses the flow of water. Water flows to the ground, which mirrors the "ground" in electrical circuits) We discuss how power flows with a battery (something all the kids understand) then examine an arduino board and identify the digital ports that can act as a positive power source (+) and the ground ports (-) on it.

After talking about a basic circuit the kids are given an LED, a resistor, wires a breadboard and an Arduino board.

The first challenge is using a breadboard to wire up a circuit that flows from (+) -> resistor -> positive side of LED, then out of the negative side of the LED to ground. The difficulty here is to understand how each element needs to be separate in order for electricity to flow where you want.

The second challenge, once the circuit is working, we plug the arduino into the computer and create a program to turn the light on. The difficulty here is understanding there is a series of steps that need to be placed into a program then uploaded to the arduino.

The third challenge is to blink the led using computer code. They must discover a "digital port on" and a "digital port off" function as well as delays. Since the arduino can turn the port on 10s of thousands of times a second, the difficulty is figuring out that in order to blink you need to set the led on, then delay for a second, then turn it off, then delay again.

The fourth challenge is to make the led blink twice as fast. This requires them to figure out that in order to blink twice as fast, the delay needs to be half as long. For the kids with math prowess, they are asked to get the led to blink at different speeds (1/3 of a second, etc.)

The fifth challenge is to wire up a second LED. They are given wires, led, and resistor and asked to make a new program that blinks between the two lights. The challenge here is to apply everything they just did in order to replicate their circuit and to repeat the light blinking in the programs. The difficulty here is remembering how the first circuit worked (and troubleshooting it if it doesn't) and the stumbling block is duplicating the code creates an "off" state between each light blinking. They then need to step through each command in the code in order to see *why* the lights are both turning off. Once they see it, the kids can easily fix the code and wire up a 3rd led.

Extension challenges:

Wire up and use an RGB led to blink sequentially Red, Green, Blue and the purple. The challenge here is understanding how one led can have three elements controlled by three ports, and the stumbling block is that the blue and red leds need to "stay on" while switching between blue, purple and red. (and that red+blue = purple)

Wire up a variable potentiometer sent to an analogue port and use the output to set the delay between blinks.

Wire up a Servo motor and control it turning. The extension is to use a variable potentiometer to control the servo (which requires remapping the analogue value to degrees)

Wire up a buzzer and have it play various tones.

To Do List: 
See in description
LA Code: