NX7Seg

NX7Seg © GPL3+

Arduino ASCII Driver (library) for 3641 (four 7-segments) driven by 595 shift registers.

  • 1,060 views
  • 0 comments
  • 5 respects

Components and supplies

3641bs 7 segment controller driven by 595 shift register
×1
A000066 iso both
Arduino UNO & Genuino UNO
×1
Multifunction Expansion Shield
×1

About this project

Arduino ASCII Driver for 3641BS 4x7 segments

Do not forget to include the ASCII Dictionary.

This library helps you to write characters from an ASCII Dictionary on a 4x7 segments using shift registers (595). You write/update the "to write chars" via simplified methods.

  • nx7seg::write(char[] chars, int chars_array) Write chars
  • nx7seg::writeChar(char value, int where, bool point) Write chars
  • nx7seg::writeInt(int value, int expected_length) Write an int
  • nx7seg::writeFloat(float value, int expected_length) Write a float
  • nx7seg::writeDigit(int value, int where, bool point) Write a specific digit from the dictionary
  • nx7seg::clear() Clear the display

Once written, you can simply use nx7seg::send() to write data into the shift registers and nx7seg::refresh(int time) to continuously refresh the 7 segments during a time period.

Example

#include <ASCIIDic.h>
#include <NX7Seg.h>
#define LATCH_DIO 4
#define CLK_DIO 7
#define DATA_DIO 8
nx7seg my4x7seg = nx7seg(LATCH_DIO,CLK_DIO,DATA_DIO);
void setup ()
{
  /* Set DIO pins to outputs */
  pinMode(LATCH_DIO,OUTPUT);
  pinMode(CLK_DIO,OUTPUT);
  pinMode(DATA_DIO,OUTPUT);
}
/* Main program */
void loop()
{
  my4x7seg.writeInt(46);
  my4x7seg.refresh(1000);
  my4x7seg.write("abcd",4);
  my4x7seg.refresh(1000);
  my4x7seg.writeFloat(i);
  my4x7seg.refresh(1000);
}

Functions

nx7seg nx7seg(int latch, int clock, int data, bool reverse = false)

Constructor : If you don't have a latch (not a 595 shift register), give a pin and don't use it. If the 7 segment is reverse, then gives the argument reverse to true.

Latch could be named : RCLCK

Clock could be named : SCLK

void buffer(digit, data)

Write a byte in the digits buffer

void clear()

Clear the 7 segment buffer

void send()

Show the digit buffer on the 7 segment : Less than a millisecond. Use this if you are time dependant. Call it multiple times between time dependant steps to show the message.

byte cypher(char)

Convert a char into a byte coded for the 7 segments

void refresh(time = 500) // APPROXIMATIVE in ms

Show the digit buffer on the 7 segments during some time (in ms). It is approximative. It is a loop with delay(1), time times. Nothing can be done while showing numbers.

void write(char[], int sizeArray = 4)

Write a char[] into the buffer array, coded by cypher. Specify the size array.

void writeChar(char value, int digit, bool point = false);

Write a char into the buffer array, coded by cypher, at the digit wanted. If wanted, add a point.

void writeDigit(int value, int digit, bool point = false);

Write a number (0 to 10) into the buffer array, coded by cypher, at the digit wanted. If wanted, add a point.

void writeFloat(float value, int toWrite = 4)

Write the float value to 7 segment buffer. (refresh() or send() to show)

void writeInt(int value, int toWrite = 4)

Write the float value to 7 segment buffer. (refresh() or send() to show)

TODO

  • Change the direction of the chars. Right to left instead of left to right for some 3641BS soldered differently.

Credits

Alexis Paques (@AlexisTM)

Code

Github
https://github.com/AlexisTM/NX7Seg

Schematics

Multifunction Expansion Shield Schematic
The highly required shematic of the Multifunction Expansion Shield

Comments

Similar projects you might like

LCD (Liquid Crystal Display)

by MicroBob

  • 30,797 views
  • 41 comments
  • 101 respects

Displaying Sensor Values on LCD

by Wimpie van den Berg

  • 42,771 views
  • 4 comments
  • 36 respects

OSEPP LCD and keypad shield

Project tutorial by Joe

  • 38,396 views
  • 26 comments
  • 48 respects

Controlling an LED Matrix with Arduino Uno

Project tutorial by Igor Fonseca Albuquerque

  • 32,180 views
  • 5 comments
  • 24 respects
Add projectSign up / Login