XE TECH - Arduino Singapore


LED Dot Matrix Screen Control

This example shows you how to control a LED Dot Matrix Screen.

Control Functions

Press button 1 to play video clip 1 on dot matrix screen
Press button 2 to play video clip 2 on dot matrix screen
Press button 3 to play video clip 3 on dot matrix screen
Press button 4 to play video clip 4 on dot matrix screen

Hardware Required

  • Arduino Board
  • Breadboard
  • Terminal Block
  • LED Controller, such as T-4000C
  • 8 Channel relay
  • Buttons
  • DC 5V Power Supply Unit

Challenges

The four channel LED video player T- 4000C does not play individual clips. There is only one button for all clips. The button is called MODE. Press MODE, it will play NEXT video clip.  Default clip at power on is the first clip. The codes developed was to bridge differences between user requirements and LED video player equipment capabilities.

The buttons are at the same time, connected to PC via keyboard simulators, to trigger video clips on LCD screen, done by others. The connection details on the other system are un-known. Therefore, relay boards are used to isolate button signal inputs. One button is wired to two relay outputs, in order not to burn any device. 

Code

//video clip duration 49 34 33 34 sec
//buttons initialization
// This may not be the best way to do it, but it works :)

// a real-lift project developed by Rose Lu, Nov 2014, in Singapore

int OneDegButton = 2;
int TwoDegButton = 3;
int ThreeDegButton = 4;
int FourDegButton = 5;
int ControllerMode = 6;
int ControllerPower = 7;
boolean currentOneDegButton = LOW;
boolean lastOneDegButton = LOW;
boolean currentTwoDegButton = LOW;
boolean lastTwoDegButton = LOW;
boolean currentThreeDegButton = LOW;
boolean lastThreeDegButton = LOW;
boolean currentFourDegButton = LOW;
boolean lastFourDegButton = LOW;

//button de-bounce functions. Basic stuff that needs to be done when you have button inputs.

boolean debounceOneDegButton(boolean last)  
{
boolean current = digitalRead(OneDegButton);
if (last != current)
{
delay(5);
current = digitalRead(OneDegButton);
return current;
}
}
boolean debounceTwoDegButton(boolean last)
{
boolean current = digitalRead(TwoDegButton);
if (last != current)
{
delay(5);
current = digitalRead(TwoDegButton);
return current;
}
}
boolean debounceThreeDegButton(boolean last)
{
boolean current = digitalRead(ThreeDegButton);
if (last != current)
{
delay(5);
current = digitalRead(ThreeDegButton);
return current;
}
}
boolean debounceFourDegButton(boolean last)
{
boolean current = digitalRead(FourDegButton);
if (last != current)
{
delay(5);
current = digitalRead(FourDegButton);
return current;
}
}

void setup() {

pinMode (OneDegButton, INPUT); 
digitalWrite (OneDegButton, LOW);
pinMode (TwoDegButton, INPUT); 
digitalWrite (TwoDegButton, LOW);
pinMode (ThreeDegButton, INPUT); 
digitalWrite (ThreeDegButton, LOW);
pinMode (FourDegButton, INPUT); 
digitalWrite (FourDegButton, LOW);
pinMode (ControllerMode, OUTPUT); 
digitalWrite (ControllerMode, LOW);
pinMode (ControllerPower, OUTPUT); 
digitalWrite (ControllerPower, HIGH);

}

void loop() {
currentOneDegButton = debounceOneDegButton(lastOneDegButton);
currentTwoDegButton = debounceTwoDegButton(lastTwoDegButton);
currentThreeDegButton = debounceThreeDegButton(lastThreeDegButton);
currentFourDegButton = debounceFourDegButton(lastFourDegButton);

if (currentOneDegButton == HIGH && lastOneDegButton == LOW)  //button 1
{
lastOneDegButton = HIGH;
digitalWrite (ControllerPower, LOW);
delay(250);
digitalWrite (ControllerPower, HIGH);
delay(3000);   //adding this delay time is critical for T-4000C controller. Due to its start up initialization time.

digitalWrite (ControllerMode, HIGH);
delay(250);
digitalWrite (ControllerMode, LOW);
delay(45000);   //video play duration

digitalWrite (ControllerPower, LOW);
delay(250);
digitalWrite (ControllerPower, HIGH);
delay(3000);  //power off and on the T-4000C, so it will loop play the first vido clip, i.e. the home screen.


}
if (currentTwoDegButton == HIGH && lastTwoDegButton == LOW) //button 2
{
lastTwoDegButton = HIGH;
digitalWrite (ControllerPower, LOW);
delay(250);
digitalWrite (ControllerPower, HIGH);
delay(3000); // plays 1st clip - home screen

digitalWrite (ControllerMode, HIGH);
delay(250);  // plays 2nd clip - video 1
digitalWrite (ControllerMode, LOW);
delay(1500); 

digitalWrite (ControllerMode, HIGH);
delay(250); 
digitalWrite (ControllerMode, LOW);
delay(29000);  // skips 2nd clip, plays 3rd clip - video 2

digitalWrite (ControllerPower, LOW);
delay(250);
digitalWrite (ControllerPower, HIGH);
delay(3000); 


}
if (currentThreeDegButton == HIGH && lastThreeDegButton == LOW) //button 3
{
lastThreeDegButton = HIGH;
digitalWrite (ControllerPower, LOW);
delay(250);
digitalWrite (ControllerPower, HIGH);
delay(3000);

digitalWrite (ControllerMode, HIGH);
delay(250);
digitalWrite (ControllerMode, LOW);
delay(1500); 

digitalWrite (ControllerMode, HIGH);
delay(250);
digitalWrite (ControllerMode, LOW);
delay(1500); 


digitalWrite (ControllerMode, HIGH);
delay(250);
digitalWrite (ControllerMode, LOW);
delay(25000); 

digitalWrite (ControllerPower, LOW);
delay(250);
digitalWrite (ControllerPower, HIGH);
delay(3000); 

}

if (currentFourDegButton == HIGH && lastFourDegButton == LOW) //button 4
{
lastFourDegButton = HIGH;
digitalWrite (ControllerPower, LOW);
delay(250);
digitalWrite (ControllerPower, HIGH);
delay(3000);

digitalWrite (ControllerMode, HIGH);
delay(250);
digitalWrite (ControllerMode, LOW);
delay(1500); 

digitalWrite (ControllerMode, HIGH);
delay(250);
digitalWrite (ControllerMode, LOW);
delay(1500);

digitalWrite (ControllerMode, HIGH);
delay(250);
digitalWrite (ControllerMode, LOW);
delay(1500); 

digitalWrite (ControllerMode, HIGH);
delay(250);
digitalWrite (ControllerMode, LOW);
delay(24000); 

digitalWrite (ControllerPower, LOW);
delay(250);
digitalWrite (ControllerPower, HIGH);
delay(3000); 

}
else
{
digitalWrite (ControllerMode, LOW);
digitalWrite (ControllerPower, HIGH);
}
lastOneDegButton = currentOneDegButton;
lastTwoDegButton = currentTwoDegButton;
lastThreeDegButton = currentThreeDegButton;
lastFourDegButton = currentFourDegButton;

}

Make a Free Website with Yola.