Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
example of using 7-Segment Serial Display
// example of using 7-Segment Serial Display
// product available from https://www.sparkfun.com/products/9765
// based on code from http://www.arunet.co.uk/tkboyd/ec/ec1led4x7ser.htm
// Note: solder wires at Gnd/Vcc & Rx, Rx goes to a digital pin on the arduino.
// Video available at http://www.youtube.com/watch?v=YVMAzYqV4kg
// Blogged @ http://chrisnolan.ca/2012/08/05/i-can-solder-7-segment-serial-display-nunchucky-operational/
#include <SoftwareSerial.h> // Arduino 1.0 included
#define SerInToArdu 2
#define SerOutFrmArdu 3 // pin it's plugged into
#define wDelay 300//no ; here. Sets how long each "message" appears
SoftwareSerial mySerialPort(SerInToArdu,SerOutFrmArdu);
// The above creates the serial channel we will use.
void setup(){
pinMode(SerOutFrmArdu,OUTPUT);
pinMode(SerInToArdu,INPUT);//Not actually needed...
mySerialPort.begin(9600);
mySerialPort.print("v"); //To reset display module
};
void loop(){
default_example();
scroll_word("4321");
scroll_word("87654321");
scroll_word("HELLo noLAn");
scroll_word("123456789");
mySerialPort.print("xxxx");//Send an "x" to turn a digit off
delay(wDelay);
delay(wDelay);
};
void default_example() {
mySerialPort.print("1234");
delay(wDelay);
mySerialPort.print("234x");
delay(wDelay);
mySerialPort.print("34xx");
delay(wDelay);
mySerialPort.print("4xxx");
delay(wDelay);
mySerialPort.print("xxxx");
delay(wDelay);
mySerialPort.print("----");
delay(wDelay);
mySerialPort.print("8888");
delay(wDelay);
mySerialPort.print("HEL0");
delay(wDelay);
mySerialPort.print("NoLA");
delay(wDelay);
mySerialPort.print("oLAn");
delay(wDelay);
mySerialPort.print("LAnx");
delay(wDelay);
mySerialPort.print("Anxx");
delay(wDelay);
mySerialPort.print("nxxx");
delay(wDelay);
};
void scroll_word(String w) {
int length = w.length();
if (length <= 4) {
mySerialPort.print(w);
delay(wDelay);
} else {
w = " " + w + " ";
for (int i=0; i<= length+4; i++) {
mySerialPort.print(w.substring(i,i+4));
delay(wDelay);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.