Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "SevSeg.h"
- //Time Global variables
- unsigned long timer;
- int deciSecond = 0;
- //int lastMillis,lastMillis2 = millis();
- int value=100;
- int value2=4;
- const int ledPin1 = 14; //Blue Channel LED
- const int ledPin2 = 15; // Green Value LED
- char value_buffer1[4];
- char value_buffer2[4];
- // DISPLAY CODE
- SevSeg myDisplay;
- void setup() {
- pinMode ( ledPin1, OUTPUT );
- pinMode ( ledPin2, OUTPUT );
- int displayType = COMMON_CATHODE; //Your display is either common cathode or common anode
- //Declare what pins are connected to the GND pins (cathodes)
- int digit1 = 11; //Display Pin 12
- int digit2 = 12; //Display Pin 9
- int digit3 = 13; //Display Pin 8
- int digit4 = 19; //Display Pin x
- //Declare what pins are connected to the segments (anodes)
- int segA = 3; //Display Pin 11
- int segB = 4; //Display Pin 7
- int segC = 5; //Display Pin 4
- int segD = 6; //Display Pin 2
- int segE = 7; //Display Pin 1
- int segF = 8; //Display Pin 10
- int segG = 9; //Display Pin 5
- int segDP= 10; //Display Pin 3
- int numberOfDigits = 3; //Do you have a 1, 2 or 4 digit display?
- myDisplay.Begin(displayType, numberOfDigits, digit1, digit2, digit3, digit4, segA, segB, segC, segD, segE, segF, segG, segDP);
- myDisplay.SetBrightness(100); //Set the display to 100% brightness level
- //Time Variables
- timer = millis();
- }
- void loop()
- {
- sprintf(value_buffer1, "%03d", value);
- myDisplay.DisplayString(value_buffer1, 0);
- digitalWrite(ledPin1, HIGH); // Turn on the LED
- digitalWrite(ledPin2, LOW); // Turn off the LED
- delay(2000);
- sprintf(value_buffer2, "%03d", value2);
- myDisplay.DisplayString(value_buffer2, 0);
- digitalWrite(ledPin1, LOW); // Turn off the LED
- digitalWrite(ledPin2, HIGH); // Turn on the LED
- delay(2000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement