How to use sensor reading for arduino POV scrolling text

Thread Starter

glenn_boy13

Joined Dec 19, 2012
29
Hello. my project is working now. but I want to scroll the text.

Rich (BB code):
// defining the alphabet
 #include "font.h"
 
 // define the Arduino LED pins in use
 const int LEDpins[] = {
   8,7,6,5,4,3,2};
 
 // number of LEDs
  const int charHeight = sizeof(LEDpins);
  const int charWidth = 5;
 
 
 
 // sensor setup
 const int sensorPIN = 12;  // define the Arduino sensor pin

//  boolean sensorFlag = false;  // stores sensor state
  int sensVal;  // variable to store the value coming from the sensor
 
 
 inr randomNum;
 void setup()
 {
   pinMode(13, OUTPUT);

    pinMode(2, OUTPUT);
     pinMode(3, OUTPUT);
    pinMode(4, OUTPUT);
    pinMode(5, OUTPUT);
    pinMode(6, OUTPUT);
     pinMode(7 , OUTPUT);
   pinMode(8, OUTPUT);

   
  //   Serial.begin(9600);
 }
 
 void reverse_string(char str[])
{
    char c;
    char *p, *q;

    p = str;
    if (!p)
        return;

    q = p + 1;
    if (*q == '\0')
        return;

    c = *p;
    reverse_string(q);

    while (*q != '\0') {
        *p = *q;
        p++;
        q++;
    }
    *p = c;

    return;
}
 
 void loop()
 {
   
   //try random
   // turn on Led for a circle in middle and proof that arduino is powered
    digitalWrite(13, HIGH);   // set the LED on  
    char textString[] = "DIANA:)";
//     reverse_string(textString);
   sensVal = digitalRead(sensorPIN);  // read the Hall Effect Sensor  
 
    analogWrite(9, 0);
    
 
 //    Serial.println(sensVal);
// delay(500 );  
// had difficulty here
// since it is a switch hall switch probably shoiuld just do digital read

 if (sensVal == LOW) {
   
   // printing every letter of the textString
   for (int k=0; k<sizeof(textString); k++){
     printLetter(textString[k]);
   }

 }
 }
 
 
 
 
 void printLetter(char ch)
 {
   // make sure the character is within the alphabet bounds (defined by the font.h file)
   // if it's not, make it a blank character
   
    
   
    if (ch < 32 || ch > 126){
     ch = 32;
   }
   // subtract the space character (converts the ASCII number to the font index number)
   ch -= 32;
   // step through each byte of the character array
  for (int i=0; i<charWidth; i++) {
     byte b = font[ch];
     
 
 
     // bit shift through the byte and output it to the pin
     for (int j=charHeight; j>=0; j--) {
       digitalWrite(LEDpins[j], !!(b & (1 << j)));
     
     }
     // space between columns
 
 delayMicroseconds(900);
   }
   //clear the LEDs

digitalWrite(2 , LOW);   // set the LED on
digitalWrite(3 , LOW);   // set the LED on
digitalWrite(4 ,LOW);   // set the LED on
digitalWrite(5 , LOW);   // set the LED on
digitalWrite(6 , LOW);   // set the LED on
    digitalWrite(7 , LOW);   // set the LED on
digitalWrite(8 , LOW);   // set the LED on
   // space between letters
   delayMicroseconds(2500);
 
 }


Here are my findings and the steps that I've already taken, but no help.

I learned that charWidth is best to have a value of 5. that is constant smiley-grin As it was declared originally by the author of such codes in instructables. Yes, this project is modified by me. My project is a globe and the instructable is a fan.

Findings:
1. if the text is: "DIANA ROSE smiley" --- 13 characters or less than that( including white spaces), the result is super fine. super stable.
2. if the text is longer than 13 characters, the display is still readable but not scrolling. ughhhhhhhhh
say, my text is: "DIANA ROSE CUSTODIO smiley". first it will display the "DIANA ROSE CUST" then the rest. 2 displays each second.
3. I also tried to remove the if(sensVal==LOW) and set the text to "DIANA ROSE CUSTODIO", it scrolls a bit but sometimes the 1st and 2nd and last name displays randomly.
4. I also tried to edit the reading to: "IF(SENSVAL==HIGH)", it was no help too.

