Advertisement
Guest User

FUGG

a guest
Mar 18th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.11 KB | None | 0 0
  1. //Set the pins 2, 3, 4, 5, 6, 7, and 8 as circuit inputs A, B, C, D, E, F, and G
  2. #include <EEPROM.h>
  3. int A=2, B=3, C=4, D=5, E=6, F=7, G=8, Z=9;
  4. int delayAmount = 1000;
  5. byte romTable [16] = {0x7e, 0x30, 0x6d, 0x79, 0x33, 0x5b, 0x5f, 0x70, 0x7f, 0x73, 0x77, 0x7f, 0x4e, 0x7e, 0x4f, 0x47};
  6. byte reverseROMTable [16] = {0x47, 0x4f, 0x7e, 0x4e, 0x7f, 0x77, 0x73, 0x7f, 0x70, 0x5f, 0x5b, 0x33, 0x79, 0x6d, 0x30, 0x7e};
  7. byte value[16];
  8. int countdownCondition; //if 1, pin 9 is on, and the readROMTable should read from the reverseROMTable. If 0, then procede as normal.
  9.  
  10. void burnROMTable(byte rt[16]) {
  11. for(int addr = 0; addr < 16; addr++) {
  12. EEPROM.write(addr, rt[addr]);
  13. }//end of for loop
  14. Serial.println("Exit burnROMTable");
  15. }//end of burnROMTable
  16.  
  17. void readROMTable() {
  18. Serial.println("Enter readROMTable");
  19.  
  20.  
  21. for (int j = 0; j < 16; j++) {
  22. value[j] = EEPROM.read(j);
  23. Serial.println(value[j], BIN);
  24.  
  25. //If true, A will power the a diode of the 7SD
  26. if ((value[j] & 0000001) == 0000001){
  27. digitalWrite(G, 1);
  28. }//end of if statement
  29.  
  30. if (((value[j] >> 1) & 0000001) == 0000001) {
  31. digitalWrite(F, 1);
  32. }//end of if statement
  33.  
  34. if (((value[j] >> 2) & 0000001) == 0000001) {
  35. digitalWrite(E, 1);
  36. }//end of if statement
  37.  
  38. if (((value[j] >> 3) & 0000001) == 0000001) {
  39. digitalWrite(D, 1);
  40. }//end of if statement
  41.  
  42. if (((value[j] >> 4) & 0000001) == 0000001) {
  43. digitalWrite(C, 1);
  44. }//end of if statement
  45.  
  46. if (((value[j] >> 5) & 0000001) == 0000001) {
  47. digitalWrite(B, 1);
  48. }//end of if statement
  49.  
  50. if (((value[j] >> 6) & 0000001) == 0000001) {
  51. digitalWrite(A, HIGH);
  52. }//end of if statement
  53.  
  54. Serial.println("New byte");
  55. delay(delayAmount);
  56. //Turning off the output LED lights for the new byte to display
  57. for (int s = 2; s <= 8; s++) {
  58. digitalWrite(s, LOW);
  59. }//end of for loop
  60. }//end of for loop
  61.  
  62. Serial.println("Exit readROMTable.");
  63. }//end of readROMTable
  64.  
  65. void setup() {
  66. // put your setup code here, to run once:
  67. Serial.begin(9600);
  68. // Set pins 2 -> 8 as OUTPUT
  69. for (int i = 2; i <= 8; i++) {
  70. pinMode(i, INPUT);
  71. }//end of for loop
  72. //Set pin 9 as OUTPUT for the countdown sequence
  73. pinMode(9, OUTPUT);
  74.  
  75.  
  76. }//end of startup
  77.  
  78. void loop() {
  79. Serial.print("countdownCondition is: ");
  80. Serial.println(countdownCondition);
  81. //If Pin 9 is on before the readROMTable function, it will turn countdownCondition on.
  82. if (Z == HIGH){
  83. Serial.println("Z is 1.");
  84. countdownCondition = 1;
  85. }//end of if statement
  86.  
  87. //If Pin 9 is off before the readROMTable function, it will continue as normal.
  88. else {
  89. Serial.println("Z is 0.");
  90. countdownCondition = 0;
  91. }//end of else statement
  92.  
  93. //This statement will make the 7SD print in reverse order if Pin 9 is on.
  94. if (countdownCondition == 1){
  95. burnROMTable(reverseROMTable);
  96. readROMTable();
  97. }//end of if statement
  98.  
  99. //This statement will make the 7SD print in regular order.
  100. else{
  101. burnROMTable(romTable);
  102. readROMTable();
  103. }//end of else statement
  104. }//end of loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement