PDA

View Full Version : NEW COM RADIO CODE FOR 7 SEGMENT_DIODE REQUEST! (BRAINSTORMING)



BuzziBi
11-07-2013, 02:13 PM
I have studied the JMeller's "FINAL_NAV_COM", but have difficulty understanding what is happening inside the sketsj.
I did not even get it to work! :(
It's possible I'm slow, but I hope Iím not the only one. :roll:
Therefore I was wondering if there could be another way to attack the problem.
The thing I wondering is: Is it possible to set up the different numbers, from zero to eight eg. in a Arrey (or a way to store thes values).



DIGIT0,
digitalWrite(pinA, B1);
digitalWrite(pinB, B1);
digitalWrite(pinC, B1);
digitalWrite(pinD, B1);
digitalWrite(pinE, B1);
digitalWrite(pinF, B1);
digitalWrite(pinG, B0);

DIGIT1,
digitalWrite(pinA, B0);
digitalWrite(pinB, B1);
digitalWrite(pinC, B1);
digitalWrite(pinD, B0);
digitalWrite(pinE, B0);
digitalWrite(pinF, B0);
digitalWrite(pinG, B0);

DIGIT2,
digitalWrite(pinA, B1);
digitalWrite(pinB, B1);
digitalWrite(pinC, B0);
digitalWrite(pinD, B1);
digitalWrite(pinE, B1);
digitalWrite(pinF, B0);
digitalWrite(pinG, B1);

And so on, to the DIGIT8...............................................


Then writing the Common anode HIGH / LOW as neaded when reseaving from Link2fs_multi.
Here Iím using 5 SSDís


digitalWrite(SSD1gnd, B0); //This is the active SSD
digitalWrite(SSD2gnd, B1);
digitalWrite(SSD3gnd, B1);
digitalWrite(SSD4gnd, B1);
digitalWrite(SSD5gnd, B1);


Setting this up in a sketsj I can write 0, 1 and 2, on the first 3 SSDís with the code like this:


DIGIT0,
digitalWrite(pinA, B1);
digitalWrite(pinB, B1);
digitalWrite(pinC, B1);
digitalWrite(pinD, B1);
digitalWrite(pinE, B1);
digitalWrite(pinF, B1);
digitalWrite(pinG, B0);
digitalWrite(SSD1gnd, B0); //The code goes to the 1. Digit
digitalWrite(SSD2gnd, B1);
digitalWrite(SSD3gnd, B1);

DIGIT1,
digitalWrite(pinA, B0);
digitalWrite(pinB, B1);
digitalWrite(pinC, B1);
digitalWrite(pinD, B0);
digitalWrite(pinE, B0);
digitalWrite(pinF, B0);
digitalWrite(pinG, B0);
digitalWrite(SSD1gnd, B1);
digitalWrite(SSD2gnd, B0);//The code goes to the 2. Digit
digitalWrite(SSD3gnd, B1);

DIGIT2,
digitalWrite(pinA, B1);
digitalWrite(pinB, B1);
digitalWrite(pinC, B0);
digitalWrite(pinD, B1);
digitalWrite(pinE, B1);
digitalWrite(pinF, B0);
digitalWrite(pinG, B1);
digitalWrite(SSD1gnd, B1);
digitalWrite(SSD2gnd, B1);
digitalWrite(SSD3gnd, B0); //The code goes to the 3. Digit

Thus I was wondering if one could receive Com1 (= A) from Link2fs_multi, retrieve the value eg (118,300 only use 118.30 for 5 SSD's).
And then deciding which Common's to show the stored value (DIGIT)

IE: OBS! This is not a working code but a brainstorming!

Serial.read(); 118.30
(digitalWrite SSD1 + DIGIT1),
(digitalWrite SSD2 + DIGIT1)
(digitalWrite SSD3 + DIGIT8 + Desimal "DP")
(digitalWrite SSD4 + DIGIT3)
(digitalWrite SSD5 + DIGIT0)


This way one could make a code that "slow-downs" like me could understand what is going on in the sketsj.
Do not be afraid to say that I'm on the wrong track with this idea.
But suggestions is received with pleasure

JMeller
11-07-2013, 09:44 PM
Roy,
I soooo apologize. That was my first finished product at my first crack of the arduino code; it's a long daunting mess!

I agree with you... arrays seem to be a better way to go. So, to pay pennance, I decided to offer up this theory:



void setup {
... usual setup stuff
comAnode = 9 // define first anode of com1
// comAnodes are pins 9, 10, 11, 12; this assumes 1wx.yz0; 1, decimal, & 0 are static
} // end setup


void loop() {
... linkFS stuff

com1 [0] = char(Serial.read()-48);
com1 [1] = char(Serial.read()-48);
com1 [2] = char(Serial.read()-48);
com1 [3] = char(Serial.read()-48); // decimal point
com1 [4] = char(Serial.read()-48);
com1 [5] = char(Serial.read()-48);
com1 [6] = char(Serial.read()-48);
LEDstates(); // fetch method
} // end loop




void LEDstates(){


for (int i = 1; i < 6; i++) { // does not read first digit com1 [0] or last digit com1 [6]


// Note: need to disregard decimal at com1 [3]

switch (com1 [i]) {
case 0:
led[6] = {1,1,1,1,1,1,0}; //{a,b,c,d,e,f,g} creates '0'
LightSEG();

case 1:
led[6] = {0,1,1,0,0,0,0}; //{a,b,c,d,e,f,g} creates '1'
LightSEG()

... etc.
if (comAnode < 13) {comAnode = comAnode + 1;}else{ comAnode = 9;}
}
}// end LEDstates


void LightSEG(){

digitalWrite (Pin2, led[0]); // a segment
digitalWrite (Pin3, led[1]); // b segment
digitalWrite (Pin4, led[2]); // c segment
digitalWrite (Pin5, led[3]); // d segment
digitalWrite (Pin6, led[4]); // e segment
digitalWrite (Pin7, led[5]); // f segment
digitalWrite (Pin8, led[6]); // g segment
WriteAnode();

} //end LightSEG


void WriteAnode() {
digitalWrite ({comAnode , HIGH);
delay(30); adjust accordingly to avoid eye detected number blink
digitalWrite ({comAnode , LOW);
}// end WriteAnode


Hope this helps. Be prepared for A LOT of tedious soldering!!

BuzziBi
11-08-2013, 06:46 AM
Hi James.
I have to crawl to the cross to ask for an explanation :oops:
I do not know if this phrase originates from programming language, or whether it is directly related to the SSD's

< this assumes 1wx.yz0; >

But I had appreciated an explanation :smile:


I'll just sit there staring at this statement except I do not understand what it tells me!

JMeller
11-08-2013, 08:24 AM
lol - no, it is I who had to pay for my wrong doing. :)

Anyway, 1wx.yz0 is a shorthand picture of the variable com freq layout:

In my setup, the first digit and the last digit are hardwired to never change. Example: 122.250 - the first digit is always "1" and the last digit is always "0"; to save outputs, they are hardwired to be static numbers; the decimal point is also static and should be hardwired to always be lit. This was a tip geneb gave me.

Therefore, wxyz (2225) are the numbers which will change via Link2FS; the segments (a-g) and the four anode pins( or cathodes) are connected to
the arduino outputs.

Hope this cleared up the confusion.

BuzziBi
11-08-2013, 10:20 AM
JEY! Now we can talk (the same language) :p
TX. for that explanation. It's weird how small stone can fell great oaks :p

BuzziBi
11-08-2013, 04:22 PM
I'm back with some nagging James :rolleyes:
I tried to put the code in a sketsh and this came up?
I have unfortunately not the skills to see the error.
8292

JMeller
11-08-2013, 06:46 PM
Ha. It's important thing to remember is what I typed up was only a theory; it was never placed into a sketch - much less tested.

That said, the line highlighted appears not to like the led array. Was it declared as an array at the top of the sketch?

The second error I noticed was that there is a missing bracket "}" to close the LEDstates method. Yeah, I know it shows one with the comment "// end LEDstates" - simply add a "}" above that.

Next I noticed I did not close my second statement under Case1 with the semicolon.

Next I noticed "... etc" in line 45.

The theory I proposed was not meant to be a copy, paste and everything works. It was meant to be a guide using the knowledge I have learned since the original pde.

BuzziBi
11-09-2013, 06:47 PM
Hi James.
The day has been used in reading on webpages, about SSD's and Led's :roll:
Don't think I'm getting anyway!
Is it possible to set up the "Digits" and the "Segments"in an Arrey, this way?


//10 Digits (0-9) and 7 Segments.

byte Digits_Segments[10][7] = {
{ 1,1,1,1,1,1,0 }, // = 0
{ 0,1,1,0,0,0,0 }, // = 1
{ 1,1,0,1,1,0,1 }, // = 2
{ 1,1,1,1,0,0,1 }, // = 3
{ 0,1,1,0,0,1,1 }, // = 4
{ 1,0,1,1,0,1,1 }, // = 5
{ 1,0,1,1,1,1,1 }, // = 6
{ 1,1,1,0,0,0,0 }, // = 7
{ 1,1,1,1,1,1,1 }, // = 8
{ 1,1,1,0,0,1,1 }}; // = 9

JMeller
11-09-2013, 09:16 PM
Roy,
I can't say... I've never used the format. However, after viewing your code, it occurred to me that I used a zero based definition to define the array for led. It should be as follows:

case 0:
led[7] = {1,1,1,1,1,1,0}; //{a,b,c,d,e,f,g} creates '0'
LightSEG();

below was my error:L
case 0:
led[ 6 ] = {1,1,1,1,1,1,0}; //{a,b,c,d,e,f,g} creates '0'
LightSEG();

Note: define arrays as whole numbers (greater than zero); read arrays as zero based

This could explain the exception that was thrown in your earlier post. Perhaps, I should build actually take the time to sketch and build example code rather than just throw it out there from the top of my head!

Below is the theory built in the sketch with no errors; insert your code need to read from Link2FS .


int com1[7];
int led[7];
int comAnode;


int Pin2 = 2;
int Pin3 = 3;
int Pin4 = 4;
int Pin5 = 5;
int Pin6 = 6;
int Pin7 = 7;
int Pin8 = 8;


void setup(){
// your setup stuff here
}




void loop() {
// Link2FS stuff here
com1 [0] = char(Serial.read()-48);
com1 [1] = char(Serial.read()-48);
com1 [2] = char(Serial.read()-48);
com1 [3] = char(Serial.read()-48); // decimal point
com1 [4] = char(Serial.read()-48);
com1 [5] = char(Serial.read()-48);
com1 [6] = char(Serial.read()-48);
LEDstates(); // fetch method
} // end loop








void LEDstates(){




for (int i = 1; i < 6; i++) { // does not read first digit com1 [0] or last digit com1 [6]




// Note: need to disregard decimal at com1 [3]


switch (com1 [i]) {
case 0:
led[7] = (1,1,1,1,1,1,0); //{a,b,c,d,e,f,g} creates '0'
LightSEG();

case 1:
led[7] = (0,1,1,0,0,0,0); //{a,b,c,d,e,f,g} creates '1'
LightSEG();

if (comAnode < 13) {comAnode = comAnode + 1;}else{ comAnode = 9;}
}
}
}// end LEDstates




void LightSEG(){


digitalWrite (Pin2, led[0]); // a segment
digitalWrite (Pin3, led[1]); // b segment
digitalWrite (Pin4, led[2]); // c segment
digitalWrite (Pin5, led[3]); // d segment
digitalWrite (Pin6, led[4]); // e segment
digitalWrite (Pin7, led[5]); // f segment
digitalWrite (Pin8, led[6]); // g segment
WriteAnode();


} //end LightSEG




void WriteAnode() {
digitalWrite (comAnode , HIGH);
delay(30); // adjust accordingly to avoid eye detected number blink
digitalWrite (comAnode , LOW);
}// end WriteAnode


Happy coding!
JM

BuzziBi
11-10-2013, 07:20 AM
Hi James.

Only working with hardware before I started with Arduino, I really have trouble to learn the terms: "Reference: structure, values​​, and functions.
I see an "int" and automatically goes: "initialize!". :D
I'm trying to put the different parts of your suggestions into the (Multi_Basic_Concept.ino), and it's hard to get my head focused.
But I'm trying, and it's fun thoug!

A thought:
This line: //Note: need to disregard decimal at com1 [3]
Can it be done with a bolean "!" (not), like this: !3;
in the line:
for (int i = 1; i i < 6; i++) // does not read first digit com1[0], or last digit com1 [6]

EDIT:
Also: can You explain this:
if (comAnode < 13) {comAnode = comAnode + 1;}else{ comAnode = 9;}

What does the digit's refer to?

JMeller
11-10-2013, 10:52 AM
The line:
if (comAnode < 13) {comAnode = comAnode + 1;}else{ comAnode = 9;}

Since the segments (a-g) are assigned to pins 2-8, the anodes for the four number blocks are assigned to 9 through 12. Because of the for-next loop within the LEDstates method, it will make five passes (one pass will include the decimal point) to determine the Case - which highlightes need to disregard the decimal point. The corrected statement should be:

if (i <> 3){ // com1[3] = decimal point
if (comAnode < 13) {comAnode = comAnode + 1;}else{ comAnode = 9;}
}
Now that I corrected the statement, I'll resume the explanation. :) Ok, so we know there will be five passes in the for-next loop to determine which case to use in order to assign the proper segment array values. We also know that by the time it finishes the last case (case 9) , it will have determined what the number is, assigned the proper segment array value to light up the correct segments, then fetched the LEDsegments method to write the appropriate segment pins (2-8 ) HIGH (refer to EDIT).

After it writes the pins high, the last line of the LEDsegments method tells it to fetch the WriteAnode method. This is where comAnode comes into play... remember at the first pass of the for-next loop the value of comAnode was 9; therefore, it will digitalWrite (9, HIGH) displaying the number found from com1[i] for period determined by the following delay statement. Then it turn it off. At the second pass of the for-next loop, it will digitalWrite (10, HIGH) which is your second 7-segment led block. This continues to
the last 7-segment led block which has the anode pin on pin12 i.e., digitalWrite (12, HIGH). After it has lit the last led block (pin12), it returns to the first led block on pin9 and repeats the process - which highlights another error I made!! Correction below:

if (i <> 3){ // com1[3] = decimal point
if (comAnode < 12) {comAnode = comAnode + 1;}else{ comAnode = 9;}
}

The reason it was changed to 12 is because the statement is after the Select Case. Since it is after it, comAnode's value could have been assigned to pin13 and executed the LEDstates, LEDsegments, and WriteAnode before reverting back to pin9 - which would have thrown everything out of whack!

I hope this all made sense.

Edit: You're gonna love this...
If you're using the common anode type 7-segments, you'll want to assign the values for a-g LOW to allow current to pass. That said,
WRONG:
case 0:
led[7] = (1,1,1,1,1,1,0); //{a,b,c,d,e,f,g} creates '0'

CORRECTED:
case 0:
led[7] = (0,0,0,0,0,0,1); //{a,b,c,d,e,f,g} creates '0'

Yet another reason I should build & test the theory! :)

BuzziBi
11-11-2013, 07:52 AM
James.
First of all, thanks for the explanation regarding the comAnode. (I will come back to that :D )
I guess if you are going to use the "comAnode" in the "void loop()}", we must tell where the comAnodes are?
So...... Do one set them up with "int", in an Arrey or in the void setup()}

With int :


int Pin2 = 2;
int Pin3 = 3;
int Pin4 = 4;
int Pin5 = 5;
int Pin6 = 6;
int Pin7 = 7;
int Pin8 = 8;


int Com1Anode1 = 9;
int Com1Anode2 = 10;
int Com1Anode3 = 11;
int Com1Anode4 = 12;
int Com1Anode5 = 13;
void setup()}

void loop()}

