Pages: [1]   Go Down
Author Topic: POV  (Read 528 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 72
Arduino rocks
View Profile
POV
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I am new to both Arduino and programing.  I recently  have been trying to modify some code i found online to make a POV. I planed on modifying it so one may easily change several different slogans and move between them at the push of a button, the code for which I will add later.

My problem is i ran out of RAM before i finished the alphabet  and i still wanted to add some shapes after that.  A different forum suggested I use Use an array of bytes, with each bit being a pixel.  

I tried to follow the tutorial  on the Arduino playground but have not been able to get even one row to light.

Here is the original code if any one has any suggestions.

Code:
// defining the alphabet
int _[] = {0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0,0};
int A[] = {0,1,1,1,1,1,1, 1,0,0,1,0,0,0, 1,0,0,1,0,0,0, 1,0,0,1,0,0,0, 0,1,1,1,1,1,1};
int B[] = {1,1,1,1,1,1,1, 1,0,0,1,0,0,1, 1,0,0,1,0,0,1, 1,0,0,1,0,0,1, 0,1,1,0,1,1,0};
int C[] = {0,1,1,1,1,1,0, 1,0,0,0,0,0,1, 1,0,0,0,0,0,1, 1,0,0,0,0,0,1, 0,1,0,0,0,1,0};
int D[] = {1,1,1,1,1,1,1, 1,0,0,0,0,0,1, 1,0,0,0,0,0,1, 0,1,0,0,0,1,0, 0,0,1,1,1,0,0};
int E[] = {1,1,1,1,1,1,1, 1,0,0,1,0,0,1, 1,0,0,1,0,0,1, 1,0,0,1,0,0,1, 1,0,0,0,0,0,1};
int F[] = {1,1,1,1,1,1,1, 1,0,0,1,0,0,0, 1,0,0,1,0,0,0, 1,0,0,1,0,0,0, 1,0,0,0,0,0,0};
int G[] = {0,1,1,1,1,1,0, 1,0,0,0,0,0,1, 1,0,0,0,0,0,1, 1,0,0,0,1,0,1, 0,1,0,0,1,1,0};
int H[] = {1,1,1,1,1,1,1, 0,0,0,1,0,0,0, 0,0,0,1,0,0,0, 0,0,0,1,0,0,0, 1,1,1,1,1,1,1};
int I[] = {1,0,0,0,0,0,1, 1,0,0,0,0,0,1, 1,1,1,1,1,1,1, 1,0,0,0,0,0,1, 1,0,0,0,0,0,1};
int J[] = {0,0,0,0,1,1,0, 0,0,0,0,0,0,1, 0,0,0,0,0,0,1, 0,0,0,0,0,0,1, 1,1,1,1,1,1,0};
int K[] = {1,1,1,1,1,1,1, 0,0,0,1,0,0,0, 0,0,1,0,1,0,0, 0,1,0,0,0,1,0, 1,0,0,0,0,0,1};
int L[] = {1,1,1,1,1,1,1, 0,0,0,0,0,0,1, 0,0,0,0,0,0,1, 0,0,0,0,0,0,1, 0,0,0,0,0,0,1};
int M[] = {1,1,1,1,1,1,1, 0,1,0,0,0,0,0, 0,0,1,0,0,0,0, 0,1,0,0,0,0,0, 1,1,1,1,1,1,1};
int N[] = {1,1,1,1,1,1,1, 0,0,1,0,0,0,0, 0,0,0,1,0,0,0, 0,0,0,0,1,0,0, 1,1,1,1,1,1,1};
int O[] = {0,1,1,1,1,1,0, 1,0,0,0,0,0,1, 1,0,0,0,0,0,1, 1,0,0,0,0,0,0, 0,1,1,1,1,1,0};
int P[] = {};
int Q[] = {};
int R[] = {};
int S[] = {};
int T[] = {};
int U[] = {};
int V[] = {};
int W[] = {};
int X[] = {};
int Y[] = {};
int Z[] = {};

int letterSpace;
int dotTime;

void setup()
{
  // setting the ports of the leds to OUTPUT
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  
  // defining the space between the letters (ms)
  letterSpace = 6;
  // defining the time dots appear (ms)
  dotTime = 3;
  
}

void printLetter(int letter[])
{
  int y;
  
  // printing the first y row of the letter
  for (y=0; y<7; y++)
  {
    digitalWrite(y+2, letter[y]);
  }
  delay(dotTime);
  
  // printing the second y row of the letter
  for (y=0; y<7; y++)
  {
    digitalWrite(y+2, letter[y+7]);
  }
  delay(dotTime);
  
  // printing the third y row of the letter
  for (y=0; y<7; y++)
  {
    digitalWrite(y+2, letter[y+14]);
  }
  delay(dotTime);
  
  // printing the fourth y row of the letter
  for (y=0; y<7; y++)
  {
    digitalWrite(y+2, letter[y+21]);
  }
  delay(dotTime);
  
  // printing the fifth y row of the letter
   for (y=0; y<7; y++)
  {
    digitalWrite(y+2, letter[y+28]);
  }
  delay(dotTime);
  
  // printing the space between the letters
  for (y=0; y<7; y++)
  {
    digitalWrite(y+2, 0);
  }
  delay(letterSpace);
}

void loop()
{
  // printing some letters
  printLetter(A);
  printLetter(_);
  
}

[/list]

Thanks

Logged

FR
Offline Offline
Full Member
***
Karma: 0
Posts: 105
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes try with the array of bytes.
Here is an old code ( I 'm not sure if it 'll work with 7 lines instead of 5).

/*

????????????????????????????????????????????

persistence of vision typography with arduino

michael zoellner - march 2006

http://i.document.m05.de



connect anodes (+) of 5 leds to digital ports of the arduino board

and put 20-50 ohm resistors from the cathode (-) to ground.



the letters are lookup tables consisting arrays width the dot status in y rows.

????????????????????????????????????????????

*/





// defining the alphabet

byte _[] = {0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0};

byte A[] = {0,1,1,1,1, 1,0,1,0,0, 0,1,1,1,1};

byte B[] = {1,1,1,1,1, 1,0,1,0,1, 0,1,0,1,0};

byte C[] = {0,1,1,1,0, 1,0,0,0,1, 1,0,0,0,1};

byte D[] = {1,1,1,1,1, 1,0,0,0,1, 0,1,1,1,0};

byte E[] = {1,1,1,1,1, 1,0,1,0,1, 1,0,1,0,1};

byte F[] = {1,1,1,1,1, 1,0,1,0,0, 1,0,1,0,0};

byte G[] = {0,1,1,1,0, 1,0,1,0,1, 0,0,1,1,0};

byte H[] = {1,1,1,1,1, 0,0,1,0,0, 1,1,1,1,1};

byte I[] = {0,0,0,0,1, 1,0,1,1,1, 0,0,0,0,1};

byte J[] = {1,0,0,0,0, 1,0,0,0,1, 1,1,1,1,1};

byte K[] = {1,1,1,1,1, 0,0,1,0,0, 0,1,0,1,1};

byte L[] = {1,1,1,1,1, 0,0,0,0,1, 0,0,0,0,1};

byte M[] = {1,1,1,1,1, 0,1,1,0,0, 0,1,1,1,1};

byte N[] = {1,1,1,1,1, 1,0,0,0,0, 0,1,1,1,1};

byte O[] = {0,1,1,1,0, 1,0,0,0,1, 0,1,1,1,0};

byte P[] = {1,1,1,1,1, 1,0,1,0,0, 0,1,0,0,0};

byte Q[] = {0,1,1,1,1, 1,0,0,1,1, 0,1,1,1,1};

byte R[] = {1,1,1,1,1, 1,0,1,0,0, 0,1,0,1,1};

byte S[] = {0,1,0,0,1, 1,0,1,0,1, 1,0,0,1,0};

byte T[] = {1,0,0,0,0, 1,1,1,1,1, 1,0,0,0,0};

byte U[] = {1,1,1,1,1, 0,0,0,0,1, 1,1,1,1,1};

byte V[] = {1,1,1,1,0, 0,0,0,0,1, 1,1,1,1,0};

byte W[] = {1,1,1,1,0, 0,0,1,1,0, 1,1,1,1,0};

byte X[] = {1,1,0,1,1, 0,0,1,0,0, 1,1,0,1,1};

byte Y[] = {1,1,0,0,0, 0,0,1,0,0, 1,1,1,1,1};

byte Z[] = {1,0,0,1,1, 1,0,1,0,1, 1,1,0,0,1};



int letterSpace;

int dotTime;



void setup()

{

  // setting the ports of the leds to OUTPUT

  pinMode(2, OUTPUT);

  pinMode(3, OUTPUT);

  pinMode(4, OUTPUT);

  pinMode(5, OUTPUT);

  pinMode(6, OUTPUT);

  

  // defining the space between the letters (ms)

  letterSpace = 6;

  // defining the time dots appear (ms)

  dotTime = 3;

  

}



void printLetter(byte letter[])

{

  int y;

  

  // printing the first y row of the letter

  for (y=0; y<5; y++)

  {

    digitalWrite(y+2, letter[y]);

  }

  delay(dotTime);

  

  // printing the second y row of the letter

  for (y=0; y<5; y++)

  {

    digitalWrite(y+2, letter[y+5]);

  }

  delay(dotTime);

  

  // printing the third y row of the letter

  for (y=0; y<5; y++)

  {

    digitalWrite(y+2, letter[y+10]);

  }

  delay(dotTime);

  

  // printing the sspace between the letters

  for (y=0; y<5; y++)

  {

    digitalWrite(y+2, 0);

  }

  delay(letterSpace);

}



void loop()

{

  // printing some letters

  printLetter(T);

  printLetter(O);

  printLetter(U);

  printLetter(T);

  printLetter(_);

  printLetter(_);  

}


Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 72
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I changed the word int to byte at every point in my sketch and completed the alphabet.  It worked great!  

Thank you so much.


Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 72
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK, after a while away from the Arduino POV I.m back with a new problem.  I added a counting press button to the POV to add the ability to cycle between several different slogans.  The counting button works as i have tried it on a simple sketch, as seen in the Ladyada Arduino tutorial part 5.  The POV works due to the help of nrolland, thanks again.  However when i add the two together and upload the sketch only  the LEDs to pins 6, 7, & 8 dimly light and stay light.  Pushing the button only changes the luminosity slightly.

Any suggestions?

Listed below is the sketch.

Code:
byte A[] = {0,1,1,1,1,1,1, 1,0,0,1,0,0,0, 1,0,0,1,0,0,0, 1,0,0,1,0,0,0, 0,1,1,1,1,1,1};

//B through Y not shown due to limit of 5500 character per post in forum

byte Z[] = {1,0,0,0,0,1,1, 1,0,0,0,1,0,1, 1,0,0,1,0,0,1, 1,0,1,0,0,0,1, 1,1,0,0,0,0,1};
int letterSpace;
int dotTime;

int switchPin = 12;             // switch is connected to pin 12
int val;                        // variable for reading the pin status
int val2;                       // variable for reading the delayed status
int buttonState;                // variable to hold the button state
int Mode = 0;                   // What mode is the ____ in?

void setup()
{
  // setting the ports of the leds to OUTPUT
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  
  pinMode(switchPin, INPUT);    // Set the switch pin as input
  
  letterSpace = 6;  // defining the space between the letters (ms)
  dotTime = 3;  // defining the time dots appear (ms)
  
  Serial.begin(9600);           // Set up serial communication at 9600bps
  buttonState = digitalRead(switchPin);   // read the initial state
}

void printLetter(byte letter[])
{
  int y;
  
  // printing the first y row of the letter
  for (y=0; y<7; y++)
  {
    digitalWrite(y+2, letter[y]);
  }
  delay(dotTime);
  
  // printing the second y row of the letter
  for (y=0; y<7; y++)
  {
    digitalWrite(y+2, letter[y+7]);
  }
  delay(dotTime);
  
  // printing the third y row of the letter
  for (y=0; y<7; y++)
  {
    digitalWrite(y+2, letter[y+14]);
  }
  delay(dotTime);
  
  // printing the fourth y row of the letter
  for (y=0; y<7; y++)
  {
    digitalWrite(y+2, letter[y+21]);
  }
  delay(dotTime);
  
  // printing the fifth y row of the letter
   for (y=0; y<7; y++)
  {
    digitalWrite(y+2, letter[y+28]);
  }
  delay(dotTime);
  
  // printing the space between the letters
  for (y=0; y<7; y++)
  {
    digitalWrite(y+2, 0);
  }
  delay(letterSpace);
}

void loop(){
  val = digitalRead(switchPin);      // read input value and store it in val
  delay(10);                         // 10 milliseconds debounce
  val2 = digitalRead(switchPin);     // read the input again to check for bounces
  if (val == val2) {                 // make sure we got 2 consistant readings!
    if (val != buttonState) {          // the button state has changed!
      if (val == LOW) {                // check if the button is pressed
        if (Mode == 0) {          //
          Mode = 1;               //
        } else {
          if (Mode == 1) {        //
            Mode = 2;             //
          } else {
            if (Mode == 2) {      //
              Mode = 3;           //
            } else {
              if (Mode == 3) { // above 3 it returnes to 0
                Mode = 0;           //
              }
          }
          }
        }
      }
    }
    buttonState = val;                 // save the new state in our variable
  }

  // Now do whatever the Mode indicates
  if (Mode == 0) {
  printLetter(s); // printing some letters
  printLetter(_);
  }

  if (Mode == 1) {
  printLetter(A); // printing some letters
  printLetter(_);
  }

  if (Mode == 2) {
  printLetter(B); // printing some letters
  printLetter(_);
  }
  if (Mode == 3)  {
  printLetter(C); // printing some letters
  printLetter(_);
  }    
}
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 72
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Any suggestions on what could be the problem?  Any help would be appreciated.
Logged

Pages: [1]   Go Up
Jump to: