Go Down

Topic: Update HT1632 Text String on Button Press (Read 767 times) previous topic - next topic



I've got some text scrolling across my display but on a button press I want a couple of things to happen. I want to to change the text to something else then after about 2 seconds change back to the original string.

In theory this is quite easy using the delay() function but due to this LED display updating in the loop it just causes the display to freeze for 2 seconds when the button is pressed and then switching back to the original string.

Anybody have any ideas? Please let me know if i'm not being clear enough.

Code: [Select]
#include <font_5x4.h>
#include <HT1632.h>
#include <images.h>

int i = 0;
int wd;
char* thetext = {"Press the button"};
const int buttonPin = 2;     // the number of the pushbutton pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup () {
  // Setup and begin the matrix
  // HT1632.begin(CS1,WR,DATA)
  HT1632.begin( 9, 10, 11);

  // Give the width, in columns, of the assigned string
  // FONT_5x4_WIDTH and FONT_5x4_HEIGHT are parameter specified in the "font_5x4.h" file
  wd = HT1632.getTextWidth("Press the button", FONT_5X4_WIDTH, FONT_5X4_HEIGHT);

    // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);


void loop () {
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {   
thetext = "Pressed";
thetext = "Press the button";


  HT1632.drawText(thetext, 2*OUT_SIZE - i, 2, FONT_5X4, FONT_5X4_WIDTH, FONT_5X4_HEIGHT, FONT_5X4_STEP_GLYPH);
  i = (i+1)%(wd + OUT_SIZE * 2); 


Go Up