Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Set the pins 2, 3, 4, 5, 6, 7, and 8 as circuit inputs A, B, C, D, E, F, and G
- #include <EEPROM.h>
- int A=2, B=3, C=4, D=5, E=6, F=7, G=8, Z=9;
- int delayAmount = 1000;
- byte romTable [16] = {0x7e, 0x30, 0x6d, 0x79, 0x33, 0x5b, 0x5f, 0x70, 0x7f, 0x73, 0x77, 0x7f, 0x4e, 0x7e, 0x4f, 0x47};
- byte reverseROMTable [16] = {0x47, 0x4f, 0x7e, 0x4e, 0x7f, 0x77, 0x73, 0x7f, 0x70, 0x5f, 0x5b, 0x33, 0x79, 0x6d, 0x30, 0x7e};
- byte value[16];
- int countdownCondition; //if 1, pin 9 is on, and the readROMTable should read from the reverseROMTable. If 0, then procede as normal.
- void burnROMTable(byte rt[16]) {
- for(int addr = 0; addr < 16; addr++) {
- EEPROM.write(addr, rt[addr]);
- }//end of for loop
- Serial.println("Exit burnROMTable");
- }//end of burnROMTable
- void readROMTable() {
- Serial.println("Enter readROMTable");
- for (int j = 0; j < 16; j++) {
- value[j] = EEPROM.read(j);
- Serial.println(value[j], BIN);
- //If true, A will power the a diode of the 7SD
- if ((value[j] & 0000001) == 0000001){
- digitalWrite(G, 1);
- }//end of if statement
- if (((value[j] >> 1) & 0000001) == 0000001) {
- digitalWrite(F, 1);
- }//end of if statement
- if (((value[j] >> 2) & 0000001) == 0000001) {
- digitalWrite(E, 1);
- }//end of if statement
- if (((value[j] >> 3) & 0000001) == 0000001) {
- digitalWrite(D, 1);
- }//end of if statement
- if (((value[j] >> 4) & 0000001) == 0000001) {
- digitalWrite(C, 1);
- }//end of if statement
- if (((value[j] >> 5) & 0000001) == 0000001) {
- digitalWrite(B, 1);
- }//end of if statement
- if (((value[j] >> 6) & 0000001) == 0000001) {
- digitalWrite(A, HIGH);
- }//end of if statement
- Serial.println("New byte");
- delay(delayAmount);
- //Turning off the output LED lights for the new byte to display
- for (int s = 2; s <= 8; s++) {
- digitalWrite(s, LOW);
- }//end of for loop
- }//end of for loop
- Serial.println("Exit readROMTable.");
- }//end of readROMTable
- void setup() {
- // put your setup code here, to run once:
- Serial.begin(9600);
- // Set pins 2 -> 8 as OUTPUT
- for (int i = 2; i <= 8; i++) {
- pinMode(i, INPUT);
- }//end of for loop
- //Set pin 9 as OUTPUT for the countdown sequence
- pinMode(9, OUTPUT);
- }//end of startup
- void loop() {
- Serial.print("countdownCondition is: ");
- Serial.println(countdownCondition);
- //If Pin 9 is on before the readROMTable function, it will turn countdownCondition on.
- if (Z == HIGH){
- Serial.println("Z is 1.");
- countdownCondition = 1;
- }//end of if statement
- //If Pin 9 is off before the readROMTable function, it will continue as normal.
- else {
- Serial.println("Z is 0.");
- countdownCondition = 0;
- }//end of else statement
- //This statement will make the 7SD print in reverse order if Pin 9 is on.
- if (countdownCondition == 1){
- burnROMTable(reverseROMTable);
- readROMTable();
- }//end of if statement
- //This statement will make the 7SD print in regular order.
- else{
- burnROMTable(romTable);
- readROMTable();
- }//end of else statement
- }//end of loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement