Advertisement
Guest User

Untitled

a guest
Oct 24th, 2014
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. #include "SevSeg.h"
  2. //Time Global variables
  3. unsigned long timer;
  4. int deciSecond = 0;
  5. //int lastMillis,lastMillis2 = millis();
  6.  
  7. int value=100;
  8. int value2=4;
  9. const int ledPin1 = 14; //Blue Channel LED
  10. const int ledPin2 = 15; // Green Value LED
  11. char value_buffer1[4];
  12. char value_buffer2[4];
  13.  
  14. // DISPLAY CODE
  15. SevSeg myDisplay;
  16.  
  17. void setup() {
  18.  
  19. pinMode ( ledPin1, OUTPUT );
  20. pinMode ( ledPin2, OUTPUT );
  21. int displayType = COMMON_CATHODE; //Your display is either common cathode or common anode
  22. //Declare what pins are connected to the GND pins (cathodes)
  23. int digit1 = 11; //Display Pin 12
  24. int digit2 = 12; //Display Pin 9
  25. int digit3 = 13; //Display Pin 8
  26. int digit4 = 19; //Display Pin x
  27. //Declare what pins are connected to the segments (anodes)
  28. int segA = 3; //Display Pin 11
  29. int segB = 4; //Display Pin 7
  30. int segC = 5; //Display Pin 4
  31. int segD = 6; //Display Pin 2
  32. int segE = 7; //Display Pin 1
  33. int segF = 8; //Display Pin 10
  34. int segG = 9; //Display Pin 5
  35. int segDP= 10; //Display Pin 3
  36. int numberOfDigits = 3; //Do you have a 1, 2 or 4 digit display?
  37. myDisplay.Begin(displayType, numberOfDigits, digit1, digit2, digit3, digit4, segA, segB, segC, segD, segE, segF, segG, segDP);
  38. myDisplay.SetBrightness(100); //Set the display to 100% brightness level
  39.  
  40. //Time Variables
  41. timer = millis();
  42. }
  43. void loop()
  44. {
  45. sprintf(value_buffer1, "%03d", value);
  46. myDisplay.DisplayString(value_buffer1, 0);
  47. digitalWrite(ledPin1, HIGH); // Turn on the LED
  48. digitalWrite(ledPin2, LOW); // Turn off the LED
  49.  
  50. delay(2000);
  51. sprintf(value_buffer2, "%03d", value2);
  52. myDisplay.DisplayString(value_buffer2, 0);
  53. digitalWrite(ledPin1, LOW); // Turn off the LED
  54. digitalWrite(ledPin2, HIGH); // Turn on the LED
  55.  
  56. delay(2000);
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement