Cub Scout, Tiger Mom and Arduino Electronic Dice

February 28th, 2011 § 1 comment § permalink

@theliuyan just posted a few pictures from the Sunday’s Cub Scout event. It was fun to introduce some hardware hacking to cub scouts. I think they enjoyed it with their great group of supportive parents. Just put Tiger Mom on the title for SEO. 😉 The activity is part of their scout engineering and we were making Electronics Dice.

IMG_0029

IMG_0027

IMG_0017

]]>

Electronic Dice

February 27th, 2011 § 0 comments § permalink

Got a chance to introduce Arduino to the boy scout at YCIS. It was a fun afternoon working with the boys and the parents. Here are more on the design of the electronic dice. Look forward to seeing the boys completing the system next week.

The tool used to design the dice is Fritzing. It’s an open source design program for interactive electronics. The functionalities of the dice is pretty straight forward: when the button is press, the LEDs start to flash and on the release of the button, one of the LED is randomly picked.

Untitled

Untitled

Arduino is used to drive the dice logics. Arduino is a popular open source microcontroller for building interactive electronics. It comes with an easy-to-use IDE that can be downloaded here.

Untitled

The complete program of the dice is here. Just connect up the Arduino board to the computer using the USB cable and launch the IDE to upload the program. Would be fun to see some tinkering with the program to provide different behavior of the dice.


#define RANDOM 1
#define PICKED 2
#define BOUNCEDELAY 50
int state;
void setup()
{
  pinMode(7, INPUT);
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  state = 1;
  Serial.begin(9600);
}
int reading = 0;
int button = 0;
int last_button = 0;
int picked = 0;
void loop()
{
  if (state == RANDOM) {
    digitalWrite(2, HIGH);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    delay(50);
    digitalWrite(2, LOW);
    digitalWrite(3, HIGH);
    digitalWrite(4, LOW);
    delay(50);
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    digitalWrite(4, HIGH);
    delay(50);
  } else if (state == PICKED) {
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    digitalWrite(picked, HIGH);
  }
  reading = digitalRead(7);
  if (reading == last_button) {
    button = reading;
  } else {
   last_button = reading;
  }
  if (button == 1) {
    state = RANDOM;
  } else {
    state = PICKED;
    if (button != last_button) {
      picked = random(3) + 2;
    }
  }
}
]]>

Visited by EmbeDream and their awesome FIRA bot

February 25th, 2011 § 0 comments § permalink

We received visitor from Nanjing based EmbeDream today. The gust come bearing gift of their open source FIRA bot. It’s of great design and I can’t not wait to try to hook it up to Arduino to have some fun! Here are some photos of the bot.

It’s small cube.

DSC 7334

Take apart one side

DSC 7318

DSC 7333

DSC 7329

DSC 7330

]]>

Design a Block Language for Arduino

February 7th, 2011 § 1 comment § permalink

I have been playing around with OpenBlocks. It’s a very flexible environment to create a new block language. When it comes to design one for Arduino, I found myself wondering between two different styles of design.

Design I

The first design is of course to follow the Arduino Language Reference closely. However, the resulting block language seems to be a bit too “verbose?” Or should I say “busy” since it’s really a graphical representation of the textual program. Here is a sample of what it looks like for the equivalence of codes here.

void setup() {
  pinMode(1, INPUT);
  pinMode(2, OUTPUT);
}
void loop() {
  if (digitalRead(1) == HIGH) {
    digitalWrite(2, LOW);
  }
}

Vpl 1

Design II

Since the block language is targeted at the beginner of Arduino and programming, most of time, we talk about “When the button on pin 1 is pushed, I want the LED on pin 2 to light up.” There is a much natural way to map this statement into an intuitive block language by building the blocks around the pin. Here is how it may look like:

Vpl 2

This language is more concise and easier to understand. The language itself should provide enough meta info to infer the setup codes. However, in order to do this, the language may need a little runtime (OS?) to be compiled along with the Sketch but it seems to be worth the effort.

The OpenBlocks codes I am playing around with the idea is available at my ‘ant’ branch openblocks on github. Appreciate any feedback on this.

]]>

Visual Programming Language for Arduino (1)

February 5th, 2011 § 0 comments § permalink

To make Arduino easier for non-programmers, I decided to start a visual programming environment similar to Scratch for Arduino.

Similar Projects around the Web

Modkit is a similar project but at the time I wanted to start the project, it was in a closed alpha. Also, it seems that modkit is going to be proprietary and I want an open source VPL for Arduino. By the way, Modkit CrimpCards is an awesome idea and design.

S4A (Scratch for Arduino) is another interesting project but it’s for using Scratch with Arduino instead of programming for Arduino.

David Mellis over at MIT Media Lab also has a project called “Scratch for Arduino” but no detail yet. David is also one of the creator of Arduino platform.

Arduino IDE and OpenBlocks

Fork the source of Arduino IDE hosted on github to host my version here. Next stop is to find a library for the visual programming. I found a project called OpenBlocks developed as part of the MIT StarLogo NG. Open Blocks is also used in Google’s Android development tool App Inventor.

Both Arduino IDE and Open Blocks are written in Java so the integration should be smooth. Since I have done by share of Java, I decided to also use this opportunities to look into a few alternative languages running on JVM to implement this. Since I have done mostly Ruby for the past few years, JRuby looks pretty good. The language I really want to use is Clojure but it seems it’s a bit tricky to use it embedded in a Java app. Will give both a try and see how it goes.

Let the hacking beging!

Hopefully, we will have a running version in the next few weeks. ]]>

Where am I?

You are currently viewing the archives for February, 2011 at 新车间 [XinCheJian].