• ABOUT THIS SITE
  • MY CV
  • MY SOCIAL STREAM
  • CONTACT
  • SEARCH

olav.net

  • content
  • technology
  • life
  • bonn
Home

3x3x3 LED Cube in Javascript

olav — Sun, 06/13/2010 - 20:46

The other day I built a 3×3×3 LED cube, following the excellent instructable by gzip . Now that I have drifted away a little bit from the Arduino platform, and, mostly for the ridiculously cheap PICAXE-08M, have looked into the PICAXE platform, I have decided to port my LED cube over to a 3V PICAXE-20X2 microcontroller.

Before doing that, I wanted to more thoroughly understand the procedural approach to LED patterns that gzip used in his design, so I programmed a litte LED cube simulator in Javascript:

The biggest challenge were the delay() calls in the original software. There is no such thing as a delay() function in Javascript. Sure, there are some clever solutions out there like using a modal dialog, but I found using the standard setInterval() to be quite enough. There is one tricky piece in the code where I want to run a longer sequence from within the regular 500ms ticks. For this, I kill the overall timer, run the sequence, and finally restart the overall timer in a callback to the sequence() routine:

function animations() {
  clearTimeout(timer);
  cube.sequence([ /* ... */ ], function() {
    timer = setInterval(function() { animations(cube); }, 500)
  }, 100);
}

and

cube.prototype.sequence = function(seq, onfinish, delay) {
  var timer = setInterval(function() {
    // ... some clever sequencing here
    clearTimeout(timer);
    onfinish();
  }, delay);
}

Btw., I haven’t found an LED cube using a PICAXE microcontroller and would be grateful for any hints.

  • 3x3x3 LED Cube
  • Javascript
  • Add new comment

Praxiswissen Drupal 6. oreillys basics

Mein Buch ist erschienen:

Image of Praxiswissen Drupal 6. oreillys basics

Hier ist die Zusammenfassung.

Hm, lecker!

Selber Punkte verschicken oder sammeln unter browniepunkt.de.

Mitglied der Drupal Association

Kreativ mit Elektronik

Basteln mit Elektronik, Arduino, PICAXE, kombiniert mit Malerei, Textilien, Holz oder Metall können Eltern und Kinder regelmäßig bei meinen Workshops. Nächster Termin: 3./4.4.2012 im Deutschen Museum in Bonn . Ein kleines Side Project war der Benzoltisch im Deutschen Museum im Bonn.

Wir sind alle Atheisten

... in Bezug auf die meisten Götter, an die die Menschheit jemals geglaubt hat. Manche von uns gehen einfach noch einen Gott weiter – Richard Dawkins.

Das Syndicat

Unter syndikate.it blogge ich über Cloud-Technologien. Dort gibt es auch Links zu meinen anderen Websites .

Navigation

  • Recent posts

User login

What is OpenID?
  • Log in using OpenID
  • Cancel OpenID login
  • Create new account
  • Request new password

Kommentiert

  • Wenn dieses Framework nichts
    11 weeks 6 days ago
  • Kindle version of book
    13 weeks 3 days ago
  • Susanna
    13 weeks 4 days ago
  • Tami
    17 weeks 2 days ago
  • Anti-Glare?
    49 weeks 5 days ago
  • Ein erstes Release des CakePHP-Frontends für TYPO3
    1 year 20 weeks ago
  • Geniuos!
    1 year 28 weeks ago
  • Mobile
    1 year 39 weeks ago
  • Dat Buch
    1 year 46 weeks ago
  • Känguru weiß es
    2 years 6 days ago

Freunde

Powered by Drupal, an open source content management system
  • content
  • technology
  • life
  • bonn