Thursday, December 11, 2014

Pretty close to the final code for the LED display!

This is an adaptation of the code that was posted on the blog earlier, that has been made to work for our setup. it should work for us, but it hasn't been tested yet and will need some minor tweaks.

/*
Team Frequency
Design Lab 1 Final
POV Display final Code
12/12/2014

This code is designed to illuminate the LEDs on an arduino breadboard mounted on a rotating disc spinning at a known RPM. Ideally, the
only variable that needs to be modified is the value of period, which represents the period of rotation of the disc. The delay values may
also need to be modified slightly, or alternatively, the n value and corrosponding length of the lines of text in the message array may be
increased to provide a longer delay if the message is repeating itself or illegibly compact. Requires a separate arduino running the motor
attachment.

*/

//-----------------------Variable Declaration----------------------------------------------------
long period = 400;
int ledPins[] = {12, 11, 10, 9, 8, 7};
int n = 128;
char *message[6] = {
"11111111110001111111111000011111111100011111111110000000000000000000000000000000000000000000000000000000000000000000000000000000",
"00001100000001100000000000111000000000000001100000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"00001100000001111111000000011111111000000001100000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"00001100000001100000000000000000011100000001100000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"00001100000001111111111000111111111000000001100000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
};


/*
//This is an attempt to create the team name on the display. Will be completed if the display proves functional.

char *messageB[6] = {
"1111111111000111111111100000011110000001110000001110000000000000000111111111100011111110000001111111111000011111111000011000000001100011111111110001110000011000000111111100011100001110000000000",
"000011000000011000000000000011001100000111110011111000000000000000011000000000001100001100
"000011000000011111110000000110000110000110011110011000000000000000011111110000001100011000
"000011000000011000000000001111111111000110001100011000000000000000011000000000001111110000
"000011000000011111111110001100000011000110000000011000000000000000011000000000001100011000
*/

//--------------------------------Setup Function---------------------------------------
void setup()
{
 for (int led = 0; led < 6; led ++)
 {
   pinMode(ledPins[led], OUTPUT);
 }
}

//--------------------------------Main Loop--------------------------------------------

void loop()
{
  for (int col = 0; col < n; col++)                // This code divides the char array message into columns using nested for-loops.
  {
    for (int row = 0; row < 6; row++)              // The LEDs in each column light for 1/1000th of the period, shown by the delayMicrosecond(period) function, before turning off.
    {
      if(message[5-row][col] != 0){
        setLed(row);
      }
    }
    delayMicroseconds(period);                     // The delay values may need to be adjusted if the timing of the system is too far off. Microseconds may be too short to effectively work.
    allOff();
    delayMicroseconds(period / 16);
  }
}

//-----------------------------Additional Functions-----------------------------------

void setLed(int led)
{
 digitalWrite(ledPins[led], HIGH);                  // Turns on the LED chosen by the main loop.

}

void allOff()
{
   for (int led = 0; led < 6; led ++)                // Resets all LEDs to the LOW position after the delay.
 {
    digitalWrite(ledPins[led], LOW);
 }
}

Circuit Setup for Motor

Circuit Diagram



Key for the Circuit Pictures

This pictures from the SIK guide that came with the spark fun inventors kit, helped setup the circuit necessary for the motor to operate.

Priyank



Video! @60fps


This shows how the bottom section rotates, as you can also see it rotates on an angle which is a small problem and can be fixed by making the next part considering the fact that extra space needed for the motor. 

Priyank


Bottom Setup Complete



Priyank

Power Equipment



As I figured that I needed some bigger holes in the bottom of the cylinder, I had to take some help from the Powerful Craftsman 12V drill.

Priyank

Code #2 for DC Motor


int motorPin = 9;
void setup() {
 pinMode(motorPin, OUTPUT);
}
void loop() {
 digitalWrite(motorPin, HIGH);
 delay(1000);
 digitalWrite(motorPin, LOW);
 delay(1000);

} 

This code will run and stop the motor after 1 second.


Thanks to http://www.dummies.com/how-to/content/how-to-spin-a-dc-motor-with-the-arduino.html

Priyank

Setup and Code for the DC Motor

 http://www.dummies.com/how-to/content/how-to-spin-a-dc-motor-with-the-arduino.html

This link is going to be how the motor circuit is going to be setup, and the given code is going to be used to get it up and running.

Thanks to http://www.dummies.com/

Priyank