Go Down

### Topic: four 7 segments and 4 shift registers, pineapple library (Read 2261 times)previous topic - next topic

#### taswanj

##### Aug 03, 2012, 09:38 pm
End project is simply a clock displayed on four 7 segments data pulled from a GPS unit. I will be adding another 2 digits with a separate array to display temperature.

I've got one 7 segment and one shift register going and I seem to understand how it controls the 8 outputs pretty well but I can't seem to understand how to integrate additional 7 segments and shift registers using a particular library. I'm using the Pineapple library which makes using one of these very simple.

Here's a link to the .cpp file for the library. Of course I tried to simply change the number of registers being used in the Serial read sketch but that did not cause the second digit to light up with anything. I'm sure there is something simple I'm not understanding to write the correct numeral array.

Here's the library.   https://github.com/Qtechknow/Arduino-Libraries/blob/master/Pineapple/Pineapple.cpp

Can someone help me understand a little better how to integrate more shift registers and digits using this library?

I'm testing digits using this code.
Quote
/*  PineappleSerial

When you type in a number between 0 and 9 on the serial monitor, the 7-segment
display, driven by the Pineapple library, will light up correspondingly.
Credits go to Qtechknow (Quin), Adam Meyer of Bildr, and Arduino Forum member
lloyddean.

created 08 May 2012
*/

#include "Pineapple.h"

Pineapple pineapple;      // initialize the library

int serial = 4;              // serial pin
int registerClock = 3;       // register clock pin
int serialClock = 2;         // serial clock pin

int numberofRegisters = 1;   // just one register

void setup() {
// Segments A, B, C, D, E, F, G, DP pin numbers on the shift register
pineapple.segmentPins(0, 1, 2, 3, 4, 5, 6, 7, HIGH);  // set high for common anode, and
pineapple.registerPins(serial, registerClock, serialClock, numberofRegisters);    // low for common cathode display
Serial.begin(9600);     // begin serial communication
}

void loop() {

pineapple.clear();

if(Serial.available() > 0) {    // is there anything on the serial monitor?

switch (ch) {        // start the switch case statement

case '0':            // if we receive a 0, print a 0
pineapple.write(0);
break;

case '1':
pineapple.write(1);  // if we receive a 1, print a 1
break;

case '2':            // if we receive a 2, print a 2 and so on.
pineapple.write(2);
break;

case '3':
pineapple.write(3);
break;

case '4':
pineapple.write(4);
break;

case '5':
pineapple.write(5);
break;

case '6':
pineapple.write(6);
break;

case '7':
pineapple.write(7);
break;

case '8':
pineapple.write(;
break;

case '9':
pineapple.write(9);
break;

default:             // default is to clear the display
pineapple.clear();
}
}
delay(1000);       // don't go too fast!
}

#### florinc

#1
##### Aug 05, 2012, 03:08 am
This
Code: [Select]
`    switch (ch) {        // start the switch case statement           case '0':            // if we receive a 0, print a 0      pineapple.write(0);      break;            case '1':      pineapple.write(1);  // if we receive a 1, print a 1      break;            case '2':            // if we receive a 2, print a 2 and so on.      pineapple.write(2);      break;            case '3':      pineapple.write(3);      break;            case '4':      pineapple.write(4);      break;            case '5':      pineapple.write(5);      break;            case '6':      pineapple.write(6);      break;            case '7':      pineapple.write(7);      break;            case '8':      pineapple.write(;      break;            case '9':      pineapple.write(9);      break;            default:             // default is to clear the display      pineapple.clear();    }`

can be replaced with this:

Code: [Select]
`if (ch >=0 && ch <= 9)      pineapple.write(ch);else      pineapple.clear();`

Go Up