In an Arrey:


int comAnode[] = {9, 10, 11, 12, 13};
void setup()}

void loop()}

Or in the void setup()}


int comAnode;
void setup(){


pinMode (Pin2, OUTPUT); //THe segment pins
pinMode (Pin3, OUTPUT);
pinMode (Pin4, OUTPUT);
pinMode (Pin5, OUTPUT);
pinMode (Pin6, OUTPUT);
pinMode (Pin7, OUTPUT);
pinMode (Pin8, OUTPUT);

for (int comAnode = 9; comAnode < 14; comAnode++)
{
pinMode(comAnode, OUTPUT);
digitalWrite(comAnode, HIGH);
}
}
void loop() {

Now let me come back to the "explanation regarding the comAnode". :D
I thought I had it regarding the common anode/common catode, but lets clarify!
8304
As I can se it
(with common catode), the common catode must be LOW and the segments HIGH,
to show any given digit.

digitalWrite (comAnode1, LOW);
led[7] = (1,1,1,1,1,1,0); //{a,b,c,d,e,f,g} creates '0'

and (with common anode), the common anode, the anode must be HIGH and the segments LOW,
to show any given digit.

digitalWrite (comAnode1, HIGH);
led[7] = (0,0,0,0,0,0,1); //{a,b,c,d,e,f,g} creates '0'

Am I correct in this, or? :D

One more thing:
I cant get the:

if (i <> 3){ // com1[3] = decimal point to compile!
But this one does:

if (i < 3 > 3 ){ // com1[3] = decimal point

JMeller
11-11-2013, 08:36 AM
With regard to the common anode/cathode bit you wrote about at the end of your post- you are absolutely correct.

However, the comAnode will not be in array because there is no need to store the value. It will be assigned a value at the top of the sketch: int comAnode = 9;

Then, it will get incremented by 1 in the LEDstates method... if i does not equal three.
It also resets the value to nine if comAnode equals twelve (because in my example, my anodes are on pins 9,10,11 & 12):

Corrected (i <>3)... I was speaking visual basic - oops!

if (i != 3){ // com1[3] = decimal point
if (comAnode < 12) {comAnode = comAnode + 1;}else{ comAnode = 9;}
}

Setup for common anode:


int Pin2 = 2;
int Pin3 = 3;
int Pin4 = 4;
int Pin5 = 5;
int Pin6 = 6;
int Pin7 = 7;
int Pin8 = 8;
int comAnode = 9; // must define starting pin; this pin will increase to 12 in the LEDstates method

void setup(){
for (int i = 2; i < 9; i++)
{
pinMode (i, OUTPUT);
digitalWrite(i, HIGH);
}

for (int i = 9; i < 13; i++)
{
pinMode(i, OUTPUT);
digitalWrite(i, LOW);
}
}


Setup for common cathode


int Pin2 = 2;
int Pin3 = 3;
int Pin4 = 4;
int Pin5 = 5;
int Pin6 = 6;
int Pin7 = 7;
int Pin8 = 8;
int comAnode = 9; // must define starting pin; this pin will increase to 12 in the LEDstates method

void setup(){
for (int i = 2; i < 9; i++)
{
pinMode (i, OUTPUT);
digitalWrite(i, LOW);
}

for (int i = 9; i < 13; i++)
{
pinMode(i, OUTPUT);
digitalWrite(i, HIGH);
}
}

BuzziBi
11-11-2013, 09:57 AM
So if I've got 4 comon anodes:


int Pin2 = 2;
int Pin3 = 3;
int Pin4 = 4;
int Pin5 = 5;
int Pin6 = 6;
int Pin7 = 7;
int Pin8 = 8;
int comAnode9 = 9; // must define starting pin; this pin will increase to 12 in the LEDstates method
int comAnode10 = 10;
int comAnode11 = 11;
int comAnode12 = 12;

void setup(){
for (int i = 2; i < 9; i++)
{
pinMode (i, OUTPUT);
digitalWrite(i, LOW);
}

for (int i = 9; i < 13; i++)
{
pinMode(i, OUTPUT);
digitalWrite(i, HIGH);
}
}

JMeller
11-11-2013, 10:27 AM
No. You only need int comAnode = 9 ... not comAnode9, comAnode10, etc. Why? Because comAnode will increase by 1 in the last line of the LEDstates method. But before it increases by one, it will told to go to WriteAnode method:

void WriteAnode() {
digitalWrite (comAnode , HIGH);
delay(30); // adjust accordingly to avoid eye detected number blink
digitalWrite (comAnode , LOW);
}// end WriteAnode

BuzziBi
11-11-2013, 11:20 AM
OOOOOOoooooo!!
So I guess this line: for (int i = 9; i < 13; i++)
already hawe stated where the comaAanodes are?
On Pin 9, 10, 11 and 12.
is that correct?

JMeller
11-11-2013, 11:48 AM
Yup, you got it!

BuzziBi
11-12-2013, 06:53 AM
Next question ;)
If you uses this line in the void setup, for the Segments and the Anode/Catode:

for (int i = 2; i < 9; i++) // The segments
{
pinMode (i, OUTPUT);
digitalWrite(i, LOW); }

for (int i = 9; i < 13; i++) // The Anode/Catode
{
pinMode(i, OUTPUT);
digitalWrite(i, HIGH);
}

Would'nt this create problems when we in the loop adds this:
(when we simultaneously use (i) for the segments).


if (i != 3){ // com1[3] = decimal point //
if (comAnode < 12) {comAnode = comAnode + 1;}else{ comAnode = 9;}
}
What I wonder is, whether or not, (is this the name?) the "Parameter" for the Anode/Catode,must be given another name, both in the void setup and the void loop!
Like this:

for (int i = 2; i < 9; i++) // The segments
{
pinMode (i, OUTPUT);
digitalWrite(i, LOW); }

for (int x = 9; x < 13; x++) // The Anode/Catode
{
pinMode(x, OUTPUT);
digitalWrite(x, HIGH);

}

if (x != 3){ // com1[3] = decimal point //
if (comAnode < 12) {comAnode = comAnode + 1;}else{ comAnode = 9;}
}

JMeller
11-12-2013, 07:25 AM
In your first example - No. I purposely wrote it as such to illustrate that fact. The variable "i" is declared by the for-next loop using for (int i = 2; i < 9; i++){ //stuff here} ; Consequently, the variable "i" is confined only within the brackets of that for-next loop and that loop only. If you attempted "i" outside of the for-next loop, you would have a build error stating "i" was not declared. For that reason, variables which are to be used throughout the void loop(), void LEDstates(), etc. must be declared at the top of the sketch.

Now, if you have a for-next loop WITHIN another for-next loop then you would have to use another variable name.

BuzziBi
11-12-2013, 09:22 AM
Hi James.
I'm absolutely stuck'ed here :( (So, nothing new)
Take a loock at the code, can this sum it up so far?
I just wonder, how can I write a test line in the sketch, just to see if I can light up a couple of displays?
I just dont know what to use in a "digitalWrite" :-(


int com1[7];
int led[7];


int Pin2 = 2; //The segment pins A, B, C, D, E, F, G.
int Pin3 = 3;
int Pin4 = 4;
int Pin5 = 5;
int Pin6 = 6;
int Pin7 = 7;
int Pin8 = 8;


int comAnode = 9; /* Define starting pin for the common Anodes (comAnode).
This will including pin 10, 11, 12, with the LEDstates method, in the line: for (int i = 9; i < 13; i++)
*/


void setup(){

// NOTE!
for (int i = 2; i < 9; i++) // Writes the Segmengt pins 2,3,4,5,6,7, and 8,
{ // "LOW" (For common Catode Displays).
pinMode (i, OUTPUT); // Change it to "HIGH" (For the common Anode Displays).
digitalWrite(i, LOW); // This will turn the Segment pins "OFF".
}




for (int i = 9; i < 13; i++) // NOTE!
{ // Writes the common Anode/Catode.
pinMode(i, OUTPUT); // Make it "HIGH" (For The common Catode Displays),
digitalWrite(i, HIGH); // change it to "LOW" (For The common Anode Displays).
}


Serial.begin(115200);
}


void loop() {

}
void LEDstates(){


for (int i = 1; i < 6; i++) { // does not read first digit com1 [0] or last digit com1 [6]
if (i != 3){ // does not read the decimal point
if (comAnode < 12) {comAnode = comAnode + 1;}else{ comAnode = 9;}
}


switch (com1 [i]) {
case 0:
led[7] = (1,1,1,1,1,1,0); //{a,b,c,d,e,f,g} creates '0'
LightSEG();

case 1:
led[7] = (0,1,1,0,0,0,0); //{a,b,c,d,e,f,g} creates '1'
LightSEG();


case 2:
led[7] = (1,1,0,1,1,0,1); //{a,b,c,d,e,f,g} creates '2'
LightSEG();


case 3:
led[7] = (1,1,1,0,0,0,1); //{a,b,c,d,e,f,g} creates '3'
LightSEG();


case 4:
led[7] = (0,1,1,0,0,1,1); //{a,b,c,d,e,f,g} creates '4'
LightSEG();


case 5:
led[7] = (1,0,1,1,0,1,1); //{a,b,c,d,e,f,g} creates '5'
LightSEG();


case 6:
led[7] = (1,0,1,1,1,1,1); //{a,b,c,d,e,f,g} creates '6'
LightSEG();


case 7:
led[7] = (1,1,1,0,0,0,0); //{a,b,c,d,e,f,g} creates '7'
LightSEG();


case 8:
led[7] = (1,1,1,1,1,1,1); //{a,b,c,d,e,f,g} creates '8'
LightSEG();


case 9:
led[7] = (1,1,1,0,0,1,1); //{a,b,c,d,e,f,g} creates '9'
LightSEG();
}
}
} // end LEDstates


void LightSEG(){


digitalWrite (Pin2, led[0]); // a segment
digitalWrite (Pin3, led[1]); // b segment
digitalWrite (Pin4, led[2]); // c segment
digitalWrite (Pin5, led[3]); // d segment
digitalWrite (Pin6, led[4]); // e segment
digitalWrite (Pin7, led[5]); // f segment
digitalWrite (Pin8, led[6]); // g segment
WriteAnode();
} //end LightSEG


void WriteAnode() {
digitalWrite (comAnode , HIGH);
delay(30); // adjust accordingly to avoid eye detected number blink
digitalWrite (comAnode , LOW);
} // end WriteAnode

JMeller
11-12-2013, 05:12 PM
See notes highlighted in green:


int com1[7];
int led[7];

int Pin2 = 2; //The segment pins A, B, C, D, E, F, G.
int Pin3 = 3;
int Pin4 = 4;
int Pin5 = 5;
int Pin6 = 6;
int Pin7 = 7;
int Pin8 = 8;

int comAnode = 9; /* Define starting pin for the common Anodes (comAnode).
This will including pin 10, 11, 12, with the LEDstates method, in the line: for (int i = 9; i < 13; i++)
*/

void setup(){

// NOTE!
for (int i = 2; i < 9; i++) // Writes the Segmengt pins 2,3,4,5,6,7, and 8,
{ // "LOW" (For common Catode Displays).
pinMode (i, OUTPUT); // Change it to "HIGH" (For the common Anode Displays).
digitalWrite(i, LOW); // This will turn the Segment pins "OFF".
}

for (int i = 9; i < 13; i++) // NOTE!
{ // Writes the common Anode/Catode.
pinMode(i, OUTPUT); // Make it "HIGH" (For The common Catode Displays),
digitalWrite(i, HIGH); // change it to "LOW" (For The common Anode Displays).
}
Serial.begin(115200);
// store comm freq in com1 array - freq= 121.750
com1 [0] = 1; // will not be read for-next loop
com1 [1] = 2;
com1 [2] = 1;
com1 [3] = .; // this may cause an error - to correct, com1[7] may need to be declared as
//String since '.' is not an integer; or, for testing reasons, simply assign any number since it will not //be read anyway.
com1 [4] = 7;
com1 [5] = 5;
com1 [6] = 0; // will not be read from LEDstates() for-next loop
}

void loop() {

}
void LEDstates(){

for (int i = 1; i < 6; i++) { // does not read first digit com1 [0] or last digit com1 [6]

// moved if ( i != 3) (see below)

switch (com1 [i]) {
case 0:
led[7] = (1,1,1,1,1,1,0); //{a,b,c,d,e,f,g} creates '0'
LightSEG();

case 1:
led[7] = (0,1,1,0,0,0,0); //{a,b,c,d,e,f,g} creates '1'
LightSEG();

case 2:
led[7] = (1,1,0,1,1,0,1); //{a,b,c,d,e,f,g} creates '2'
LightSEG();

case 3:
led[7] = (1,1,1,0,0,0,1); //{a,b,c,d,e,f,g} creates '3'
LightSEG();

case 4:
led[7] = (0,1,1,0,0,1,1); //{a,b,c,d,e,f,g} creates '4'
LightSEG();

case 5:
led[7] = (1,0,1,1,0,1,1); //{a,b,c,d,e,f,g} creates '5'
LightSEG();

case 6:
led[7] = (1,0,1,1,1,1,1); //{a,b,c,d,e,f,g} creates '6'
LightSEG();

case 7:
led[7] = (1,1,1,0,0,0,0); //{a,b,c,d,e,f,g} creates '7'
LightSEG();

case 8:
led[7] = (1,1,1,1,1,1,1); //{a,b,c,d,e,f,g} creates '8'
LightSEG();

case 9:
led[7] = (1,1,1,0,0,1,1); //{a,b,c,d,e,f,g} creates '9'
LightSEG();
} //END Select Case


// Moved if !=3 to after Select Case because it is assumed segment values were
// assigned and the method LightSeg() (and remaining methods with the method) has
// been fetched and returned back to the for-next loop. After doing so, comAnode is allowed
// to move to the next pin of the LED Block.
if (i != 3){ // does not read the decimal point
if (comAnode < 12) {comAnode = comAnode + 1;}else{ comAnode = 9;}
}
} // END for-next loop
} // end LEDstates


void LightSEG(){

digitalWrite (Pin2, led[0]); // a segment
digitalWrite (Pin3, led[1]); // b segment
digitalWrite (Pin4, led[2]); // c segment
digitalWrite (Pin5, led[3]); // d segment
digitalWrite (Pin6, led[4]); // e segment
digitalWrite (Pin7, led[5]); // f segment
digitalWrite (Pin8, led[6]); // g segment
WriteAnode();
} //end LightSEG

void WriteAnode() {
digitalWrite (comAnode , LOW); // changed to work with common Cathode
delay(30); // adjust accordingly to avoid eye detected number blink
digitalWrite (comAnode , HIGH); // changed to work with common Cathode
} // end WriteAnode


edit: copy/paste error in assigning com1 values is setup()

BuzziBi
11-15-2013, 07:08 AM
Hi James.
I am struggling to get things to fall into place(in my head).
I did not get the Sketc to work so I'm back to my original idea of setting the Segments up in a arrey, using "byte".
( Do not understand that I'm doing this! I'm sure not innteligent enough. :roll: )
Just as well I've set up 4 seven_segent_displays, and made a sketch (Segments in a arrey, using "byte") that counts to 3 on the first display, then makes second display show digit 1, when second display have reached 3, the third display count up to 3, and then starts counting on display 4. When display 4 have reached 3, it starts all over again.
Yes! I am aware that I have not reinvented the wheel, but it sure feels a bit like that :p
Now I'm struggling to do something usable with this.
In that context, I found this in You're "FINAL_NAV_COM.pde"


" if (COM1LED == 1 || COM1LED == 4)"
I have seen this another place, called a delimiter.

//delimiter
if(i==2 || i==4) {
Do You care to explain.

JMeller
11-15-2013, 07:35 AM
Hello, Roy. It had been a few days since I last heard from you - I was hoping you had great success! :)

A delimiter is a character which indicates the beginning and end of a statement. In the case of the arduino example, "(" and ")" are delimiters for the condition of the IF statement. The "{" and the "}" are delimiters for the IF output.

I'll tell you what I'll do Roy - I've been wanting to start on an MCP. I'll begin building an LED board this weekend and put the theory to the test and post the results - hopefully by end of the weekend.

BuzziBi
11-15-2013, 03:20 PM
Hmmmmm!
I will show you the code I'm playing with. (The code origins from a SSD_LED_Watch).
I have attempted to write explanation trough the sketch, but I'm not sure how to describe it all!
See the end of the code (delimiter), her is something I don't understand.
After running trough all numbers in the "byte d[10]" , the display lights up random segments.
I suppose I should have a sort of code to terminate the count, made in the "(for(int j=0; j<8; j++)".
But I don't know how :(
I imagine that this way of doing it would simplify things. I could be wrong...........:grin:




#define DIGITS 4



int digits[DIGITS] = {9,10,11,12}; // mapping the common cathodes


int segments[7] = {2,3,4,5,6,7,8}; //A,B,C,D,E,F,G
//digits (segments on/off) common cathode displays. opposite for common anode
byte d[10] = {
B00111111, //0
B00000110, //1
B01011011, //2
B01001111, //3
B01100110, //4
B01101101, //5
B01111101, //6
B00000111, //7
B01111111, //8
B01101111, //9
};



//write the Segments OUTPUTS and makes a on/off statement
void on(int pin) {
digitalWrite(pin, HIGH);
}
void off(int pin) {
digitalWrite(pin, LOW);
}
void out(int pin) {
pinMode(pin, OUTPUT);
}
void offSegments(){
for(int i=0; i<7; i++) {
off(segments[i]);
}
}
void onSegments(){
for(int i=0; i<7; i++) {
on(segments[i]);
}
}

//----------------------------------------------
void setup() {
Serial.begin(115200);

int i=0;
//init pins
for(i=0; i < DIGITS; i++) {
out(digits[i]);
off(digits[i]);//led's cathod set low
}
for(i=0; i<9; i++) {
out(segments[i]);
}

// Test light all. segments anod set high
onSegments();
delay(1000);
//hide
for(i=0; i < DIGITS; i++) {
on(digits[i]);
}
offSegments();
}
//----------------------------------------------

byte framebuffer[4] = {0,0,0,0}; //




//----------------------------------------------


void loop() {
//------------------------------------------
for(int i=0; i < 13; ) {

byte currentChar = d[framebuffer[i]++]; //

if(i==0 || i==0) {//delimiter
}
for(int j=0; j<8; j++){
if(bitRead(currentChar, j)){
on(segments[j]);


} else {
off(segments[j]);
}
}
off(9); //Turns display #1 on, and now this display will count trough digits in the "byte" d[10].

delay (400);

}


}

JMeller
11-16-2013, 04:05 PM
As promised, working code posted below. I must apologize, though. I led you astray using:
case 1:
led[7] = {0,1,1,0,0,0,0}; //{a,b,c,d,e,f,g} creates '1'
LightSEG();

The reason is because you can only use led[7] = {0,1,1,0,0,0,0} to initialize an array with values. To modify values, you would have to write led[0] = 0; led[1] = 1; led[2] = 1; and so on to segment 'g'. This, of course, worked but it created a long & messy code for each select case.

So, I simply stored the values in a complete string and then the string was parsed into an array. Once in the array, I subtracted 48 from the ascii value and placed into another array to hold the integer. Now that it was converted to an integer, it could now tell the arduino to write the segment pins HIGH or LOW using the 1 or 0 respectively.



Have fun!


int com1[7];
char ledstr[7];
int ledint[7];
String segValue = "0000000";


int a = 31; //The segment pins A, B, C, D, E, F, G.
int b = 33;
int c = 35;
int d = 37;
int e = 39;
int f = 41;
int g = 43;


int comAnode = 9; /* Define starting pin for the common Anodes (comAnode).
This will including pin 10, 11, 12, with the LEDstates method, in the line: for (int i = 9; i < 13; i++)
*/


void setup(){
// NOTE!
for (int i = 31; i < 44; i++) // Writes the Segmengt pins 2,3,4,5,6,7, and 8,
{ // "LOW" (For common Catode Displays).
pinMode (i, OUTPUT); // Change it to "HIGH" (For the common Anode Displays).
digitalWrite(i, HIGH); // This will turn the Segment pins "OFF" for ANODE type.
}


for (int i = 9; i < 13; i++) // NOTE!
{ // Writes the common Anode/Catode.
pinMode(i, OUTPUT); // Make it "HIGH" (For The common Catode Displays),
digitalWrite(i, LOW); // change it to "LOW" (For The common Anode Displays).
}
Serial.begin(115200);




// store comm freq in led array - freq= 121.750
com1 [0] = 1; // will not be read for-next loop
com1 [1] = 2;
com1 [2] = 1;
com1 [3] = 0; // this may cause an error - to correct, com1[7] may need to be declared as
//String since '.' is not an integer; or, for testing reasons, simply assign any number since it will not //be read anyway.
com1 [4] = 7;
com1 [5] = 5;
com1 [6] = 0; // will not be read from LEDstates() for-next loop
}


void loop() {
LEDstates();
}




void LEDstates(){


for (int i = 1; i < 6; i++) { // does not read first digit com1 [0] or last digit com1 [6]


switch (com1[i]) {
case 0:
segValue = "0000001"; // Common Anode type
//segValue = "1111110"; // Common Cathode type
break;

case 1:
segValue = "1001111"; // Common Anode type
//segValue = "0110000"; // Common Cathode type
break;

case 2:
segValue = "0010010"; // Common Anode type
//segValue = "1101101"; // Common Cathode type
break;

case 3:
segValue = "0000110"; // Common Anode type
//segValue = "1111001"; // Common Cathode type
break;

case 4:
segValue = "1001100"; // Common Anode type
//segValue = "0110011"; // Common Cathode type
break;

case 5:
segValue = "0100100"; // Common Anode type
//segValue = "1011011"; // Common Cathode type
break;

case 6:
segValue = "0100000"; // Common Anode type
//segValue = "1011111"; // Common Cathode type
break;

case 7:
segValue = "0001111"; // Common Anode type
//segValue = "1110000"; // Common Cathode type
break;

case 8:
segValue = "0000000"; // Common Anode type
//segValue = "1111111"; // Common Cathode type
break;

case 9:
segValue = "0001100"; // Common Anode type
//segValue = "1110011"; // Common Cathode type
break;

} //END Select Case



if (i != 3){ // does not read the decimal point
LightSEG();
if (comAnode < 12) {comAnode = comAnode + 1;}else{ comAnode = 9;}
}

} // END for-next loop
} // end LEDstates




void LightSEG(){
//Assign to ledstr array
segValue.toCharArray(ledstr, 8);

// subtract 48 from ascii value and assign to ledint array
for (int i = 0; i < 7; i++) { ledint[i] = ledstr[i] - 48; }

digitalWrite (a, ledint[0]); // a segment
digitalWrite (b, ledint[1]); // b segment
digitalWrite (c, ledint[2]); // c segment
digitalWrite (d, ledint[3]); // d segment
digitalWrite (e, ledint[4]); // e segment
digitalWrite (f, ledint[5]); // f segment
digitalWrite (g, ledint[6]); // g segment

WriteAnode();
} //end LightSEG


void WriteAnode() {
digitalWrite (comAnode , HIGH); // changed to HIGH work with common ANODE
delay(1);
digitalWrite (comAnode , LOW); // changed to LOW work with common ANODE
} // end WriteAnode

JMeller
11-16-2013, 08:17 PM
Hmmm. For curiosity, I began looking into your bit - pun intended. :) Anyhow, I found a sketch here (http://www.tinkerhobby.com/controlling-a-seven-segment-display-using-arduino-part-4-of-4/) and modified it to suit our application.

Below is the modified & tested (and much shorter!!) code :


// Arduino digital pins used to light up
// corresponding segments on the LED display
#define Apin 30
#define Bpin 32
#define Cpin 34
#define Dpin 36
#define Epin 38
#define Fpin 40
#define Gpin 42


int Anode = 9;
char com1[7];
int freq = 0; // current display count
int j;






//Common Anode = 0b gfedcba
const byte numbers[10] = { 0b1000000, 0b1111001, 0b0100100, 0b0110000, 0b0011001, 0b0010010, 0b0000010, 0b1111000, 0b0000000, 0b0010000 };


//Common Cathode = 0b gfedcba
//const byte numbers[10] = { 0b0111111, 0b0000110, 0b1011011, 0b1001111, 0b1100110,
//0b1101101, 0b1111101, 0b0000111, 0b1111111, 0b1101111 };


void setup() {
pinMode(Apin, OUTPUT);
pinMode(Bpin, OUTPUT);
pinMode(Cpin, OUTPUT);
pinMode(Dpin, OUTPUT);
pinMode(Epin, OUTPUT);
pinMode(Fpin, OUTPUT);
pinMode(Gpin, OUTPUT);

for (int i = 9; i < 12; i++) {
pinMode(i, OUTPUT);
}

com1 [0] = 1; // will not be read for-next loop
com1 [1] = 2;
com1 [2] = 7;
com1 [3] = 8; // decimal point - for testing reasons, simply assign any number since it will not be read anyway.
com1 [4] = 7;
com1 [5] = 5;
com1 [6] = 0; // will not be read for-next loop
}


void loop() {

for (int i = 1; i < 6; i++) {

if (i != 3){
freq = com1 [i];
lightSegments(numbers[freq]);
if (Anode < 12) {Anode = Anode + 1;}else{ Anode = 9;}
} // i !=3
}// for-next
} //void loop




void lightSegments(byte number) {
j=0; // needed since my segment pins are not sequential
for (int i = 0; i < 7; i++) {
int bit = bitRead(number, i);
// segments connected to Arduino
digitalWrite(j + Apin, bit);
j = j + 2; // needed since my segment pins are not sequential
}// for-next
digitalWrite(Anode, HIGH);
delay(2);
digitalWrite(Anode, LOW);

}

BuzziBi
11-17-2013, 07:20 AM
James.
OOOOOOOOOOO........... ho I envy you your knowledge in programming!
I sat yesterday, trying to understand how to put com1 in a char, logical reasoning told me that this would work, reality hit me in the face and told me that I did'nt understand how to do this. :grin:
Now I'll sit down and try to understand the context and test a little.
I hate to admit it, but I should perhaps start to learn coding from scratch. Instead, I pick up pieces of code, a little here and a little there, and trying to understand how thing works using the error and learn method! :neutral:
I find it hard to find a place that can learn me things in a proper manner.
I like things that are explained this way (happy with even more explanation):


char inData[20]; // Allocate some space for the string<code style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif;">char
inChar=-1; // Where to store the character read
</code>byte index = 0; // Index into array; where to store the character

JMeller
11-17-2013, 11:05 PM
No worries, Roy. I still consider myself a n00b - the more experienced enjoy watching us squirm. :)

A trick I have learned is to not necessarily take snippets; if possible, I take the entire posted (working) code, run it, and get to know it. If it is not your friend already, use the serial monitor... always. This will assist in knowing what the arduino is comprehending. If you know the values expected are not what the arduino is reading, you can adjust your code accordingly.

BuzziBi
11-18-2013, 05:25 AM
Question:
As I'm useing common cathode displays, I have activated the line for Common Cathode, and deactivated the line for the Common Anode displays. (The Segments on pin 2 to pin 8.
When trying the sketch, it will constant light up the A,C,E,G segments, and thats all?
What else is there that I do not see?
I feel really dumb now :roll:


// Arduino digital pins used to light up
// corresponding segments on the LED display
#define Apin 2
#define Bpin 3
#define Cpin 4
#define Dpin 5
#define Epin 6
#define Fpin 7
#define Gpin 8




int Anode = 9;
char com1[7];
int freq = 0; // current display count
int j;


//Common Anode = 0b gfedcba
//const byte numbers[10] = { 0b1000000, 0b1111001, 0b0100100, 0b0110000, 0b0011001, 0b0010010, 0b0000010, 0b1111000, 0b0000000, 0b0010000 };


//Common Cathode = 0b gfedcba
const byte numbers[10] = { 0b0111111, 0b0000110, 0b1011011, 0b1001111, 0b1100110, 0b1101101, 0b1111101, 0b0000111, 0b1111111, 0b1101111 };


void setup() {
pinMode(Apin, OUTPUT);
pinMode(Bpin, OUTPUT);
pinMode(Cpin, OUTPUT);
pinMode(Dpin, OUTPUT);
pinMode(Epin, OUTPUT);
pinMode(Fpin, OUTPUT);
pinMode(Gpin, OUTPUT);

for (int i = 9; i < 12; i++) {
pinMode(i, OUTPUT);
}

com1 [0] = 1; // will not be read for-next loop
com1 [1] = 2;
com1 [2] = 7;
com1 [3] = 8; // decimal point - for testing reasons, simply assign any number since it will not be read anyway.
com1 [4] = 7;
com1 [5] = 5;
com1 [6] = 0; // will not be read for-next loop
}


void loop() {

for (int i = 1; i < 6; i++) {
if (i != 3){
freq = com1 [i];
lightSegments(numbers[freq]);
if (Anode < 12) {Anode = Anode + 1;}else{ Anode = 9;}
} // i !=3
}// for-next
} //void loop


void lightSegments(byte number) {
j=0; // needed since my segment pins are not sequential
for (int i = 0; i < 7; i++) {
int bit = bitRead(number, i);
// segments connected to Arduino
digitalWrite(j + Apin, bit);
j = j + 2; // needed since my segment pins are not sequential
}// for-next
digitalWrite(Anode, HIGH);
delay(2);
digitalWrite(Anode, LOW);
}

JMeller
11-18-2013, 07:16 AM
Two things:
In the void lightSegments(byte number) method, it is still setup for common Anode. Change to common Cathode:
digitalWrite(Anode, LOW);
delay(2);
digitalWrite(Anode, HIGH);

Secondly, remove my offsets. I had to use j because my segment pins were 31(a), 33(b), 35(c), etc...
remove j = 0;
change digitalWrite(j + Apin, bit); to digitalWrite(Apin, bit);
remove j = j + 2;

After changing the items listed above, you should be good to go!

BuzziBi
11-18-2013, 01:21 PM
Like this?
Now the only segment that lights, is the A segment. And only on the #9 pin (common cathode)
If I change the: digitalWrite(Apin, bit) to digitalWrite(Bpin, bit) the B-segment ligts up, and so on with the other segments :D


// Arduino digital pins used to light up
// corresponding segments on the LED display
#define Apin 2
#define Bpin 3
#define Cpin 4
#define Dpin 5
#define Epin 6
#define Fpin 7
#define Gpin 8




int Anode = 9;
char com1[7];
int freq = 0; // current display count
int j;


//Common Cathode = 0b gfedcba
const byte numbers[10] = { 0b0111111, 0b0000110, 0b1011011, 0b1001111, 0b1100110, 0b1101101, 0b1111101, 0b0000111, 0b1111111, 0b1101111 };




void setup() {
pinMode(Apin, OUTPUT);
pinMode(Bpin, OUTPUT);
pinMode(Cpin, OUTPUT);
pinMode(Dpin, OUTPUT);
pinMode(Epin, OUTPUT);
pinMode(Fpin, OUTPUT);
pinMode(Gpin, OUTPUT);

for (int i = 9; i < 12; i++) {
pinMode(i, OUTPUT);
}

com1 [0] = 1; // will not be read for-next loop
com1 [1] = 2;
com1 [2] = 7;
com1 [3] = 8; // decimal point - for testing reasons, simply assign any number since it will not be read anyway.
com1 [4] = 7;
com1 [5] = 5;
com1 [6] = 0; // will not be read for-next loop
}




void loop() {

for (int i = 1; i < 6; i++) {

if (i != 3){
freq = com1 [i];
lightSegments(numbers[freq]);
if (Anode < 12) {Anode = Anode + 1;}else{ Anode = 9;}
} // i !=3
}// for-next
} //void loop


void lightSegments(byte number) {
for (int i = 0; i < 7; i++) {
int bit = bitRead(number, i);
// segments connected to Arduino
digitalWrite(Apin, bit);
}// for-next
digitalWrite(Anode, LOW);
delay(2);
digitalWrite(Anode, HIGH);
}

JMeller
11-18-2013, 06:29 PM
Ah, yes. I was in a bit of hurry this morning and overlooked why I used Apin for my sketch.

Yours should change from:
digitalWrite(Apin, bit);
to
digitalWrite(i +2, bit);

The reason is because your segments start at pin2. With i starting at 0, 0 + 2 = 2 (pin2), 1 + 2 = 3 (pin3), and so on until i < 7 ( i +2 = pin8 ).

JMeller
11-18-2013, 10:31 PM
Hey Roy. I thought I would share this with you:
You can dim or brighten the display by simply modifying the delays.

Common Anode Example:

For a dim display -
digitalWrite(Anode, HIGH);
delayMicroseconds(2);
digitalWrite(Anode, LOW);
delayMicroseconds(1998 );

For full brightness -
digitalWrite(Anode, HIGH);
delayMicroseconds(2000);
digitalWrite(Anode, LOW);
delayMicroseconds(0);

This just hit me out of the blue and it solved one of the things that has been pestering me for some time.

Enjoy!

BuzziBi
11-19-2013, 05:53 AM
Awesome You! :D This time it displays the freq. that I write in the

com1 [0] = 1; // will not be read for-next loop
com1 [0] = 1; // will not be read for-next loop
com1 [1] = 2;
com1 [2] = 7;
com1 [3] = 8; // decimal point - for testing reasons, simply assign any number since it will not be read anyway.
com1 [4] = 7;
com1 [5] = 5;
com1 [6] = 0; // will not be read for-next loop
}} And changes if I writes a different Freq.

I saw that delayMicroseconds in that SSD watch code. I even changed the value and saw the segments dim. ( because of my emminent coding skills ) I thought I wrote a bug un the code, did'nt understand its real function :cool:

EDIT:
Then I got an idea. Instead of the variable resistor to dim the 1602 LCD's, one can use a push button.
The code states that with, one press, continue to the next value (which dims more). Eg. 4 values ​​with different brightness. When you reach the end of the set values. start again, at the higest value.

BuzziBi
11-19-2013, 06:47 AM
I have now tested the code. It now displays the 2.,3.,4. and 5. digit on my " Five Digit LED Seven Segment Display.
Next Step: If I use 2 pieces of (Five Digit LED Seven Segment Displays), a dual Rotary Encoder to change MHZ & KHZ and a pushbutton for Active/Standby.
What I imagine is:
I change the Freq. with the Encoder, the freq. set by the encoder, shows up in the #2 (Five Digit LED Seven Segment Display- Standby dislay). Now, when I hit the ACT/STBY button, the freq. on the #2 display, shows up in the #1 (Five Digit LED Seven Segment Display- Active display)
I noticed that both the Link2fs inOut and the Multi, has com1 s/b. Is there a place where code for this use is written?



// Arduino digital pins used to light up
// corresponding segments on the LED display
#define Apin 2
#define Bpin 3
#define Cpin 4
#define Dpin 5
#define Epin 6
#define Fpin 7
#define Gpin 8


int j1;


int Anode = 9;
char com1[7];
int freq = 0; // current display count


//Common Anode = 0b gfedcba
//const byte numbers[10] = { 0b1000000, 0b1111001, 0b0100100, 0b0110000, 0b0011001, 0b0010010, 0b0000010, 0b1111000, 0b0000000, 0b0010000 };


//Common Cathode = 0b gfedcba
const byte numbers[10] = { 0b0111111, 0b0000110, 0b1011011, 0b1001111, 0b1100110, 0b1101101, 0b1111101, 0b0000111, 0b1111111, 0b1101111 };


void setup() {

Serial.begin(115200);

pinMode(Apin, OUTPUT);
pinMode(Bpin, OUTPUT);
pinMode(Cpin, OUTPUT);
pinMode(Dpin, OUTPUT);
pinMode(Epin, OUTPUT);
pinMode(Fpin, OUTPUT);
pinMode(Gpin, OUTPUT);

for (int i = 9; i < 13; i++) {
pinMode(i, OUTPUT);
}
}


void loop() {


if (Serial.available() > 0) {
j1 = Serial.read();
if (j1 == 'd'){ // Found the reading "Com1 frequency"
delay (1);
com1 [0] = (Serial.read()-48); // aBc.def
com1 [1] = (Serial.read()-48); // aBc.def
com1 [2] = (Serial.read()-48); //abC.def
com1 [3] = (Serial.read()-48); //decimal read
com1 [4] = (Serial.read()-48); //abc.Def
com1 [5] = (Serial.read()-48); //abc.dEf
com1 [6] = (Serial.read()-48); //abc.deF
}
}
for (int i = 1; i < 6; i++) {
if (i != 3){
freq = com1 [i];
lightSegments(numbers[freq]);
if (Anode < 12) {Anode = Anode + 1;}else{ Anode = 9;}
} // i !=3
}// for-next
} //void loop


void lightSegments(byte number) {
for (int i = 0; i < 7; i++) {
int bit = bitRead(number, i);
// segments connected to Arduino
digitalWrite(i + 2, bit);
}// for-next
digitalWrite(Anode, LOW);
delay(2);
digitalWrite(Anode, HIGH);
}

JMeller
11-19-2013, 08:22 AM
For dimming, I plan to use a potentiometer on the PWMs to adjust the delays accordingly.

I was preparing a response to the active/stby bit until I realized it was becoming a hairy mess to read & follow without actually modifying the code. Then, without testing it myself, may lead you astray... again.

I'll add another display to my test bench this evening and post any results... unless you beat me to it.

BuzziBi
11-19-2013, 09:13 AM
I have to do some soldering for my next display before I can test, so I doubt that I'll beat you. I'm going to a birthday party for a relative this evening, so I need to give priority to that.
(Unfortunately, once you have such fun with Arduino :) )


EDIT:
Can I use pin 9, 10, 11, 12 and 13
to display


com1 [0] on pin 9
com1 [1] on pin 10
com1 [2] on pin 11
com1 [3] = (Serial.read()-48); //decimal read
com1 [4] on pin 12
com1 [5] on pin 13
com1 [6] = (Serial.read()-48); //abc.deF

I have tryed but I can't get it to work :(

JMeller
11-19-2013, 09:30 PM
Roy,
To answer your question, "Can I use pin 9, 10, 11, 12 and 13 to display ...", the answer is NO. Why? It is because the specific array element contains a value, i.e. "2". You must parse the value into single segments for 'a' thru 'g' via the byte value. Once the byte value is assigned, it fetches the 'void lightSegments(byte number)' method; in the method, it reads the byte value from right to left and then it writes the segment high or low - depending on the value 1 or 0, respectively. In the same method that it writes the 'a' thru 'g' segments, it turns ON your cathode pin (i.e. pin 9) for a period longer than it is OFF so your eyes can see the number.

Now for the second display with working and tested code:
Note the items highlighted. This was for my display for three digit extraction. Therefore, you will have to change the Anode to Cathode values and change pin assignments.


// Arduino digital pins used to light up
// corresponding segments on the LED display
#define Apin 30
#define Bpin 32
#define Cpin 34
#define Dpin 36
#define Epin 38
#define Fpin 40
#define Gpin 42


int com1SBYAnode = 6; // set first pin of first digit of Standby
char com1SBY[7];
int com1freqSBY = 0; // current display freq
boolean com1SBYdisp;


int com1ACTIVEAnode = 9; // set first pin of first digit of ACTIVE
char com1ACTIVE[7];
int com1freqACTIVE = 0; // current display freq
boolean com1ACTIVEdisp;






int j;


//Common Anode = 0b gfedcba
const byte numbers1[10] = { 0b1000000, 0b1111001, 0b0100100, 0b0110000, 0b0011001, 0b0010010, 0b0000010, 0b1111000, 0b0000000, 0b0010000 }; < - delete




//Common Cathode = 0b gfedcba
//const byte numbers[10] = { 0b0111111, 0b0000110, 0b1011011, 0b1001111, 0b1100110,
//0b1101101, 0b1111101, 0b0000111, 0b1111111, 0b1101111 };




void setup() {
//Initialize Segments
pinMode(Apin, OUTPUT);
pinMode(Bpin, OUTPUT);
pinMode(Cpin, OUTPUT);
pinMode(Dpin, OUTPUT);
pinMode(Epin, OUTPUT);
pinMode(Fpin, OUTPUT);
pinMode(Gpin, OUTPUT);

//Initialize Anodes (or Cathodes)
// My anodes start at 6 and end at 11
for (int i = 6; i < 12; i++) {
pinMode(i, OUTPUT);
}


com1ACTIVE [0] = 1; // will not be read for-next loop
com1ACTIVE [1] = 2;
com1ACTIVE [2] = 7;
com1ACTIVE [3] = 8; // decimal point - for testing reasons, simply assign any number since it will not be read anyway.
com1ACTIVE [4] = 7;
com1ACTIVE [5] = 5;
com1ACTIVE [6] = 0; // will not be read for-next loop


com1SBY [0] = 1; // will not be read for-next loop
com1SBY [1] = 8;
com1SBY [2] = 2;
com1SBY [3] = 8; // decimal point - for testing reasons, simply assign any number since it will not be read anyway.
com1SBY [4] = 6;
com1SBY [5] = 3;
com1SBY [6] = 0; // will not be read for-next loop
}




void loop() {
// read Com1 Standby array & fetch "void lightSegments(byte number)"
// increase com1SBYAnode digit pin
// then...
// read Com1 Active array & fetch "void lightSegments(byte number)"
// increase com1ACTIVEAnode digit pin
for (int i = 1; i < 5; i++) {
// change i < 5 to i < 6; for my setup, I am only reading to array [4]

if (i != 3){

//Standby freq has lowest starting anode pin(i.e., 6), therefore
// it is assigned first.
com1freqSBY = com1SBY ;
com1SBYdisp = true;
lightSegments(numbers1[com1freqSBY]);

if (com1SBYAnode < 8) {com1SBYAnode = com1SBYAnode + 1;}else{ com1SBYAnode = 6;}
com1SBYdisp = false;
// my [I]StandBy has only (3) anodes - 6,7,& 8; change accordingly

//Active has highest starting anode pin(i.e., 9), therefore
// it is assigned last.
com1freqACTIVE = com1ACTIVE ;
com1ACTIVEdisp = true;
lightSegments(numbers1[com1freqACTIVE]);

if (com1ACTIVEAnode < 11) {com1ACTIVEAnode = com1ACTIVEAnode + 1;}else{ com1ACTIVEAnode = 9;}
com1ACTIVEdisp = false;
// my [I]Active has only (3) anodes - 9,10,& 11; change accordingly
} // i !=3
}// for-next
} //void loop








void lightSegments(byte number) {
j=0; // needed since my segment pins are not sequential < - delete
for (int i = 0; i < 7; i++) {
int bit = bitRead(number, i);
// segments connected to Arduino
digitalWrite(j + Apin, bit);
j = j + 2; // needed since my segment pins are not sequential < - delete
}// for-next


//Standby freq has lowest starting anode pin(i.e., 6), therefore
// it is written first.
if (com1SBYdisp == true){
digitalWrite(com1SBYAnode, HIGH);
delayMicroseconds(400);
digitalWrite(com1SBYAnode, LOW);
//delayMicroseconds(1); // Must be >0
} // end com1SBYdisp == true

//Active has highest starting anode pin(i.e., 9), therefore
// it is written last.
if (com1ACTIVEdisp == true){
digitalWrite(com1ACTIVEAnode, HIGH);
delayMicroseconds(400);
digitalWrite(com1ACTIVEAnode, LOW);
//delayMicroseconds(1); // Must be >0
}// end com1ACTIVEdisp == true
}


The code will light up the active & standby frequencies on your displays. In your Link2FS code, simply create a button to tell Link2FS to swap frequencies. When Link2FS receives the command, it will automatically send the updated Active and Standby frequencies back to the arduino.

BuzziBi
11-20-2013, 04:42 AM
I guess I need to order new SSD's to get this to work! I use the 5 digit SSDs and this complicates things for me. Thinking I put the project on the shelf for new SSDs to arrive.

BuzziBi
11-27-2013, 08:13 AM
Hi James.
I've vot my new SSDs today, and will do the soldering later this evening.
I just wanted to take a quick look at the code before starting.
Here's something I do not understand.

//Common Anode = 0b gfedcba
const byte numbers1[10] = {
0b1000000,
0b1111001,
0b0100100,
0b0110000,
0b0011001,
0b0010010,
0b0000010,
0b1111000,
0b0000000,
0b0010000 }; < - delete
Why the < - delete?

EDIT: You may forget that question :oops:

JMeller
11-27-2013, 04:34 PM
If you look at the original code, there were two const byte arrays - one of which was commented out. The <- delete was a flag for you to delete the Common Anode byte array which works for me... the one you just posted. The other one was modified to work with your LEDs - Common Cathode.

Happy soldering! :)

