Attached below is my script and then my error message when trying to compile the Arduino Mega code to my Arduino Nano Every. The code and circuit still works on the Arduino Mega but doesn't compile to the Arduino Nano Every for some reason.
MODERATOR EDIT- added code tags (please read How to get the best out of this forum )
// Code for controlling AdaFruit DotStar LED. Code cyleds RGB colors while recording
// photodiode signal from pin "PDpin". Parameters can be adjusted in setup lines.
// Contact mmcgeeha@uoregon.edu with questions.
#include <Adafruit_DotStar.h> //DotStar LED library
#include <SPI.h> //Serial peripheral interface library
//#include <avr/power.h> // ENABLE THIS LINE FOR GEMMA OR TRINKET
#define NUMPIXELS 1 // Number of LEDs in strip
#define DATAPIN 6
#define CLOCKPIN 5
Adafruit_DotStar strip(NUMPIXELS, DATAPIN, CLOCKPIN, DOTSTAR_BRG);
int head = 0; // Index of first 'on' and 'off' pixels
uint32_t green = 0xFF0000; // 'On' color (starts red)
uint32_t red = 0x00FF00; // 'On' color (starts red)
uint32_t blue = 0x0000FF; // 'On' color (starts red)
uint32_t off = 0x000000; // 'On' color (starts red)
int flashes = 150;
int flashTime = 50;
int pauseTime = 10;
int PDvalue = 0;
int PDpin = A0;
int redIntensity = 0;
int greenIntensity = 0;
int blueIntensity = 0;
void setup() {
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000L)
clock_prescale_set(clock_div_1); // Enable 16 MHz on Trinket
#endif
strip.begin(); // Initialize pins for output
strip.show(); // Turn all LEDs off ASAP
Serial.begin(9600);
}
void loop() {
for (int i=0;i<=flashes;i++){
strip.setPixelColor(head, red); // 'On' pixel at head
strip.show();
delay(flashTime);
redIntensity = analogRead(PDpin);
strip.setPixelColor(head, off); // 'Off' pixel at head
strip.show();
delay(pauseTime); // Pause 20 milliseconds (~50 FPS)
strip.setPixelColor(head, green); // 'On' pixel at head
strip.show(); // Refresh strip
delay(flashTime);
greenIntensity = analogRead(PDpin);
strip.setPixelColor(head, off); // 'Off' pixel at head
strip.show();
delay(pauseTime); // Pause 20 milliseconds (~50 FPS)
strip.setPixelColor(head, blue); // 'On' pixel at head
strip.show(); // Refresh strip
delay(flashTime);
blueIntensity = analogRead(PDpin);
strip.setPixelColor(head, off); // 'Off' pixel at head
strip.show();
delay(pauseTime); // Pause 20 milliseconds (~50 FPS)
Serial.print("Blue:");
Serial.print(blueIntensity);
Serial.print(", ");
Serial.print("Red:");
Serial.print(redIntensity);
Serial.print(", ");
Serial.print("Green:");
Serial.println(greenIntensity);
}
exit(0);
}
Error message:
Arduino: 1.8.13 (Mac OS X), Board: "Arduino Nano Every, ATMEGA328" /Users/kylienash/Documents/Arduino/libraries/Adafruit_DotStar/Adafruit_DotStar.cpp: In member function 'void Adafruit_DotStar::show()': /Users/kylienash/Documents/Arduino/libraries/Adafruit_DotStar/Adafruit_DotStar.cpp:329:5: error: 'SPDR' was not declared in this scope SPDR = 0x00; // 4th is pipelined ^~~~ /Users/kylienash/Documents/Arduino/libraries/Adafruit_DotStar/Adafruit_DotStar.cpp:329:5: note: suggested alternative: 'SPI' SPDR = 0x00; // 4th is pipelined ^~~~ SPI /Users/kylienash/Documents/Arduino/libraries/Adafruit_DotStar/Adafruit_DotStar.cpp:331:16: error: 'SPSR' was not declared in this scope while (!(SPSR & _BV(SPIF))) ^~~~ /Users/kylienash/Documents/Arduino/libraries/Adafruit_DotStar/Adafruit_DotStar.cpp:331:16: note: suggested alternative: 'SPI' while (!(SPSR & _BV(SPIF))) ^~~~ SPI In file included from /Users/kylienash/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/avr/include/avr/io.h:99:0, from /Users/kylienash/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/avr/include/avr/pgmspace.h:90, from /Users/kylienash/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/cores/arduino/api/String.h:31, from /Users/kylienash/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/cores/arduino/api/IPAddress.h:24, from /Users/kylienash/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/cores/arduino/api/ArduinoAPI.h:30, from /Users/kylienash/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/cores/arduino/Arduino.h:23, from /Users/kylienash/Documents/Arduino/libraries/Adafruit_DotStar/Adafruit_DotStar.h:25, from /Users/kylienash/Documents/Arduino/libraries/Adafruit_DotStar/Adafruit_DotStar.cpp:42: /Users/kylienash/Documents/Arduino/libraries/Adafruit_DotStar/Adafruit_DotStar.cpp:331:27: error: 'SPIF' was not declared in this scope while (!(SPSR & _BV(SPIF))) ^ /Users/kylienash/Documents/Arduino/libraries/Adafruit_DotStar/Adafruit_DotStar.cpp:331:27: note: suggested alternative: 'SPI' /Users/kylienash/Documents/Arduino/libraries/Adafruit_DotStar/Adafruit_DotStar.cpp:336:18: error: 'SPSR' was not declared in this scope while (!(SPSR & _BV(SPIF))) ^~~~ /Users/kylienash/Documents/Arduino/libraries/Adafruit_DotStar/Adafruit_DotStar.cpp:336:18: note: suggested alternative: 'SPI' while (!(SPSR & _BV(SPIF))) ^~~~ SPI In file included from /Users/kylienash/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/avr/include/avr/io.h:99:0, from /Users/kylienash/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/avr/include/avr/pgmspace.h:90, from /Users/kylienash/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/cores/arduino/api/String.h:31, from /Users/kylienash/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/cores/arduino/api/IPAddress.h:24, from /Users/kylienash/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/cores/arduino/api/ArduinoAPI.h:30, from /Users/kylienash/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/cores/arduino/Arduino.h:23, from /Users/kylienash/Documents/Arduino/libraries/Adafruit_DotStar/Adafruit_DotStar.h:25, from /Users/kylienash/Documents/Arduino/libraries/Adafruit_DotStar/Adafruit_DotStar.cpp:42: /Users/kylienash/Documents/Arduino/libraries/Adafruit_DotStar/Adafruit_DotStar.cpp:336:29: error: 'SPIF' was not declared in this scope while (!(SPSR & _BV(SPIF))) ^ /Users/kylienash/Documents/Arduino/libraries/Adafruit_DotStar/Adafruit_DotStar.cpp:336:29: note: suggested alternative: 'SPI' /Users/kylienash/Documents/Arduino/libraries/Adafruit_DotStar/Adafruit_DotStar.cpp:341:14: error: 'SPSR' was not declared in this scope while (!(SPSR & _BV(SPIF))) ^~~~ /Users/kylienash/Documents/Arduino/libraries/Adafruit_DotStar/Adafruit_DotStar.cpp:341:14: note: suggested alternative: 'SPI' while (!(SPSR & _BV(SPIF))) ^~~~ SPI In file included from /Users/kylienash/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/avr/include/avr/io.h:99:0, from /Users/kylienash/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/avr/include/avr/pgmspace.h:90, from /Users/kylienash/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/cores/arduino/api/String.h:31, from /Users/kylienash/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/cores/arduino/api/IPAddress.h:24, from /Users/kylienash/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/cores/arduino/api/ArduinoAPI.h:30, from /Users/kylienash/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/cores/arduino/Arduino.h:23, from /Users/kylienash/Documents/Arduino/libraries/Adafruit_DotStar/Adafruit_DotStar.h:25, from /Users/kylienash/Documents/Arduino/libraries/Adafruit_DotStar/Adafruit_DotStar.cpp:42: /Users/kylienash/Documents/Arduino/libraries/Adafruit_DotStar/Adafruit_DotStar.cpp:341:25: error: 'SPIF' was not declared in this scope while (!(SPSR & _BV(SPIF))) ^ /Users/kylienash/Documents/Arduino/libraries/Adafruit_DotStar/Adafruit_DotStar.cpp:341:25: note: suggested alternative: 'SPI' exit status 1 Error compiling for board Arduino Nano Every.