So I changed SOFTPWM_DEFINE_OBJECT to 8 (instead of 1)
#include <PalatisSoftPWM.h>
SOFTPWM_DEFINE_PINA8_CHANNEL(0); //Configure Arduino pin A8 as PWM channel 0
SOFTPWM_DEFINE_PINA9_CHANNEL(1);
SOFTPWM_DEFINE_PINA10_CHANNEL(2);
SOFTPWM_DEFINE_PINA11_CHANNEL(3);
SOFTPWM_DEFINE_PINA12_CHANNEL(4);
SOFTPWM_DEFINE_PINA13_CHANNEL(5);
SOFTPWM_DEFINE_PINA14_CHANNEL(6);
SOFTPWM_DEFINE_PINA15_CHANNEL(7);
SOFTPWM_DEFINE_OBJECT(8);
void setup() {
PalatisSoftPWM.begin(60); // begin with 60 Hz PWM frequency
}
void loop() {
for(int pin = 0; pin < 8; pin++)
for(int s = 63; s <= 255; s += 64)
{ // PWM: 255 = 5V
PalatisSoftPWM.set(pin, s); // sweeps 1.24, 2.5, 3.75 & 5 V
delay(500);
}
}
I get these errors with defining the channels:
Arduino: 1.8.5 (Windows 7), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"
In file included from sketch\PalatisSoftPWM_example.ino.cpp:1:0:
C:\Users\uraynara\Documents\Arduino\PalatisSoftPWM-master\examples\PalatisSoftPWM_example\PalatisSoftPWM_example.ino: In function 'void {anonymous}::pinModeStatic(uint8_t) [with int channel = 1; uint8_t = unsigned char]':
C:\Users\uraynara\Documents\Arduino\libraries\PalatisSoftPWM-master/PalatisSoftPWM.h:322:79: error: 'DDRK1' was not declared in this scope
#define SOFTPWM_DEFINE_PIN63_CHANNEL(CHANNEL) SOFTPWM_DEFINE_CHANNEL(CHANNEL, DDRK1, PORTK, PORTK1)
^
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:113:32: note: in definition of macro 'bitClear'
#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
^
C:\Users\uraynara\Documents\Arduino\libraries\PalatisSoftPWM-master/PalatisSoftPWM.h:1215:3: note: in expansion of macro 'SOFTPWM_DEFINE_PINMODE'
SOFTPWM_DEFINE_PINMODE( CHANNEL, PMODE, PORT, BIT )
^
C:\Users\uraynara\Documents\Arduino\libraries\PalatisSoftPWM-master/PalatisSoftPWM.h:322:47: note: in expansion of macro 'SOFTPWM_DEFINE_CHANNEL'
#define SOFTPWM_DEFINE_PIN63_CHANNEL(CHANNEL) SOFTPWM_DEFINE_CHANNEL(CHANNEL, DDRK1, PORTK, PORTK1)
^
C:\Users\uraynara\Documents\Arduino\libraries\PalatisSoftPWM-master/PalatisSoftPWM.h:354:47: note: in expansion of macro 'SOFTPWM_DEFINE_PIN63_CHANNEL'
#define SOFTPWM_DEFINE_PINA9_CHANNEL(CHANNEL) SOFTPWM_DEFINE_PIN63_CHANNEL(CHANNEL)
^
C:\Users\uraynara\Documents\Arduino\PalatisSoftPWM-master\examples\PalatisSoftPWM_example\PalatisSoftPWM_example.ino:4:1: note: in expansion of macro 'SOFTPWM_DEFINE_PINA9_CHANNEL'
SOFTPWM_DEFINE_PINA9_CHANNEL(1);
^
C:\Users\uraynara\Documents\Arduino\libraries\PalatisSoftPWM-master/PalatisSoftPWM.h:322:79: error: 'DDRK1' was not declared in this scope
#define SOFTPWM_DEFINE_PIN63_CHANNEL(CHANNEL) SOFTPWM_DEFINE_CHANNEL(CHANNEL, DDRK1, PORTK, PORTK1)
^
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:113:32: note: in definition of macro 'bitClear'
#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
^
C:\Users\uraynara\Documents\Arduino\libraries\PalatisSoftPWM-master/PalatisSoftPWM.h:1215:3: note: in expansion of macro 'SOFTPWM_DEFINE_PINMODE'
SOFTPWM_DEFINE_PINMODE( CHANNEL, PMODE, PORT, BIT )
^
C:\Users\uraynara\Documents\Arduino\libraries\PalatisSoftPWM-master/PalatisSoftPWM.h:322:47: note: in expansion of macro 'SOFTPWM_DEFINE_CHANNEL'
#define SOFTPWM_DEFINE_PIN63_CHANNEL(CHANNEL) SOFTPWM_DEFINE_CHANNEL(CHANNEL, DDRK1, PORTK, PORTK1)
^
C:\Users\uraynara\Documents\Arduino\libraries\PalatisSoftPWM-master/PalatisSoftPWM.h:354:47: note: in expansion of macro 'SOFTPWM_DEFINE_PIN63_CHANNEL'
#define SOFTPWM_DEFINE_PINA9_CHANNEL(CHANNEL) SOFTPWM_DEFINE_PIN63_CHANNEL(CHANNEL)
^
C:\Users\uraynara\Documents\Arduino\PalatisSoftPWM-master\examples\PalatisSoftPWM_example\PalatisSoftPWM_example.ino:4:1: note: in expansion of macro 'SOFTPWM_DEFINE_PINA9_CHANNEL'
SOFTPWM_DEFINE_PINA9_CHANNEL(1);
^
C:\Users\uraynara\Documents\Arduino\libraries\PalatisSoftPWM-master/PalatisSoftPWM.h:322:79: error: 'DDRK1' was not declared in this scope
#define SOFTPWM_DEFINE_PIN63_CHANNEL(CHANNEL) SOFTPWM_DEFINE_CHANNEL(CHANNEL, DDRK1, PORTK, PORTK1)
^
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:112:30: note: in definition of macro 'bitSet'
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
^
C:\Users\uraynara\Documents\Arduino\libraries\PalatisSoftPWM-master/PalatisSoftPWM.h:1215:3: note: in expansion of macro 'SOFTPWM_DEFINE_PINMODE'
SOFTPWM_DEFINE_PINMODE( CHANNEL, PMODE, PORT, BIT )
^
C:\Users\uraynara\Documents\Arduino\libraries\PalatisSoftPWM-master/PalatisSoftPWM.h:322:47: note: in expansion of macro 'SOFTPWM_DEFINE_CHANNEL'
#define SOFTPWM_DEFINE_PIN63_CHANNEL(CHANNEL) SOFTPWM_DEFINE_CHANNEL(CHANNEL, DDRK1, PORTK, PORTK1)
^
C:\Users\uraynara\Documents\Arduino\libraries\PalatisSoftPWM-master/PalatisSoftPWM.h:354:47: note: in expansion of macro 'SOFTPWM_DEFINE_PIN63_CHANNEL'
#define SOFTPWM_DEFINE_PINA9_CHANNEL(CHANNEL) SOFTPWM_DEFINE_PIN63_CHANNEL(CHANNEL)
^
C:\Users\uraynara\Documents\Arduino\PalatisSoftPWM-master\examples\PalatisSoftPWM_example\PalatisSoftPWM_example.ino:4:1: note: in expansion of macro 'SOFTPWM_DEFINE_PINA9_CHANNEL'
SOFTPWM_DEFINE_PINA9_CHANNEL(1);
^
exit status 1