Category Archives: Coding

Creating with code – programming skills

Prototyping W/ Arduino

My homework for ‘Creating w/Code’ was to make a functioning prototype of some type of creation using an Arduino and writing reiterative sketches starting with one LED leading up to 3 LEDs and a Serial Bus:

Q1 What does your Code Look Like to control 1 LED?

I changed the delay to have the LED blink faster:

// 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(500); // wait for a half second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a quarter second
}

Q2 What does your Code Look Like to control 2 LEDs?

I alternated the two LEDs to blink opposite of each other at separate delays:

// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin 13 and 10 as outputs.
pinMode(13, OUTPUT);
pinMode(10, 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(500); // wait for a half a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a quarter second

digitalWrite(10, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a quarter second
digitalWrite(10, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for a half second
}

Q3 What does your Code Look Like to control 3 LEDs?

I added a third LED and made a serial bus for the circuit:

// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin 13 and 10 as outputs.
pinMode(13, OUTPUT);
pinMode(10, OUTPUT);
pinMode(7, 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(500); // wait for a half a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a quarter second

digitalWrite(10, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a quarter second
digitalWrite(10, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for a half second

digitalWrite(7, HIGH); // turn the LED on (HIGH is the voltage level)
delay(333); // wait for a third of a second
digitalWrite(7, LOW); // turn the LED off by making the voltage LOW
delay(333); // wait for a third of a second
}

And here it is:

And to make it functional – A Trippy Lamp:

This project was good because I could add on to the work that I did before and the reiteration helped me to retain the concepts learned along the way. In my previous post I wrote about how I understood MOST of what I was doing, but felt a little more disequilibrium than I would have preferred. Here I was able to put it all together without feeling out of my range. I love the hook of having a product for the prototype – to have a purpose for it. I was in no mood to create flowers (another project suggestion), nor did I have the materials at hand, but I do like my lamp!

Arduino – Beginning Something New (Again)

Today I begin to learn about the Arduino – the microprocessor, the IDE, the electronics around the processor and the projects, the C based program, etc., and what I realize, again, is that I know so little about so much!

I’m reading Getting Started with Arduino, 2nd Edition, by Massimo Banzi, one of the co-founders of the Arduino. It’s a great book – very accessible. In the book he explains beginning electronics well – something that I know almost nothing about. Something as simple as this, to me, is a revelation:

R (resistance) = V (voltage) / I (current)
V = R * I
I = V / R

_______________

I went on to create my first project and it all went well – I answered some of the questions wandering in my mind and, of course, those made more arise. When I look at the code I feel as if I understand most of it, but not all. It’s that disequilibrium that seems to underlie most of what I do within the tech arena – and I’m not sure I’m functioning with that feeling any better than I ever have…

IMG_4563

const int LED = 13; // the pin for the LED
const int BUTTON = 7; // the input pin where the
// pushbutton is connected
int val = 0; // val will be used to store the state
// of the input pin
int old_val = 0; // this variable stores the previous
// value of “val”
int state = 0; // 0 = LED off while 1 = LED on

void setup() {
// put your setup code here, to run once:
pinMode(LED, OUTPUT); // tell Arduino LED is an output
pinMode(BUTTON, INPUT); // and BUTTON is an input
}

void loop() {
// put your main code here, to run repeatedly:
val = digitalRead(BUTTON); // read input value and store it

// check if the input is HIGH (button pressed)
// and change the state

if (val == HIGH) {
state = 1 – state;
}

old_val = val; // val is now old, let’s store it

if (state == 1) {
digitalWrite(LED, HIGH); // turn LED ON

} else {
digitalWrite(LED, LOW);
}

}

______________

• I’m quite comfortable saying, “I don’t know, let’s find out,” but working alone makes that not so easy – I would far prefer to be working in a small group of active learners – bouncing ideas, new revelations, previous learning reminded – that’s helpful for me. It’s great that there are so many online communities with the resources they provide and that finding an answer to a question, or learning how to ask a question in a better way, is so quickly available, but the human give and take, the purpose behind the task of the moment seems to be lessened without that interaction.
___________________

The second project entailed using Pulse Width Modulation (PWM) – a way to  change its brightness by changing the ratio between the on time and the off time of an LED. I got it to work, and have a fairly good idea how the code works, but again, I’m not feeling that comfortable with it. After reading 66 of the 130 pages and doing the projects up to that point I’m starting to feel that familiar feeling of cognitive overload and think that it’s best to stop for the moment.

const int LED = 9; // the pin for the LED
int i = 0; // We’ll use this to count up and down

void setup() {
// put your setup code here, to run once:
pinMode(LED, OUTPUT); // tell Arduino LED is an output
}

void loop() {
// put your main code here, to run repeatedly:
for (i = 0; i < 255; i++) { // loop from 0 to 254 (fade in)
analogWrite(LED, i); // set the LED brightness
delay(10); // Wait 10ms because analogWrite
// is instantaneous and we would
// not see any change
}

for (i = 255; i > 0; i–) { // loop from 255 to 1 (fade out)
analogWrite(LED, i); // set the LED brightness
delay(10); // Wait 10ms
}

}

________________

 

Python, Robot, and Raspberry Pi

Finally, after postal delays from China and not being able to leave the house from a bad dirt road, I have everything I need to continue my coding studies with Arduino and the RPi. I’m pretty far behind so I’ll have to spend a lot of the next few days catching up.

I’m using Brian Hill’s (sentdex)  YouTube tutorial – Raspberry pi with Python for Robotics and the SainSmart 4WD Chassis Aluminum Mobile Robot Platform For Robot Arduino Raspberry Pi for both my Pi and Arduino projects.

IMG_4552

So far I have been through two of the seven tutorials and written my first bit of Python code. I’ve attached one motor to the bridge and tested it and everything works fine so far

IMG_4553

Gender Bias in the Coding Community

While I’m trying to learn more about the coding community around me, I just saw a research paper about the GitHub community that clearly shows biases against women:
• Biases against women in the workplace have been documented in a variety of studies. This paper presents the largest study to date on gender bias, where we compare acceptance rates of contributions from men versus women in an open source software community. Surprisingly, our results show that women’s contributions tend to be accepted more often than men’s. However, when a woman’s gender is identifiable, they are rejected more often. Our results suggest that although women on GitHub may be more competent overall, bias against them exists nonetheless.

The story has been picked up by CNN and BBC News.

Beginning Python – Learning Vi/Vim

Because it’s Project Week, and I’m going to be putting together a RPi robot that will depend on Python to run, I am going to begin a Python tutorial. To start I went to the Python Wiki and found Python for Beginners. It’s asking me to learn about IDEs (Integrated Development Environments) and text editors. I choose PyCharm as my IDE because it’s open source, was updated not long ago, and supports two of the platforms I’m using, to choose a text editor I go to the Debian Wiki as the OS I’m using, “Jesse,” is the codename of Debian 8.  I choose Vim as my text editor. I installed Vim from the handy add / remove software in the accessories folder, but can’t find PyCharm in the directory of programs. I downloaded it from their site, but don’t have enough experience unpacking a tar, nor really where to put it – or anything. I do try my best to find an answer because there’s so much learning in the process, but it’s best that I don’t make a mistake – a little knowledge can be a dangerous thing.

Leaving the IDE for the moment, I am going to focus on learning the command line editor Vi – I have Vim installed and I’m using a good YouTube tutorial from Alvin Alexander.

Raspberry Pi

To update, I am currently running a RPi Model 2 with a new 32 GB sd micro card w/Debian Jesse. You can look here and here to see how I got this far. The problem of the moment is getting a good browser to work. I really don’t like Epiphany and would like to upgrade to Mozilla’s Iceweasel, I did a manual install which ran fine, but can’t get it to load as it throws an error saying that it can’t find all the resources it needs to run.

IMG_4461I’ve curated a list of resources and, as I’m learning to reach out to Communities more, I’ve done a search on the Raspberry Pi Forum at Raspberry Pi.Org for a fix. From looking on that I’ve decided to try my luck with Chromium 45 – another browser that seems promising. For those new to RPi, I strongly suggest putting some time aside to learn some terminal commands and to learn to copy and paste into the terminal. Much of the help out there gives the necessary code to get the things you need or make the changes you’d like. I attempt to install this from the forum:

wget http://ftp.us.debian.org/debian/pool/main/libg/libgcrypt11/libgcrypt11_1.5.0-5+deb7u3_armhf.deb
wget http://launchpadlibrarian.net/218525709/chromium-browser_45.0.2454.85-0ubuntu0.14.04.1.1097_armhf.deb
wget http://launchpadlibrarian.net/218525711/chromium-codecs-ffmpeg-extra_45.0.2454.85-0ubuntu0.14.04.1.1097_armhf.deb
sudo dpkg -i libgcrypt11_1.5.0-5+deb7u3_armhf.deb
sudo dpkg -i chromium-codecs-ffmpeg-extra_45.0.2454.85-0ubuntu0.14.04.1.1097_armhf.deb
sudo dpkg -i chromium-browser_45.0.2454.85-0ubuntu0.14.04.1.1097_armhf.deb

Reboot and it’s there and it’s working! Yay!

I want to show you a screenshot of the desktop but don’t know how – back to the community – there is a command line tool (unfortunately) called ‘Scrot.’ – and I get instructions on how to use it.

IMG_4463Well, I’m embarrassed to say that I ran the wrong code in sudo and totally borked my Pi and have decided to reinstall the OS and start again. Frustrating, but live and learn… At least it’ll give me practice on how to reconfigure the system and luckily I have my own breadcrumbs to follow from this weblog!

Update: I was able to put everything back together again and it really didn’t take too long because I had done it before, and yes, it was good practice. Desktop

Coding With Mobile Apps – Part Two – Getting Down to Scratch Jr.

The second part of my Creating with Code assignment is to find one mobile app that helps children to learn how to code and to explore that app and reflect upon it as I wish. I began the process by downloading nine suggested apps; Cargo-B0t, Kodable, Tickle, Daisy the Dino, The Foos, Hopscotch, Lightbot Hour, Scratch Jr., and TinkerBox.

The next step was to open one website for each app and to be totally judgmental in terms of aesthetics, likely support, popularity, and most importantly, whether I want this piece of software in my classroom life – can I stand to see it on a consistent basis? I immediately drop Daisy the Dino as it’s way to ‘cute’ and I know I will tire of her quickly. I lose TinkerBox because I see no appreciable web presence and therefore little community connection.

The next step was to open each one of the remaining seven on the iPad to get an initial impression. I drop Kodable for aesthetic reasons; the character’s voice and cutesy blinking eyes are too much to bear day-to-day, ditto for The Foos. Now I’m down to five apps that, thankfully, look quite promising. I leave Tickle behind because I know I will use it for other reasons, Hopscotch because it seems the weakest of the ‘block’ apps, and Lightbot Hour only because it seemed the need to include music, which is sometimes a deal breaker in a classroom, even with a mute button.

I played with Cargo-Bot and Scratch Jr. for a while and choose Scratch Jr. because it’s scalable to Scratch, its ease of use, the recording function, its community support, and seems quite deep enough so as not to tire of it.

File_000In the not so very distant future expect a post on a planned “Scratch Day” in which I will use Scratch on my Raspberry Pi, Scratch on CS First, and my new member of the family, Scratch Jr.

 

Coding with Mobile Apps – Part One: The Logical Journey of the Zoombinis

Sequencing, checking for events, using conditionals, being iterative and incremental, reusing and remixing, making sure that things work – finding and fixing mistakes. These are concepts and practices computer science students must consider when using computers yes? Hmmmm yes, but who cares when you’re using a mobile application solving puzzles and having fun! As a matter of fact – you don’t even need to read…

The Logical Journey of the Zoombinis, which I bought for $5 at the Apple store for iPad, is a highly entertaining and educational package of 12 puzzles which get incrementally more difficult as you move through them. The Zoombinis, little blue creatures with 625 different possible combination of attributes, move along a path toward safety. Those who don’t help solve a problem are gently sent back at a resting point behind while their fellow travelers move on, allowing them to catch-up later.

Screen Shot 2016-02-07 at 5.44.57 PM

The makers of the game, TERC, the Technical Education Research Centers, has imbedded a great deal of mathematical thinking in the game – hypothesis formation, algebraic thinking, sorting, set theory,  pattern finding, attribute comparison, and logical reasoning, but to me, someone who’s heavily involved in thinking about ways to integrate computer science into a child’s life, this is a remarkably intelligent way to incorporate it in a playful way.

Here’s a movie I made to introduce you to a few of the 12 puzzles and to some of the CS concepts and practices behind it:

Zoombinis works on a highly cognitive level – it makes the player think about thinking and its design is smart enough to move along with the level of the player as it eases the way into more difficult constructions.

I think perhaps the best way to present this to students may be to keep one game going on an iPad and discourage the creation of a new game. The iPad then can be passed around as individuals and groups continue to progress through it. For younger children it may take the whole school-year to get all the Zoombinis through, and if you continually start new games there is a danger of repeating old concepts and not taking advantage of the incremental nature of the game – best of all there’s the added satisfaction of getting them all across together as a group – and how fun is that?

Mindstorms: Computers, Children, and Powerful Ideas

In my “Creating with Code” class I’m taking at the Marlboro College Graduate Center we have, appropriately, been studying Seymour Papert’s constructionism based on Piaget’s work in constructivist theory.

hardware-hacking-in-schools-acec2014-3-638

I will be revisiting meaning-making throughout this course and every course I take (and teach) while receiving my #42 endorsement and reinstatement of my teaching license.