DeanIsMe / SevSeg

Seven segment display controller library for Arduino
MIT License
328 stars 130 forks source link

BCD to change digit #108

Closed yankneck696 closed 6 months ago

yankneck696 commented 9 months ago

I have an old VFD that uses BCD to change the digit. I am not a coder, but butchered some code to sort of make it work. Could you add something to make it work more elegantly? At the moment it should present the number "4" in all 7 segments. As you can see, I did use your example in it. I have not physically tried it, but simulated it with LEDs to represent it on a Mega 2650. In the schematic, GRA-GRD are the BCD going to a 7442 BCD to 10 decimal IC. It may not be worth the time, but I felt it would be worth asking.

Thank you, Ed image

`#include "SevSeg.h" //Include SevSeg library Ed SevSeg sevseg; // I don't understand why the upper case to lower case change Ed

const byte digitSelectPin[4] = {10, 11, 12, 13};

int d = 30; //DELAY DEFAULT //int dm = 30; // DELAY MINIMAL byte digit=0;

void setup() { for (byte bit=0; bit<4; bit++) pinMode(digitSelectPin[bit], OUTPUT);

byte numDigits = 1; //Ed
byte digitPins[] = {}; //Ed
byte segmentPins[] = {6, 5, 2, 3, 4, 7, 8}; //A, B, C, D, E, F, G, (No DP)Ed
bool resistorsOnSegments = true; //Ed

byte hardwareConfig = COMMON_CATHODE; //Ed
sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments); //Ed
sevseg.setBrightness(90); //Ed

}

void loop() { for (byte bit=0; bit<4; bit++) { if (bitRead(digit, bit) == 1) digitalWrite(digitSelectPin[bit], HIGH); } delay(d); for (byte bit=0; bit<4; bit++) { if (bitRead(digit, bit) == 1) digitalWrite(digitSelectPin[bit], LOW); } //delay(dm); //not sure why you would want this, it would make display dimmer and flickery? Keeping for the moment to keep with the OEM's signal timing

digit++; if (digit >= 6) digit = 0;

sevseg.setNumber(4); //Ed sevseg.refreshDisplay(); //Ed } `

DeanIsMe commented 6 months ago

Hey, This library is intended for a reasonably specific use case and it wasn't my intention to support display ICs. Thanks for posting the information and I'm glad you got something working! You already have something working, but for others looking for IC support, I suggest looking for another library that support it, or forking this library.