Friday, February 25, 2011


The Html5-based Modkit editor for Arduino, excited me because it seems like another gradual step for middle and high school students to learn important science, technology, math, arts and engineering. So far, we have elementary students starting Gamestar Mechanic and continuing with Scratch, or Alice; Modkit or AppInventor; and iOS SDK. They should be ready to start work on Java in high school with much better preparation.

I got an Arduino Uno (~$30 fully assembled and tested) to help evaluate the system over vacation. The Modkit team recently released a public beta associated with the publication of the latest version of Make Magazine. A comment from the Modkit team about the release of the public beta indicates that it should be possible to program other pins, too. But when I try to program it, I only get a "Programming device" followed by "error compiling" messages. Arduino literature says I should choose /dev/tty.usbmodemXXX but I see /dev/cu.usbmodem621. Could that be the problem?

So, I decided to wade into using Arduino programming tools directly. That seemed to me to be a less than optimal solution for students but it would allow me to troubleshoot the failure transfer and run simple programs. I hesitated because I don't have time to learn another language. But I discovered that Arduino developers have created an environment that reminds me of the early days of learning how to code html pages: examine and copy source, modify to get the desired result, and share. When I open the Arduino monitor, it says that it is using /dev/tty.usbmodem621. Could that be the reason it works for Arduino and not for Modkit?

In any event, I suspect that the MAMS ITeam html5 group can easily work at this level. Then when we figure out how to use the Modkit, then the more experienced users can help the new users to get started.

Analog Input
Demonstrates analog input by reading an analog sensor on analog pin 0 and
turning on and off a light emitting diode(LED) connected to digital pin 13.
The amount of time the LED will be on and off depends on
the value obtained by analogRead().

The circuit:
* Potentiometer attached to analog input 0
* center pin of the potentiometer to the analog pin
* one side pin (either one) to ground
* the other side pin to +5V
* LED anode (long leg) attached to digital output 11
* LED cathode (short leg) attached to 110 ohm resistor to ground

* Note: I use the Uno Arduino's built-in LED attached
to pin 13 on the board, as the second LED.

Created by David Cuartielles
Modified 4 Sep 2010
By Tom Igoe
Modified 28 Feb 2011
By SC Spaeth

This example code is in the public domain.



int sensorPin = A0; // select the input pin for the potentiometer
int ledPin13 = 13; // select the pin for the LED
int ledPin11 = 11;
int sensorValue = 0; // variable to store the value coming from the sensor

void setup() {
// declare the ledPin as an OUTPUT:
pinMode(ledPin13, OUTPUT);
pinMode(ledPin11, OUTPUT);
// open the serial port at 9600 bps:

void loop() {
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
// print the value from the sensor:
// turn the ledPin on
digitalWrite(ledPin13, HIGH);
digitalWrite(ledPin11, LOW);
// stop the program for <sensorValue> milliseconds:
// turn the ledPin off:
digitalWrite(ledPin13, LOW);
digitalWrite(ledPin11, HIGH);
// stop the program for for <analogInMax - sensorValue> milliseconds:
delay(1023 - sensorValue);
Now I see a small flaw in this system where the html transfer converts the 'less than' and 'greater than' brackets of the html into ampersands and code in the last few lines. It does however show up in the rendered blog page as written in on the Arduino resource page. That can be fixed with an adjustment to documentation style. Not bad for a few hours of tinkering!

No comments: