How to change default pins in ShiftPWM library

Hello,
I write a code using ShiftPWM library and now I need to upload my sketch to Attiny85.
But the problem is I can only change the “latchPin”.How do I change the other two pins?

ShiftPWM_dataPin = 11;
ShiftPWM_clockPin = 13;

Please Help.

How do I change the other two pins?

You can't
From the shiftPWM documentation

// Clock and data pins are pins from the hardware SPI, you cannot choose them yourself.
// Data pin is MOSI (Uno and earlier: 11, Leonardo: ICSP 4, Mega: 51, Teensy 2.0: 2, Teensy 2.0++: 22)
// Clock pin is SCK (Uno and earlier: 13, Leonardo: ICSP 3, Mega: 52, Teensy 2.0: 1, Teensy 2.0++: 21)

For an ATtiny85
pin1 MISO
pin2 SCK
So you could try using those pins.

Thanks for the reply. :slight_smile:
When I try to Upload ShiftPWM RGB Example sketch arduino shows me error msg :confused:

[color=red]Board breadboard:avr:atmega328bb doesn't define a 'build.board' preference. Auto-set to: AVR_ATMEGA328BB
Build options changed, rebuilding all
In file included from C:\Users\Amila Neranjan\Documents\Arduino\libraries\ShiftPWM-master/ShiftPWM.h:25:0,

                 from C:\Users\AMILAN~1\AppData\Local\Temp\arduino_9cea216527b2548a905a18b779c136d7\ShiftPWM_RGB_Example.ino:35:

C:\Users\Amila Neranjan\Documents\Arduino\libraries\ShiftPWM-master/pins_arduino_compile_time.h:318:3: error: 'PORTC' was not declared in this scope

  &PORTC,

   ^

C:\Users\Amila Neranjan\Documents\Arduino\libraries\ShiftPWM-master/pins_arduino_compile_time.h:319:3: error: 'PORTD' was not declared in this scope

  &PORTD,

   ^

In file included from C:\Users\AMILAN~1\AppData\Local\Temp\arduino_9cea216527b2548a905a18b779c136d7\ShiftPWM_RGB_Example.ino:35:0:

C:\Users\Amila Neranjan\Documents\Arduino\libraries\ShiftPWM-master/ShiftPWM.h:57:48: error: 'MOSI' was not declared in this scope

   CShiftPWM ShiftPWM(1,false,ShiftPWM_latchPin,MOSI,SCK);

                                                ^

C:\Users\Amila Neranjan\Documents\Arduino\libraries\ShiftPWM-master/ShiftPWM.h:57:53: error: 'SCK' was not declared in this scope

   CShiftPWM ShiftPWM(1,false,ShiftPWM_latchPin,MOSI,SCK);

                                                     ^

C:\Users\Amila Neranjan\Documents\Arduino\libraries\ShiftPWM-master/ShiftPWM.h: In function 'void ShiftPWM_handleInterrupt()':

C:\Users\Amila Neranjan\Documents\Arduino\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\Amila Neranjan\Documents\Arduino\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.

            ^

In file included from c:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\io.h:99:0,

                 from c:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\pgmspace.h:88,

                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:28,

                 from sketch\ShiftPWM_RGB_Example.ino.cpp:1:

C:\Users\Amila Neranjan\Documents\Arduino\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.

                       ^

In file included from C:\Users\AMILAN~1\AppData\Local\Temp\arduino_9cea216527b2548a905a18b779c136d7\ShiftPWM_RGB_Example.ino:35:0:

C:\Users\Amila Neranjan\Documents\Arduino\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.

           ^

In file included from c:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\io.h:99:0,

                 from c:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\pgmspace.h:88,

                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:28,

                 from sketch\ShiftPWM_RGB_Example.ino.cpp:1:

C:\Users\Amila Neranjan\Documents\Arduino\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.

                      ^

exit status 1
Error compiling.[/color]

When I try to Upload ShiftPWM RGB Example sketch arduino shows me error msg

Can you give a link to which ShiftPWM libiary you are using, there is more than one.

Grumpy_Mike:
Can you give a link to which ShiftPWM libiary you are using, there is more than one.

Okay sure.this is the link ShiftPWM master library

Sorry that is one of those stupid zip files that can not be un-archived on a Mac. Normally when this happens TheUnarchiver app can do this but not in this case.

Grumpy_Mike:
Sorry that is one of those stupid zip files that can not be un-archived on a Mac. Normally when this happens TheUnarchiver app can do this but not in this case.

Okay I attach unzipped file.
This error msg only comes when I try upload it to Attiny.

CShiftPWM.cpp (17.8 KB)

CShiftPWM.h (2.7 KB)

keywords.txt (944 Bytes)

pins_arduino_compile_time.h (9.78 KB)

ShiftPWM.h (8.51 KB)

shiftPWM master library

Mike thanks for all your support, If this Attiny85 not working well with ShiftPWM library,What is the best IC for this kind of project?

Thanks for that, I now see what the problem is. It is in the file "Pins_Arduino_Compile_Time.h", it is not finding the PORTD variable because the ATtiny85 does not have a PORTD register. This is one of the registers that define the address of the input / output pins. It would be possible to fix this and maybe the best bet might to ask the original library author to fix it.

As an alternative and, given your other thread, then the Neopixels work fine in the ATtiny85. I have used them with this processor.

Grumpy_Mike:
Thanks for that, I now see what the problem is. It is in the file “Pins_Arduino_Compile_Time.h”, it is not finding the PORTD variable because the ATtiny85 does not have a PORTD register. This is one of the registers that define the address of the input / output pins. It would be possible to fix this and maybe the best bet might to ask the original library author to fix it.

As an alternative and, given your other thread, then the Neopixels work fine in the ATtiny85. I have used them with this processor.

I ask from “Elco Jacobs” if he can fix this.I will update if he reply me.