someone from arduino forum said this:

If someone know how to scroll (marquee) the display, I would be glad to accept and do your instructions.
Code:
// printing every letter of the textString
for (int k=0; k<sizeof(textString); k++){
printLetter(textString[k]);
}
This for loop sends each letter to the display in turn starting at the beginning each time. If the start position was moved along the string after a suitable delay then the text would appear to scroll. You would need to deal with the wrap around, of course.
but I can't implement what he is trying to say. :( I've been trying my best for a long hours now.
 

spinnaker

Joined Oct 29, 2009
7,830
Marquee type display are very simple. It is actually a beginners programming exercise.

Here are the basics.

1. You have a buffer containing some text. Longer than the display allows.

2. A start variable that point to the start of the display buffer. Initialize this to zero.

3. A length constant variable for the physical display.

4. A variable that keeps track of the current position.

5. Display your characters up to the length of the display. Increment current position for each character display.

6. Increment the starting position.

The hard part is to keep track of the current position. If it exceeds the length of the buffer, you will need to reset it to zero.

If I have some time I will work up a demo but it will have to be for the pic. But if you searched, I am sure you will find plenty of examples.
 

Thread Starter

glenn_boy13

Joined Dec 19, 2012
29
Marquee type display are very simple. It is actually a beginners programming exercise.

Here are the basics.

1. You have a buffer containing some text. Longer than the display allows.

2. A start variable that point to the start of the display buffer. Initialize this to zero.

3. A length constant variable for the physical display.

4. A variable that keeps track of the current position.

5. Display your characters up to the length of the display. Increment current position for each character display.

6. Increment the starting position.

The hard part is to keep track of the current position. If it exceeds the length of the buffer, you will need to reset it to zero.

If I have some time I will work up a demo but it will have to be for the pic. But if you searched, I am sure you will find plenty of examples.
thumbs up for you sir. thanks, but I can't implement that all :(
Perhaps I can understand it much better if there is an easy example even if it is in PIC. I've seen many POVs in arduino that keeps track of the current position, they have even computations, but I can't understand them all.

sir shteii01 - it is a Persistence of Vision display . Not Led Matrices and not LCD.
 

spinnaker

Joined Oct 29, 2009
7,830
thumbs up for you sir. thanks, but I can't implement that all :(
Perhaps I can understand it much better if there is an easy example even if it is in PIC. I've seen many POVs in arduino that keeps track of the current position, they have even computations, but I can't understand them all.

sir shteii01 - it is a Persistence of Vision display . Not Led Matrices and not LCD.
Oh POV. The technique will be very similar to LCD. You have X spaces on LCD and you have X spaces in a POV.
 

Thread Starter

glenn_boy13

Joined Dec 19, 2012
29
Google search one minute:

https://www.inkling.com/read/arduino-cookbook-michael-margolis-2nd/chapter-11/recipe-11-4

It really is not hard to understand. Just picture in your mind what you want to do with the buffer and display.



I am sure there are many, many more out there. This is a common feature for LCD.

hello sir! I am back, I've already studied the link you have given, but that uses an LCD library.

I have here a complete code of GLOBE POV in arduino (a persistence of vision that displays globe map and rotating). It uses an interrupt for a reed switch. I know reed switch is the same with the hall effect, the same function I mean.

I can't understand all of the GLOBE POV codes, I think I can, but that would take a long time. XD.

my question is: do I need to use an interrupt to? In order for my text to scroll?
 

spinnaker

Joined Oct 29, 2009
7,830
hello sir! I am back, I've already studied the link you have given, but that uses an LCD library.

I have here a complete code of GLOBE POV in arduino (a persistence of vision that displays globe map and rotating). It uses an interrupt for a reed switch. I know reed switch is the same with the hall effect, the same function I mean.

I can't understand all of the GLOBE POV codes, I think I can, but that would take a long time. XD.

my question is: do I need to use an interrupt to? In order for my text to scroll?
If you can't understand the code then the project is most likely beyond you capability. Start with a less complex project like LCD.
 
Top