Hi
Im making a 10 RGB LED nightlight with potentiometers to control RGB values and Push button to cycle through settings. I have built this with an Arduino UNO board and it works without issue, however im now trying to upload this onto an Arduino Nano Every board and getting the below error.
Any help would be appreciated.
Library - GitHub - comdet/ShiftPWM: Arduino Library for software PWM with shift registers
#define button 2
int state = 0;
int old = 0;
int buttonPoll = 0;
int redPot = A3;
int greenPot = A2;
int bluePot = A1;
int greenVal = 0; //Create a variable to store the state of each Potentiometer
int blueVal = 0;
int redVal = 0;
// You can choose the latch pin yourself.
const int ShiftPWM_latchPin=8;
const int ShiftPWM_dataPin = 11;
const int ShiftPWM_clockPin = 13;
const bool ShiftPWM_invertOutputs = false;
const bool ShiftPWM_balanceLoad = false;
#include <ShiftPWM.h> // include ShiftPWM.h after setting the pins!
unsigned char maxBrightness = 255;
unsigned char pwmFrequency = 75;
int numRegisters = 4;
int numRGBleds = 10;//numRegisters*8/3;
unsigned int numRGBLeds = 10;
unsigned long startTime = 0;
unsigned int fadingMode = 0;
unsigned int numOutputs = numRegisters*8;
void setup(){
Serial.begin(9600);
pinMode(button, INPUT_PULLUP);
ShiftPWM.SetAmountOfRegisters(numRegisters);
ShiftPWM.SetPinGrouping(1);
ShiftPWM.Start(pwmFrequency,maxBrightness);
}
void loop() {
greenVal = analogRead(greenPot); //Read the position of the potentiometers
blueVal = analogRead(bluePot);
redVal = analogRead(redPot);
buttonPoll = digitalRead(button);
if(buttonPoll == 1){
delay(50);
buttonPoll = digitalRead(button);
if(buttonPoll == 0){
state = old + 1;
}}
else{
delay(100);
}
switch(state){
case 1:
rgbLedRainbow(3000,numRGBLeds);
old = state;
break;
case 2:
oneByOne();
old = state;
break;
case 3:
inOutAll();
old = state;
break;
case 4:
hueShiftAll();
old = state;
break;
case 5:
randomColors();
old = state;
break;
case 6:
set_All();
old = state;
break;
case 7:
pink();
old = state;
break;
default:
ShiftPWM.SetAll(0);
old = 0;
break;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void rgbLedRainbow(unsigned long cycleTime, int rainbowWidth){
// Displays a rainbow spread over a few LED's (numRGBLeds), which shifts in hue.
// The rainbow can be wider then the real number of LED's.
unsigned long time = millis()-startTime;
unsigned long colorShift = (360*time/cycleTime)%360; // this color shift is like the hue slider in Photoshop.
for(unsigned int led=0;led<numRGBLeds;led++){ // loop over all LED's
int hue = ((led)*360/(rainbowWidth-1)+colorShift)%360; // Set hue from 0 to 360 from first to last led and shift the hue
ShiftPWM.SetHSV(led, hue, 255, 255); // write the HSV values, with saturation and value at maximum
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void oneByOne(void){ // Fade in and fade out all outputs one at a time
unsigned char brightness;
unsigned long fadeTime = 500;
unsigned long loopTime = numOutputs*fadeTime*2;
unsigned long time = millis()-startTime;
unsigned long timer = time%loopTime;
unsigned long currentStep = timer%(fadeTime*2);
int activeLED = timer/(fadeTime*2);
if(currentStep <= fadeTime ){
brightness = currentStep*maxBrightness/fadeTime; ///fading in
}
else{
brightness = maxBrightness-(currentStep-fadeTime)*maxBrightness/fadeTime; ///fading out;
}
ShiftPWM.SetAll(0);
ShiftPWM.SetOne(activeLED, brightness);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void inOutAll(void){ // Fade in all outputs
unsigned char brightness;
unsigned long fadeTime = 2000;
unsigned long time = millis()-startTime;
unsigned long currentStep = time%(fadeTime*2);
if(currentStep <= fadeTime ){
brightness = currentStep*maxBrightness/fadeTime; ///fading in
}
else{
brightness = maxBrightness-(currentStep-fadeTime)*maxBrightness/fadeTime; ///fading out;
}
ShiftPWM.SetAll(brightness);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void hueShiftAll(void){ // Hue shift all LED's
unsigned long cycleTime = 10000;
unsigned long time = millis()-startTime;
unsigned long hue = (360*time/cycleTime)%360;
ShiftPWM.SetAllHSV(hue, 255, 255);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void randomColors(void){ // Update random LED to random color. Funky!
unsigned long updateDelay = 100;
static unsigned long previousUpdateTime;
if(millis()-previousUpdateTime > updateDelay){
previousUpdateTime = millis();
ShiftPWM.SetHSV(random(numRGBLeds),random(360),255,255);
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void set_All(void){ // Hue shift all LED's
for(int led=0; led<numRGBleds; led++){
ShiftPWM.SetRGB(led,redVal/4,greenVal/4,blueVal/4);
}}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void pink(void){ // Hue shift all LED's
for(int led=0; led<numRGBleds; led++){
ShiftPWM.SetRGB(led,233,5,15);
}}'
Arduino: 1.8.19 (Windows 10), Board: "Arduino Nano Every, None (ATMEGA4809)"
In file included from C:\Users\TESTUSER\sketchbook\libraries\ShiftPWM-master/ShiftPWM.h:25:0,
from C:\Users\TESTUSER\Desktop\Lewis\arduino-1.8.19-windows\rainbow\rainbow.ino:22:
C:\Users\TESTUSER\sketchbook\libraries\ShiftPWM-master/pins_arduino_compile_time.h:320:1: error: cannot convert 'PORT_t* {aka PORT_struct*}' to 'volatile uint8_t* const {aka volatile unsigned char* const}' in initialization
};
^
C:\Users\TESTUSER\sketchbook\libraries\ShiftPWM-master/pins_arduino_compile_time.h:320:1: error: cannot convert 'PORT_t* {aka PORT_struct*}' to 'volatile uint8_t* const {aka volatile unsigned char* const}' in initialization
C:\Users\TESTUSER\sketchbook\libraries\ShiftPWM-master/pins_arduino_compile_time.h:320:1: error: cannot convert 'PORT_t* {aka PORT_struct*}' to 'volatile uint8_t* const {aka volatile unsigned char* const}' in initialization
In file included from C:\Users\TESTUSER\Desktop\Lewis\arduino-1.8.19-windows\rainbow\rainbow.ino:22:0:
C:\Users\TESTUSER\sketchbook\libraries\ShiftPWM-master/ShiftPWM.h: In function 'void ShiftPWM_handleInterrupt()':
C:\Users\TESTUSER\sketchbook\libraries\ShiftPWM-master/ShiftPWM.h:131:2: error: 'SPDR' was not declared in this scope
SPDR = 0; // write bogus bit to the SPI, because in the loop there is a receive before send.
^~~~
C:\Users\TESTUSER\sketchbook\libraries\ShiftPWM-master/ShiftPWM.h:131:2: note: suggested alternative: 'SDA'
SPDR = 0; // write bogus bit to the SPI, because in the loop there is a receive before send.
^~~~
SDA
C:\Users\TESTUSER\sketchbook\libraries\ShiftPWM-master/ShiftPWM.h:147:12: error: 'SPSR' was not declared in this scope
while (!(SPSR & _BV(SPIF))); // wait for last send to finish and retreive answer. Retreive must be done, otherwise the SPI will not work.
^~~~
C:\Users\TESTUSER\sketchbook\libraries\ShiftPWM-master/ShiftPWM.h:147:12: note: suggested alternative: 'SS'
while (!(SPSR & _BV(SPIF))); // wait for last send to finish and retreive answer. Retreive must be done, otherwise the SPI will not work.
^~~~
SS
In file included from c:\users\TESTUSER\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\io.h:99:0,
from c:\users\TESTUSER\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\pgmspace.h:90,
from C:\Users\TESTUSER\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.7\cores\arduino/api/String.h:31,
from C:\Users\TESTUSER\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.7\cores\arduino/api/IPAddress.h:24,
from C:\Users\TESTUSER\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.7\cores\arduino/api/ArduinoAPI.h:30,
from C:\Users\TESTUSER\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.7\cores\arduino/Arduino.h:23,
from sketch\rainbow.ino.cpp:1:
C:\Users\TESTUSER\sketchbook\libraries\ShiftPWM-master/ShiftPWM.h:147:23: error: 'SPIF' was not declared in this scope
while (!(SPSR & _BV(SPIF))); // wait for last send to finish and retreive answer. Retreive must be done, otherwise the SPI will not work.
^
C:\Users\TESTUSER\sketchbook\libraries\ShiftPWM-master/ShiftPWM.h:147:23: note: suggested alternative: 'SPI0'
In file included from C:\Users\TESTUSER\Desktop\Lewis\arduino-1.8.19-windows\rainbow\rainbow.ino:22:0:
C:\Users\TESTUSER\sketchbook\libraries\ShiftPWM-master/ShiftPWM.h:153:11: error: 'SPSR' was not declared in this scope
while (!(SPSR & _BV(SPIF))); // wait for last send to complete.
^~~~
C:\Users\TESTUSER\sketchbook\libraries\ShiftPWM-master/ShiftPWM.h:153:11: note: suggested alternative: 'SS'
while (!(SPSR & _BV(SPIF))); // wait for last send to complete.
^~~~
SS
In file included from c:\users\TESTUSER\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\io.h:99:0,
from c:\users\TESTUSER\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\pgmspace.h:90,
from C:\Users\TESTUSER\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.7\cores\arduino/api/String.h:31,
from C:\Users\TESTUSER\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.7\cores\arduino/api/IPAddress.h:24,
from C:\Users\TESTUSER\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.7\cores\arduino/api/ArduinoAPI.h:30,
from C:\Users\TESTUSER\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.7\cores\arduino/Arduino.h:23,
from sketch\rainbow.ino.cpp:1:
C:\Users\TESTUSER\sketchbook\libraries\ShiftPWM-master/ShiftPWM.h:153:22: error: 'SPIF' was not declared in this scope
while (!(SPSR & _BV(SPIF))); // wait for last send to complete.
^
C:\Users\TESTUSER\sketchbook\libraries\ShiftPWM-master/ShiftPWM.h:153:22: note: suggested alternative: 'SPI0'
Multiple libraries were found for "ShiftPWM.h"
Used: C:\Users\TESTUSER\sketchbook\libraries\ShiftPWM-master
Not used: C:\Users\TESTUSER\Desktop\Lewis\arduino-1.8.19-windows\arduino-1.8.19\libraries\ShiftPWM-master
exit status 1
Error compiling for board Arduino Nano Every.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.