# 3 digit 7 segment library

**URL:** <https://forum.xod.io/t/3-digit-7-segment-library/4307>\
**Category:** XOD Ideas & Discussions\
**Created:** [August 9, 2020, 6:38pm UTC](https://forum.xod.io/t/3-digit-7-segment-library/4307 "2020-08-09T18:38:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zfrenchy](https://avatars.discourse-cdn.com/v4/letter/z/278dde/32.png) [@zfrenchy](https://forum.xod.io/u/zfrenchy)\
**Post date:** [August 9, 2020, 6:38pm UTC](https://forum.xod.io/t/3-digit-7-segment-library/4307/1 "2020-08-09T18:38:11Z")

</div>

Hi guys,  
I am looking for a 3 digit, 7segment, LED display.

the only one I found is from Cesar, in 2018, but not available anymore.

Anyone ?

---

<div class="post-metadata">

**Author:** ![danya](https://avatars.discourse-cdn.com/v4/letter/d/7ba0ec/32.png) [@danya](https://forum.xod.io/u/danya)\
**Post date:** [August 9, 2020, 7:50pm UTC](https://forum.xod.io/t/3-digit-7-segment-library/4307/2 "2020-08-09T19:50:13Z")

</div>

In principle, although this is not entirely true, you can copy the code from there and create the same patch.

 ![image](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/2X/c/c08cf8928b2cb87ab6caf6ee0301fc50d3c9c21c.png)  
that’s all, you still need to add the input-output ports and in the program, change the ports to ports like yours. I hope you already understood what I said, because it’s difficult for me to explain in words. A good solution would be to make the code yourself, because maybe this code does not work (I have not tested).

---

<div class="post-metadata">

**Author:** ![zfrenchy](https://avatars.discourse-cdn.com/v4/letter/z/278dde/32.png) [@zfrenchy](https://forum.xod.io/u/zfrenchy)\
**Post date:** [August 11, 2020, 11:16pm UTC](https://forum.xod.io/t/3-digit-7-segment-library/4307/3 "2020-08-11T23:16:35Z")

</div>

Not sure I am following, where did you get this sketch ?  
also, it look like it is for a single digit, correct ?

I have this sketch, which it work fine, but I want use XOD.

 ![Capture](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/2X/d/d1cb30deef02c929d3a38a58e4090f7de692330f.png)

---

<div class="post-metadata">

**Author:** ![danya](https://avatars.discourse-cdn.com/v4/letter/d/7ba0ec/32.png) [@danya](https://forum.xod.io/u/danya)\
**Post date:** [August 24, 2020, 5:10pm UTC](https://forum.xod.io/t/3-digit-7-segment-library/4307/4 "2020-08-24T17:10:19Z")

</div>

Hello. create a patch and add a not-implemented-in-xod there and then add this code:  
#pragma XOD require “[https://github.com/sigvaldm/SevenSeg](https://github.com/sigvaldm/SevenSeg)”

// Include C++ library:  
{{#global}}  
#include \<SevenSeg.h\>  
{{/global}}

struct State {  
};

{{ GENERATED\_CODE }}

void evaluate(Context ctx) {  
if (!isInputDirty\<input\_UPD\>(ctx))  
return;  
//auto inValue = getValue\<input\_IN\>(ctx);  
//emitValue\<output\_OUT\>(ctx, inValue);

SevenSeg disp (10,6,4,2,1,9,5);  
const int numOfDigits = 3;  
int digitPins [numOfDigits] = {11, 8, 7};

```
int timer = 999;
int flag;
int AmmoCount;
int AmmoMax;
int Threshold;
int LEDvar;

```

if (isSettingUp()){ //void setup()  
// put your setup code here, to run once:  
::pinMode (A0, INPUT);  
Threshold = 500;  
AmmoMax = 999;  
AmmoCount = AmmoMax;  
disp.setDigitPins ( numOfDigits, digitPins );  
disp.setRefreshRate(150);  
}

// put your main code here, to run repeatedly:  
disp.write(AmmoCount);  
LEDvar = ::analogRead(A0);  
if (LEDvar \> Threshold){  
AmmoCount = AmmoCount - 1;  
LEDvar = 0;  
}

}

Does not give errors, but I do not have a sensor, so I cannot tell if the program is working. Also I have not added the input output parameters, but if you are good with xod, I do not think that this will cause you problems. The only thing I added to the patch is the input pulse. Called the UPD. It should be on a loop.
