6 Bits (your color) LED Module Display indicator Board for Marquees Water lights Breadboard PCB


Of course, you can DoItYourself but those modules come so nice I could not resist, and they come at 76 cents only.
Actually, they are meant for debugging or status display but they turn out to be useful for educational purpose, too.
So you have an easy-to-use tool to teach the system of binary numbers by counting (increment by one) or shifting (multiply by two).

You will need two of these modules to get an awesome impression.

Well, for some 16 Euros you get the Blinkenlight with 20 LEDs, but does it pay off?

Due to the design of the form factor of the Arduino, there is a gap between bit-5 and bit-6.
Mind you: as the code given below makes use of the PORT mapping of the UNO it won't run on other Arduinos.

On each reset/restart it will either count or shift. To provide this option one bit in the EEPROM is used. As every byte in the EEPROM can "only" be reprogrammed 100,000 times there is a clear limit for restarting this program: if you restart the chip ten times a day this EEPROM byte will be worn out after 27 years.

In a way, you can say: in this Arduino two programs are stored at the same time; the selection is done by reset.

/*
 * Rapid Prototyping LEDs 
 * Breadboard starter kit 
 * for Arduino UNO connected
 * to Pins 1-6 and 8-13
 */

#include <EEPROM.h> 
 
// alternating COUNT / SHIFT
boolean inc; 
word bitMask = 1;

void setup() {
  inc = !EEPROM.read(0);
  EEPROM.write(0,inc);
  Serial.begin(9600);
  Serial.println(__FILE__);
  Serial.println(inc);
  Serial.end(); 
  /* Serial.end, 
   * otherwise bit-1  
   * can not be used 
   * as output
   */
  // set all pins to OUTPUT
  DDRB = B00111111;  
  DDRD = B11111110;  
}

void loop() {
  // COUNT or SHIFT
  if (inc) bitMask++; 
    else bitMask *= 2;
  // restart
  if (bitMask > 0x0FFF) 
    bitMask = 1; 
  // only the 6 higher bits
  PORTB = bitMask >> 6; 
  // only the 6 lower bits,  
  // D7 = ground
  PORTD = bitMask << 1 & 127;
  delay(25);
}

As you can see I was lazy: counting should start with "zero", but both counting and shifting start with "one".


contact: nji(at)gmx.de