We had four days during diwaali break and some of other people from Pankhudi group were also mulling over introducing programming to kids. I was working with UC for this possibility of doing home automation so we thought it would be nice to start with Arduino, Pi etc to give kids a real feel about how things can be programmed.
We had one arduino, some LED's and one relay switch. I was thinking of showing how easily we can control manual switches using programming. We passed around arduino board, pointed out some pins etc for a small intro and then wired up things. I was using nanpy and ipython console to pass commands to Arduino. One line of code and we had leds, bulbs blinking.
Arduino.digitalWrite(13, Arduino.HIGH) Arduino.digitalWrite(13, Arduino.LOW)
This initial group was bigger one, so I was not able to cover details etc, but mostly ended up "showing off" for random requests of what else can be done. But once kids got settled that there were not too many things, some stayed back while others drifted. Then we had a sort of extensive conversation about use cases, possibilities, why, how etc.
As other volunteers joined, there were parallel classes going on, and I was just covering same demo with some more details to different set of kids. Then I had couple of girls who started off with, यह क्या है भैया? After the answer their next question was, आप क्या काम करते हो? And here I slipped(mistake), I had a program open in editor, so I showed them those 5-10 lines and said, this is what I do, they were like ehh? and I replied, yeah we write programs like this and get paid. Now those 5-10 lines were not that complicated, but it certainly gave a wrong impression, and they were totally convinced to learn this skill.
Now with a limited focused audience, we got more time and over next few classes we covered some details of programming constructs. Good thing of using IPython is, it gives live interaction with system. First thing we covered was flipping the state of LED and hence introducing "if-else" construct or we called it something in lines of "या तो ये, नहीं तो ये"
if Arduino.digitalRead(13): Arduino.digitalWrite(13,Arduino.HIGH) else: Arduino.digitalWrite(13,Arduino.LOW)
We covered ideas like what is this if-else condition, indentation part here and in later parts. Next thing we moved onto was, making LED blink.
from nanpy import Arduino Arduino.digitalWrite(13,Arduino.HIGH) Arduino.digitalWrite(13,Arduino.LOW)
Now for this, we had to write a small python script and run it, and also concept of how computer runs this script line by line(instructions). But with this program, LED blinked very quickly so we introduced sleep function and how to call it with different parameters. Also a brief mention of import business we are doing.
from nanpy import Arduino from time import sleep Arduino.digitalWrite(13,Arduino.HIGH) sleep(2) Arduino.digitalWrite(13,Arduino.LOW)
From here we covered blinking a LED for a specific number of times(say 5 or 4). Firstly we landed up with idea that we can repeat lines 5(nth) times and we will get the task done. They wrote the program and tested if it was working. Now I introduced concept of looping(repeat something जब-तक), variable, counters.
from nanpy import Arduino from time import sleep counter = 0 while counter < 5: Arduino.digitalWrite(13,Arduino.HIGH) sleep(2) Arduino.digitalWrite(13,Arduino.LOW) sleep(2) counter = counter + 1
Here it took some time to make them understand what all is going on, why are we doing what we are doing. Once comfortable(they took this more like a bitter pill) they experimented with variation of counters, increment, while loop conditions and also infinite loop conditions. We had different color LED's so we tried combination of switching them on, syncing them and they very promptly related it to Traffic lightning and Diwaali light decorations.
I had this small program/function which gives some sense of noise level of surroundings(using mircrophone of system), so we thought of using this and writing a program which changes color of LED as the noise level changes. We started off by doing some trial runs to get idea of what are the values we are getting for different noise levels, they came up with the logic of roughly at what values the color should switch, we did some trials and edits and eventually we had something like this:
from nanpy import Arduino from time import sleep from noise import getRMS counter=1 while counter < 5: noise = getRMS() if noise == -1: continue print noise if noise < 2000: Arduino.digitalWrite(10,Arduino.HIGH) Arduino.digitalWrite(8,Arduino.LOW) Arduino.digitalWrite(12,Arduino.LOW) elif noise < 4000: Arduino.digitalWrite(12,Arduino.HIGH) Arduino.digitalWrite(8,Arduino.LOW) Arduino.digitalWrite(10,Arduino.LOW) else : Arduino.digitalWrite(8,Arduino.HIGH) Arduino.digitalWrite(10,Arduino.LOW) Arduino.digitalWrite(12,Arduino.LOW)
Pin 8 was green, 10 was blue and 12 was red(most noisy) and again they were quick to conclude that such LEDs can be installed in principal's room to give him idea of which class is going berserk. Next I was thinking of writing a small function which can return major component of color being shown to webcam and switching LED accordingly but didn't get that finished.
Now although this all looks good/decent approach, I was getting uncomfortable about missing something. Some kids are from elementary, while others are doing under-graduation but most of them are not from STEM background. So I am not sure on how to go about introducing ideas like lists, numbers, floating point numbers, complicated conditions. And also how to link all these with their needs/curriculum, I think I will have to go through their books to get better idea of what might appeal to them and make them do something which they themselves can use. I was not able to connect all these exercise with the starting idea of getting paid for doing these things. In last class while thinking these things, students were trying out scratch and they readily understood idea of "events" and control loops etc, but as the class ended without much of learning they said to me: "भैया अगली बार से English पढते हैं|"