/* Project: 3x3x3 Mono LED Cube (r3).
 * File: _3x3x3_Mono.ino
 * Description: 3x3x3 mono LED cube using Arduino UNO.
 *
 * Copyright (C) 2014 Marc Symonds
 * All rights reserved.
 *
 * This software may be used and redistributed, with or without
 * modification, as long as it is understood that this software
 * is provided as-is without any explicit or implied warranties
 * of merchantablity or fitness of purpose.
 */

#include "DirectIO.h"
#include "Counter_4017.h"
#include "ShiftReg_7495.h"

#include "DisplayFrame.h"
#include "Movies.h"

const int DISPLAYCLOCKPIN = 2; // Must be pin 2, for interrupt 0.
const int CLOCKGENPIN = 3; // Pin that will generate the interrupt pulse. Could use external pulse generator instead.

void setup()
{  
  pinMode(DISPLAYCLOCKPIN, INPUT);
  pinMode(CLOCKGENPIN, OUTPUT);
  
  // Set PWM on pin 3 to about 3.9KHz and start it.
  TCCR2B = (TCCR2B & B11111000) | B010; 
  analogWrite(CLOCKGENPIN, 127);

  // Seed the random number generator.  
  randomSeed(analogRead(0));

  // Initialise the displayFrame functions.
  df_init();
}

void loop() 
{
  static byte a = 255;
  byte b;
  
  do
  {
    b = random(0, 14);
  } while (b == a);
  a = b;

  switch(b)
  {
    case 0:
      mv_Boxy();
      break;
      
    case 1:    
      mv_EdgeChase2();
      break;
      
    case 2:    
      mv_Snake();
      break;
      
    case 3:    
      mv_Counter();
      break;
      
    case 4:    
      mv_EdgeTumble();
      break;
      
    case 5:    
      mv_Flashy();
      break;
      
    case 6:    
      mv_AllOn();
      break;
      
    case 7:    
      mv_Rain();
      break;
      
    case 8:    
      mv_EdgeChase();
      break;
      
    case 9:    
      mv_Jitter();
      break;
      
    case 10:    
      mv_Pulse();
      break;
      
    case 11:    
      mv_TwinkleAll();
      break;
      
    case 12:
      mv_Lightning();
      break;
      
    default:    
      mv_Glitter();
      break;
  }
}

Leave a Reply

Your email address will not be published. Required fields are marked *

Comments Protected by WP-SpamShield Spam Blocker