Hello. my project is working now. but I want to scroll the text.
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:
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:
but I can't implement what he is trying to say. I've been trying my best for a long hours now.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.