BuzziBi
11-28-2013, 08:33 AM
Hi James.
I'm about to give up!
There is something (or all) about this code that I do not understand. :(
I've even tried with the pinout that you have used (Using the line for the chatode displays.), but no luck.

And second, what will happen, let say, if I uses pin 22 to 28 for segments, and the cathodes from 29 and up
I tryed that with the only bit of code that I've got to work,the code below, but did not work. What is it that I'm not seeing?

// Arduino digital pins used to light up// corresponding segments on the LED display com1
#define Apin 2
#define Bpin 3
#define Cpin 4
#define Dpin 5
#define Epin 6
#define Fpin 7
#define Gpin 8


int j1; // Reads from Link2fs inOut


int Anode = 9; //Uses Anode on pin 9,10,11,12.
char com1[7];
int freq = 0; // current display count


//Common Anode = 0b gfedcba
//const byte numbers[10] = { 0b1000000, 0b1111001, 0b0100100, 0b0110000, 0b0011001, 0b0010010, 0b0000010, 0b1111000, 0b0000000, 0b0010000 };


//Common Cathode = 0b gfedcba
const byte numbers[10] = { 0b0111111, 0b0000110, 0b1011011, 0b1001111, 0b1100110, 0b1101101, 0b1111101, 0b0000111, 0b1111111, 0b1101111 };


void setup() {

Serial.begin(115200);

pinMode(Apin, OUTPUT);
pinMode(Bpin, OUTPUT);
pinMode(Cpin, OUTPUT);
pinMode(Dpin, OUTPUT);
pinMode(Epin, OUTPUT);
pinMode(Fpin, OUTPUT);
pinMode(Gpin, OUTPUT);

for (int i = 9; i < 13; i++) {
pinMode(i, OUTPUT);
}

}


void loop() {


if (Serial.available() > 0) {
j1 = Serial.read();
if (j1 == 'd'){ // Found the reading "Com1 frequency"
delay (1);
com1 [0] = (Serial.read()-48); // aBc.def
com1 [1] = (Serial.read()-48); // aBc.def
com1 [2] = (Serial.read()-48); //abC.def
com1 [3] = (Serial.read()-48); //decimal read
com1 [4] = (Serial.read()-48); //abc.Def
com1 [5] = (Serial.read()-48); //abc.dEf
com1 [6] = (Serial.read()-48); //abc.deF
}
}
for (int i = 1; i < 6; i++) {
if (i != 3){
freq = com1 [i];
lightSegments(numbers[freq]);
if (Anode < 12) {Anode = Anode + 1;}else{ Anode = 9;}
} // i !=3
}// for-next
} //void loop


void lightSegments(byte number) {
for (int i = 0; i < 7; i++) {
int bit = bitRead(number, i);
// segments connected to Arduino
digitalWrite(i + 2, bit);
}// for-next
digitalWrite(Anode, LOW);
delay(2);
digitalWrite(Anode, HIGH);
}

JMeller
11-28-2013, 10:26 AM
Roy,
Your code is correct. I did a copy/paste into my sketch, modified the pins to match my setup, and assigned static values to the com1 array. So its verified that your coding is correct. Is this the current sketch in your arduino? In this sketch, the segments are on pins 2-8 and the cathodes are on 9-12. Are you getting any segments to light? If so, what is your com1 freq from Link2Fs and what is the arduino trying to display?

As a test and a base platform, comment out items related to the serial read from Link2FS and assign static values to the com1 array like so:
com1 [0] = '3' - 48;
com1 [1] = '4' - 48;
com1 [2] = '5' - 48;
com1 [3] = '0' - 48;
com1 [4] = '6' - 48;
com1 [5] = '7' - 48;
com1 [6] = '8' - 48;

If this still does not work, whip up a simple test sketch to manually write segment pins high and a single cathode; this will verify your pin connections and assignments. Verify each digit by manually writing the respective cathode HIGH and re-download the test sketch.

After confirming the numbers display properly, reinsert the lines for Link2FS serial reads.

Good Luck!

BuzziBi
11-28-2013, 12:03 PM
Sorry James, I may have confused you.
The code I posted last, is working!
However, If I am to make room for the 7 segment pins and my anode pins
(8 pieces, 4 to the com1 Active, and 4 to the com1 S/B), I need to move things in the sketch. But if I Use the last posted code, changes the segmente to:
#define Apin 22
#define Bpin 23
#define Cpin 24
#define Dpin 25
#define Epin 26
#define Fpin 27
#define Gpin 28

and the Anode pins
to:
int Anode = 29; //Uses Anode on pin 29,30,31,32 (for the com1 Active)

Then I mess it up!
Terefor if I should use youre last posted code for the Active / SBY displays, I have to use other pinoute than the one You posted.

Enyhow, I could not get the code you posted to work, even if I changed my pinout to match the pinout that You were using :(

I know, I'm a klutz :)

JMeller
11-28-2013, 02:35 PM
Below I used my working code from post #38 and highlighted the items I changed to make it work with your setup. If you have questions why I changed it to what I did, feel free to ask; if you continue to muddle through without knowing why, you'll have problems later.





// Arduino digital pins used to light up
// corresponding segments on the LED display
#define Apin 22
#define Bpin 23
#define Cpin 24
#define Dpin 25
#define Epin 26
#define Fpin 27
#define Gpin 28


int com1SBYAnode = 29; // set first pin of first digit of Standby
char com1SBY[7];
int com1freqSBY = 0; // current display freq
boolean com1SBYdisp;


int com1ACTIVEAnode = 33; // set first pin of first digit of ACTIVE
char com1ACTIVE[7];
int com1freqACTIVE = 0; // current display freq
boolean com1ACTIVEdisp;






int j;


//Common Anode = 0b gfedcba
//const byte numbers1[10] = { 0b1000000, 0b1111001, 0b0100100, 0b0110000, 0b0011001, 0b0010010, 0b0000010, 0b1111000, 0b0000000, 0b0010000 };




//Common Cathode = 0b gfedcba
const byte numbers[10] = { 0b0111111, 0b0000110, 0b1011011, 0b1001111, 0b1100110,
//0b1101101, 0b1111101, 0b0000111, 0b1111111, 0b1101111 };




void setup() {
//Initialize Segments
pinMode(Apin, OUTPUT);
pinMode(Bpin, OUTPUT);
pinMode(Cpin, OUTPUT);
pinMode(Dpin, OUTPUT);
pinMode(Epin, OUTPUT);
pinMode(Fpin, OUTPUT);
pinMode(Gpin, OUTPUT);

//Initialize Anodes (or Cathodes)
// My anodes start at 6 and end at 11
for (int i = 29; i < 37; i++) {
pinMode(i, OUTPUT);
}


com1ACTIVE [0] = 1; // will not be read for-next loop
com1ACTIVE [1] = 2;
com1ACTIVE [2] = 7;
com1ACTIVE [3] = 8; // decimal point - for testing reasons, simply assign any number since it will not be read anyway.
com1ACTIVE [4] = 7;
com1ACTIVE [5] = 5;
com1ACTIVE [6] = 0; // will not be read for-next loop


com1SBY [0] = 1; // will not be read for-next loop
com1SBY [1] = 8;
com1SBY [2] = 2;
com1SBY [3] = 8; // decimal point - for testing reasons, simply assign any number since it will not be read anyway.
com1SBY [4] = 6;
com1SBY [5] = 3;
com1SBY [6] = 0; // will not be read for-next loop
}




void loop() {
// read Com1 Standby array & fetch "void lightSegments(byte number)"
// increase com1SBYAnode digit pin
// then...
// read Com1 Active array & fetch "void lightSegments(byte number)"
// increase com1ACTIVEAnode digit pin
for (int i = 1; i < 6; i++) { // reads com1SBY [1] thru com1SBY [5] ; reads com1ACTIVE [1] thru com1ACTIVE [5]
// change i < 5 to i < 6; for my setup, I am only reading to array [4]

if (i != 3){

//Standby freq has lowest my starting anode pin(i.e., 6), therefore
// it is assigned first.
com1freqSBY = com1SBY [i];
com1SBYdisp = true;
lightSegments(numbers1[com1freqSBY]);

if (com1SBYAnode < 32) {com1SBYAnode = com1SBYAnode + 1;}else{ com1SBYAnode = 29;}
com1SBYdisp = false;
// my StandBy has only (3) anodes - 6,7,& 8; change accordingly

//Active has highest starting anode pin(i.e., 9), therefore
// it is assigned last.
com1freqACTIVE = com1ACTIVE [i];
com1ACTIVEdisp = true;
lightSegments(numbers1[com1freqACTIVE]);

if (com1ACTIVEAnode < 36) {com1ACTIVEAnode = com1ACTIVEAnode + 1;}else{ com1ACTIVEAnode = 33;}
com1ACTIVEdisp = false;
// my Active has only (3) anodes - 9,10,& 11; change accordingly
} // i !=3
}// for-next
} //void loop








void lightSegments(byte number) {
// j=0; // needed since my segment pins are not sequential
for (int i = 0; i < 7; i++) {
int bit = bitRead(number, i);
// segments connected to Arduino
//digitalWrite(j + Apin, bit);
digitalWrite(i + Apin, bit);
// j = j + 2; // needed since my segment pins are not sequential
}// for-next


//Standby freq has lowest starting anode pin(i.e., 6), therefore
// it is written first.
if (com1SBYdisp == true){
// digitalWrite(com1SBYAnode, HIGH);
digitalWrite(com1SBYAnode, LOW);
delayMicroseconds(400);
//digitalWrite(com1SBYAnode, LOW);
digitalWrite(com1SBYAnode, HIGH);
//delayMicroseconds(1); // Must be >0
} // end com1SBYdisp == true

//Active has highest starting anode pin(i.e., 9), therefore
// it is written last.
if (com1ACTIVEdisp == true){
//digitalWrite(com1ACTIVEAnode, HIGH);
digitalWrite(com1ACTIVEAnode, LOW);
delayMicroseconds(400);
//digitalWrite(com1ACTIVEAnode, LOW);
digitalWrite(com1ACTIVEAnode, HIGH);
//delayMicroseconds(1); // Must be >0
}// end com1ACTIVEdisp == true
}

BuzziBi
11-28-2013, 03:11 PM
Thank you James for putting up with me.
I finally found out what I did wrong!
I did of course assume that you had made a mistake (SORRY JAMES!). :D
So I changed the

if (com1ACTIVEAnode < 11) {com1ACTIVEAnode = com1ACTIVEAnode + 1;}else{ com1ACTIVEAnode = 9;}

in to this:

if (com1ACTIVEAnode < 12) {com1ACTIVEAnode = com1ACTIVEAnode + 1;}else{ com1ACTIVEAnode = 9;}


assuming that: less than 12 = 11 would be right!
Well finaly sorted that out, I tested the code and noticed somthing odd!
I tryed You're last code with the pinout from 22 to 36, and it works.........almost!
When changing the third digit in (you're post #38 (http://www.mycockpit.org/forums/showthread.php?t=26959&p=144043&viewfull=1#post144043)),
com1SBY [0] = 0; // will not be read for-next loop
com1SBY [1] = 1;
com1SBY [2] = 8;
com1SBY [3] = 0; // decimal point - for testing reasons, simply assign any number since it will not be read anyway.
com1SBY [4] = 6; THIS ONE!
com1SBY [5] = 3;
com1SBY [6] = 0; // will not be read for-next loop

the third digit showed incorrect, disabeling one of the segments.

In you're post #45 (http://www.mycockpit.org/forums/showthread.php?t=26959&p=144310&viewfull=1#post144310), the fourth digit on both com1active and com1SBY displays an error.
It does only displays a zero without segment B. and does not change to any other digit!

EDIT: IGNORE THIS POST!
After I posted, I started to think (finally)!
I decided that the fault was at my side, (as usual) and took a look at my soldering. I had swapped two wires. :oops:
You're code works!

BuzziBi
11-29-2013, 02:01 PM
Hi James.
I'm going to ask another question :roll:
I have tested the code with the Link2fs Multi, and it works fine. I just wondered if I had placed things where they should be.
Reading from Link2fs Multi:


void EQUALS(){ // The first identifier was "="
CodeIn = getChar(); // Get the second identifier
switch(CodeIn) {// Now lets find what to do with it

case 'A': //Found for reading the com1 Acive identifier.
com1ACTIVE [0] = (Serial.read()-48); // aBc.def
com1ACTIVE [1] = (Serial.read()-48); // aBc.def
com1ACTIVE [2] = (Serial.read()-48); //abC.def
com1ACTIVE [3] = (Serial.read()-48); //decimal read
com1ACTIVE [4] = (Serial.read()-48); //abc.Def
com1ACTIVE [5] = (Serial.read()-48); //abc.dEf
com1ACTIVE [6] = (Serial.read()-48); //abc.deF
break;

case 'B': //Found for reading the com1 SBY. identifier.
com1SBY [0] = (Serial.read()-48); // aBc.def
com1SBY [1] = (Serial.read()-48); // aBc.def
com1SBY [2] = (Serial.read()-48); //abC.def
com1SBY [3] = (Serial.read()-48); //decimal read
com1SBY [4] = (Serial.read()-48); //abc.Def
com1SBY [5] = (Serial.read()-48); //abc.dEf
com1SBY [6] = (Serial.read()-48); //abc.deF
break;
}
}

I have placed this in the void OTHER


void OTHER(){


for (int i = 1; i < 6; i++) {
if (i != 3){
//Standby freq has lowest my etc....etc.....etc..................
} // i !=3
}// for-next
} // End of void loop


void lightSegments(byte number) {
for (int i = 0; i < 7; i++) {
int bit = bitRead(number, i);
etc....etc.....etc.......................................
}// End off void Lightsegments

What I wondered was whether I should add the lightSegments to the void loop? Or if it has any significance to the code how it is placed?
I have not tried, but wondered if it should be done so?


void loop() {
{INPUTS();} //Check the Simconnect and "keys" section
{OTHER();}// Check for "Other" things to do. (Non extraction stuff)
{lightSegments();}// Check the lightSegments

I tried to switch the frequency from sby SSDs to the active SSDs, by sending "A06" through "SimConnect Inputs" an the frequency swaped from the SBY SSD to the Active SSD, as expected. :p
I am now trying to add code for the NAV1 active and NAV1 SBY. Have not done the soldering for my next SSDs yet, but I let You know how that one goes.

JMeller
11-29-2013, 03:05 PM
Excellent, Roy! It appears your making great strides in your mission.

The lightSegments method must remain a separate method. The reason: it fetches the method via this statement - lightSegments(numbers1[com1freqSBY]); or this one - lightSegments(numbers1[com1freqACTIVE]);
Knowing this, it's ok to keep what you have.

Here is a tip to shorten your com/nav read lines:
case 'A' :
for (int i = 0; i < 6; i++) {com1ACTIVE [i] = (Serial.read()-48 ); break;}

case 'B' :
for (int i = 0; i < 6; i++) {com1SBY [i] = (Serial.read()-48 ); break;}

etc..


Keep up the great work. I'm looking forward to the video of the finished product ! :) :) :)

JM

BuzziBi
11-29-2013, 05:35 PM
Thank you James.
That shortened my com/nav read lines a lot!
Had to move a curly bracket to get it to work, but nice ;)
Also found out that, a "delayMicroseconds(400);" helped at lot avoid errors in reading from Link2fs and writing to the SSDs.


case 'A': //Found for reading the com1 Acive identifier.
delayMicroseconds(400);
for (int i; i < 6; i++) {com1ACTIVE [i] = (Serial.read()-48 );} break;

case 'B': //Found for reading the com1 SBY. identifier.
delayMicroseconds(400);
for (int i; i < 6; i++) {com1SBY [i] = (Serial.read()-48 );} break;

BuzziBi
12-07-2013, 05:05 AM
A small update!
I've got the code for Com1 and NAV1 to work, BUT (There is always a BUT) :evil:
When I read 4 digit from LInk2fs and directly connects the first SSDs to show number one, then directly connect the DP for the third digit, (on com1 Active, Com1 SBY, Nav1 Active and Nav1SBY, to show ie. 118,45) then it is just rubbish!
This contradicts everything I have learned about electronics.
Therefore I now read all of the first five digits from Link2fs, and writes them on all five SSDs. This works but requires 4 additional pins on Arduinocard.
But as I've said earlier, it's not how you do it, but that you reach the target, that's important!
Next will be to connect the buttons for "shift Active / SBY freq" and the rotary encoders for freq.
I will post the result when finished.

JMeller
12-07-2013, 08:18 AM
Yup, that was my fault Roy. I should have paid attention to the 5 digit clusters you were using. The decimal point shouldn't have given you any grief, but I can see how the constant "1" would have messed everything. The big kick out of it for me was that you knew how to fix it - at the expense of 4 additional pins.

Hint: if you are wiring to normally open non-latching pushbuttons, i.e. your 0 - 7 buttons, you can recapture those pins to charlieplex the status of those push buttons by using a matrix design while also driving your cathodes. Oh, now we're complicating things! ;)

BuzziBi
12-07-2013, 10:12 AM
I think you are having fun at my expense young man! :p
No, I let it be for now. Now I have to get things together so that I can fly in the Christmas season.
I am afraid that I later will be investing in something that can drive the displays without using so many pins. Maby a Max(something)doda-like thingy :D
I have installed new switches for all lights, deicing, pitotheat and engines, they have to be connected. So it gets a bit to do before Christmas.
Then I have to tear down all Edge Wise Meters, that I made for instrumentation, because I forgot to install backlight :roll:
I'm going to do a try on making a vertical speed instrument also. Have som smal servos laying, who is screaming of loneliness.

EDIT: I have ordered two new Arduino card, so I'm going to try me on a run of four cards.
Jim! You must expand Link2fs, so we can run the program with, say 10 cards. :D
I understand that we can run Link2fs multiple times but have not tried it.
I'm a little worried about hardware capacity.
Is there a manual for running Link2fs on the network, on a second computer?

JMeller
12-08-2013, 09:10 AM
Hehe, yeh... I couldn't resist the placing my elbow in your side. :)
But yes, if you can find the color and size you want (at reasonable price), a serial display is the way to go. But for myself, I enjoy the experimentation. For that very reason, my personal pit building progress has been lackluster.

As for running multiple L2FS programs, you can do so with no problems.

Great progress, Roy.
Cheers!

BuzziBi
12-08-2013, 04:27 PM
I promised to show/brag about the final product, so ........
I'm attaching the sketsh for my project, it is perhaps poorly remarked, but I expect that if someone likes to build a com/nav radio, they will find what they need in the thread.
First of all. Yes the displays are green! This is due to an incorrect order made ​​by ... yes you guessed it, ME! :roll:
Maybe I'll change it later if I am unhappy with them.
The video is taken with mobile and radio is not even installed in the simulator, but as you see, it works.
A BIG Thanks to you James, for all your help with the project.
PS! James. No bullying of my code, but if you see something weird, a note would be fine. :D

http://www.youtube.com/watch?v=vhQRwn_oiBQ&feature=youtu.be

BuzziBi
12-09-2013, 09:06 AM
Attached is the wiring of my com/nav radio, made with free software from Fritzing (http://fritzing.org/download/).

Jim NZ
12-12-2013, 11:21 PM
Now that's really interesting Buzzi ,,, One of the things I really fall down on is the visual building of the actual panel.

I'm extremely temped to get one of the commercial available panels along with all the visual bits (LED's etc) and build something from there ,, it would be a neat project.

Well done and thanks for posting it Buzzi ,,, Jim

Edit ,,, Yes you can run multipile copys of the Multi if you have more than 3 cards and also ,,, at the moment I haven't added any network stuff in it yet.

JMeller
12-22-2013, 05:53 PM
While searching for a 4 digit 7-seg Eagle library, I stumbled across this and thought I would share. I haven't toyed with it, yet.
http://playground.arduino.cc/Main/SevenSegmentLibrary

BuzziBi
12-22-2013, 07:37 PM
Hello James.
While you were working at the hardest with the new radio code, I sat wondering if I should try writing a library for 7seg.displays. I read a little about how to create a library but then it hit me, Googel 7seg. library.
Whether it was the same link that you posted here, I do not remember. No matter the library I found (for 4 digits), did not work!
I tried the link you posted but, the link to the download does not work. Here's another link for a download!(Have not tryed it!)
https://github.com/sparkfun/SevSeg/tree/master/Libraries/SevSeg

Anyway, I think you covered most of the same things with your code. The difference as I see it, when using the library, you will see less of the actual code that is needed to get it to work, in the sketch, because most of of the code is hidden in the library. Or am I wrong? :D

JMeller
12-22-2013, 09:24 PM
Yup, a library prevents duplication and tidies up the sketch. My favorite summary - "It's less hair to wash, comb, etc." :)

Perhaps I'll build a versatile seven seg library if that one doesn't work - the links were the same. I've built a couple libraries already. One of which was for the Multi - post #62. (http://www.mycockpit.org/forums/showthread.php?t=25693&page=7) If I do, I'll post it on this thread.

BuzziBi
01-26-2014, 09:33 AM
I was made aware of an error in designations/remarking in the code.
So I upload a new code for this radio.

Jim NZ
01-29-2014, 04:13 AM
Well I finally remembered to download your code Buzzi (but I don't have any LED displays) and what wonderful code !!!!

Even I could understand it and it's very well laid out.

Anyone contemplating using 7 seg displays should have a look-see at how you done that.

Very educational and easy to follow. :)

Thanks Buzzi ,,, Jim

BuzziBi
01-29-2014, 11:31 AM
As for the code: The credit should be given to the right man, who is James!
I only pushed the results out of him! :D
And James is right when it comes Link2fs. It is not so easy to see what I am most passionate about longer. Link2fs or FSX!
I experienced anything else weird! Some of the latest verson of Fritzing has been released with inverted numbers and designations on the pins, on some of the components. I am developing a new wiring diagram which I will upload. I Hope I will manage to get it more clearly next time and that Fritzing gets rid of these things in the future.
(To draw a wiring diagram is really boring!) :roll:


EDIT: Uploaded corrected Fritzing wiring and code in the same zip file.

librapage
03-06-2016, 04:46 AM
Hi BuzziBi:
I try to connect wiring diagram but i am Failed, it is not working.
(jest try com1 SBY & ACTIVE first ) can you help me ! thank!

brianm
09-18-2016, 01:04 PM
Maybe something like this? https://www.youtube.com/watch?v=bROOQ42Tfqs

Matti V
09-18-2016, 02:05 PM
fantastic, have u schematic and code too. i want build same. <3

BuzziBi
10-12-2016, 10:55 AM
Matti V
See comment/post #62 Ther is the link to the schenatic which is done with fritzing.

Matti V
10-12-2016, 06:47 PM
i no can open fritzing and my computer have full ,not can install any new program :(
thanks inform.

brianm
11-26-2016, 08:55 PM
Matti V, you inspired me. I am beginning to document my project builds at www.simav8.com (http://www.simav8.com). What you want is NOT there just yet though, sorry. The SIMCMP project is fully documented though (hardware, Arduino code, Link2FS setup and VB.NET to FSUIPC if you are so inclined). I'll be working on SIMRadio over holidays.