Hello,
I am testing out a 7-segment display I am intentionally trying to make from scratch (using arduino mega) as a fun exercise.
I have a counting function in my void loop so supposedly my triple digit 7-segment display should just count from 1-100 and display each number appropriately. Below is my code, but below that is my compile error message. I am not sure what is causing it. Other codes compile just fine but this one is spitting this error back. Will check out the "how to submit a full bug report" link but hoping someone here has the knowledge to help me resolve this too! Thanks!
//7 seg test
/*
The LED strips circuit:
C
____
| |
E |____| A
| G |
F |____| B
D
*/
// Define a structure to contain all the related data for executing a note
typedef struct
{
const int pin; // output pin
const int numerals[]; // digit values with output pins
} numbers_and_SEGs;
numbers_and_SEGs ONES[] = ///ones place
{
{2, {0, 1, 2, 3, 4, 7, 8, 9, 9}}, //A
{3, {0, 1, 3, 4, 5, 6, 7, 8, 9}}, //B
{4, {0, 2, 3, 5, 6, 7, 8, 9, 9}}, //C
{5, {0, 2, 3, 5, 6, 8, 9, 9, 9}}, //D
{6, {0, 4, 5, 6, 8, 9, 9, 9, 9}}, //E
{7, {0, 2, 6, 8, 8, 8, 8, 8, 8}}, //F
{8, {2, 3, 4, 6, 8, 9, 9, 9, 9}}, //G
};
numbers_and_SEGs TENS[] = ///tens place
{
{22, {0, 1, 2, 3, 4, 7, 8, 9, 9}}, //A
{23, {0, 1, 3, 4, 5, 6, 7, 8, 9}}, //B
{24, {0, 2, 3, 5, 6, 7, 8, 9, 9}}, //C
{25, {0, 2, 3, 5, 6, 8, 9, 9, 9}}, //D
{26, {0, 4, 5, 6, 8, 9, 9, 9, 9}}, //E
{27, {0, 2, 6, 8, 8, 8, 8, 8, 8}}, //F
{28, {2, 3, 4, 6, 8, 9, 9, 9, 9}}, //G
};
int DECIMAL = 29;
int HUNDREDS = 30;
void SHOW(int val) ///ACTUALLY CONTROLS THE DISPLAY!!!!!
{
if (val == 0) //in the event of a reset all scores will be zero
{
for (int i = 0; i < 7; i++)
{
digitalWrite(ONES[i].pin, LOW);
}
for (int j = 0; j < 7; j++)
{
digitalWrite(TENS[j].pin, LOW);
}
digitalWrite(HUNDREDS, LOW);
digitalWrite(DECIMAL, LOW);
}
int ones = (val%10); /// % moduloooo!! divides, then remainder is what is returned
int tens = ((val/10)%10);
int hundreds = ((val/100)%10);
//for each digit, see if it is inside the array above and send HIGH for each respective pins
for (int n = 0; n < 7; n++) //ONES PLACE BEHAVIOR
{
for (int m = 0; m < 9; m++)
{
if (ones == ONES[n].numerals[m])
{
digitalWrite(ONES[n].pin, HIGH);
digitalWrite(DECIMAL, HIGH);
}
}
}
for (int o = 0; o < 7; o++) //TENS PLACE BEHAVIOR
{
for (int p = 0; p < 9; p++)
{
if (tens == TENS[o].numerals[p])
{
digitalWrite(TENS[o].pin, HIGH);
digitalWrite(DECIMAL, HIGH);
}
}
}
if (hundreds == 1) //HUNDREDS PLACE BEHAVIOR
{
digitalWrite(HUNDREDS, HIGH);
digitalWrite(DECIMAL, HIGH);
}
if (hundreds == 0)
{
digitalWrite(HUNDREDS, LOW);
}
}
void setup() {
// put your setup code here, to run once:
for (int q = 0; q < 7; q++)
{
pinMode(ONES[q].pin,OUTPUT);
digitalWrite(ONES[q].pin, LOW);
}
for (int r = 0; r < 7; r++)
{
pinMode(TENS[r].pin,OUTPUT);
digitalWrite(TENS[r].pin, LOW);
}
pinMode(HUNDREDS, OUTPUT);
digitalWrite(HUNDREDS, LOW);
pinMode(DECIMAL, OUTPUT);
digitalWrite(DECIMAL, LOW);
}
void loop() {
// put your main code here, to run repeatedly:
for (int k = 0; k<=100; k++)
{
SHOW(k);
Serial.println(k);
delay(500);
SHOW(0);
delay(500);
}
}
Arduino: 1.8.20 Hourly Build 2021/12/20 07:34 (Mac OS X), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"
/Applications/Arduino.app/Contents/Java/arduino-builder -dump-prefs -logger=machine -hardware /Applications/Arduino.app/Contents/Java/hardware -tools /Applications/Arduino.app/Contents/Java/tools-builder -tools /Applications/Arduino.app/Contents/Java/hardware/tools/avr -built-in-libraries /Applications/Arduino.app/Contents/Java/libraries -libraries /Users/eijifrey/Documents/Arduino/libraries -fqbn=arduino:avr:mega:cpu=atmega2560 -ide-version=10820 -build-path /var/folders/f5/wmykvlzd0ml0hh17g7wscpvm0000gn/T/arduino_build_545089 -warnings=none -build-cache /var/folders/f5/wmykvlzd0ml0hh17g7wscpvm0000gn/T/arduino_cache_885951 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.avrdude.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.arduinoOTA.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -verbose /Users/eijifrey/Documents/CAREER/EMPLOYERS/PINK SPARROW/2022/Price is Right (CBS)/7_segment_test/7_segment_test.ino
/Applications/Arduino.app/Contents/Java/arduino-builder -compile -logger=machine -hardware /Applications/Arduino.app/Contents/Java/hardware -tools /Applications/Arduino.app/Contents/Java/tools-builder -tools /Applications/Arduino.app/Contents/Java/hardware/tools/avr -built-in-libraries /Applications/Arduino.app/Contents/Java/libraries -libraries /Users/eijifrey/Documents/Arduino/libraries -fqbn=arduino:avr:mega:cpu=atmega2560 -ide-version=10820 -build-path /var/folders/f5/wmykvlzd0ml0hh17g7wscpvm0000gn/T/arduino_build_545089 -warnings=none -build-cache /var/folders/f5/wmykvlzd0ml0hh17g7wscpvm0000gn/T/arduino_cache_885951 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.avrdude.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.arduinoOTA.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -verbose /Users/eijifrey/Documents/CAREER/EMPLOYERS/PINK SPARROW/2022/Price is Right (CBS)/7_segment_test/7_segment_test.ino
Using board 'mega' from platform in folder: /Applications/Arduino.app/Contents/Java/hardware/arduino/avr
Using core 'arduino' from platform in folder: /Applications/Arduino.app/Contents/Java/hardware/arduino/avr
Detecting libraries used...
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10820 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/mega /var/folders/f5/wmykvlzd0ml0hh17g7wscpvm0000gn/T/arduino_build_545089/sketch/7_segment_test.ino.cpp -o /dev/null
Generating function prototypes...
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10820 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/mega /var/folders/f5/wmykvlzd0ml0hh17g7wscpvm0000gn/T/arduino_build_545089/sketch/7_segment_test.ino.cpp -o /var/folders/f5/wmykvlzd0ml0hh17g7wscpvm0000gn/T/arduino_build_545089/preproc/ctags_target_for_gcc_minus_e.cpp
/Applications/Arduino.app/Contents/Java/tools-builder/ctags/5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives /var/folders/f5/wmykvlzd0ml0hh17g7wscpvm0000gn/T/arduino_build_545089/preproc/ctags_target_for_gcc_minus_e.cpp
Compiling sketch...
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10820 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/mega /var/folders/f5/wmykvlzd0ml0hh17g7wscpvm0000gn/T/arduino_build_545089/sketch/7_segment_test.ino.cpp -o /var/folders/f5/wmykvlzd0ml0hh17g7wscpvm0000gn/T/arduino_build_545089/sketch/7_segment_test.ino.cpp.o
Compiling libraries...
Compiling core...
Using precompiled core: /var/folders/f5/wmykvlzd0ml0hh17g7wscpvm0000gn/T/arduino_cache_885951/core/core_arduino_avr_mega_cpu_atmega2560_51f02b7210b938436b779d1c032618e1.a
Linking everything together...
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-gcc -w -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega2560 -o /var/folders/f5/wmykvlzd0ml0hh17g7wscpvm0000gn/T/arduino_build_545089/7_segment_test.ino.elf /var/folders/f5/wmykvlzd0ml0hh17g7wscpvm0000gn/T/arduino_build_545089/sketch/7_segment_test.ino.cpp.o /var/folders/f5/wmykvlzd0ml0hh17g7wscpvm0000gn/T/arduino_build_545089/../arduino_cache_885951/core/core_arduino_avr_mega_cpu_atmega2560_51f02b7210b938436b779d1c032618e1.a -L/var/folders/f5/wmykvlzd0ml0hh17g7wscpvm0000gn/T/arduino_build_545089 -lm
lto1: internal compiler error: in output_constructor_regular_field, at varasm.c:5031
libbacktrace could not find executable to open
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
lto-wrapper: fatal error: /Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-gcc returned 1 exit status
compilation terminated.
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/../lib/gcc/avr/7.3.0/../../../../avr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino Mega or Mega 2560.