cfredisded
Active member
Does shiftPWM work with the teensy 4.1?
I found this thread but I'm not sure if its indicating that it works or not.
Also will it work with a 3mm 'common anode' RGB led like this schematic?
I'm using 6 74hc595BQ
Here's the code I'm trying...
Also yesterday I swear changing "const bool ShiftPWM_invertOutputs = true;" between true and false and uploading would turn all the leds on or off but now its not doing anything.
Thanks for any incite.
I found this thread but I'm not sure if its indicating that it works or not.
Also will it work with a 3mm 'common anode' RGB led like this schematic?
I'm using 6 74hc595BQ
Here's the code I'm trying...
Code:
// You can choose the latch pin yourself.
const int ShiftPWM_latchPin=9;
#define SHIFTPWM_NOSPI // ** uncomment this part to NOT use the SPI port and change the pin numbers. This is 2.5x slower **
const int ShiftPWM_dataPin = 25;
const int ShiftPWM_clockPin = 10;
// If your LED's turn on if the pin is low, set this to true, otherwise set it to false.
const bool ShiftPWM_invertOutputs = true;
// You can enable the option below to shift the PWM phase of each shift register by 8 compared to the previous.
// This will slightly increase the interrupt load, but will prevent all PWM signals from becoming high at the same time.
// This will be a bit easier on your power supply, because the current peaks are distributed.
const bool ShiftPWM_balanceLoad = true;
#include <ShiftPWM.h> // include ShiftPWM.h after setting the pins!
// Here you set the number of brightness levels, the update frequency and the number of shift registers.
// These values affect the load of ShiftPWM.
// Choose them wisely and use the PrintInterruptLoad() function to verify your load.
unsigned char maxBrightness = 100;
unsigned char pwmFrequency = 75;
unsigned int numRegisters = 6;
elapsedMillis randomTimer;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
// Sets the number of 8-bit registers that are used.
ShiftPWM.SetAmountOfRegisters(numRegisters);
// SetPinGrouping allows flexibility in LED setup.
// If your LED's are connected like this: RRRRGGGGBBBBRRRRGGGGBBBB, use SetPinGrouping(4).
ShiftPWM.SetPinGrouping(1); //This is the default, but I added here to demonstrate how to use the funtion
ShiftPWM.Start(pwmFrequency,maxBrightness);
}
void loop() {
// put your main code here, to run repeatedly:
if (randomTimer >= 500){
Serial.println("testTimer");
int randomLed = random(0, 14);
int randomR = random(0, 254);
int randomG = random(0, 254);
int randomB = random(0, 254);
Serial.print("randomLed = ");
Serial.println(randomLed);
Serial.print("randomR = ");
Serial.println(randomR);
Serial.print("randomG = ");
Serial.println(randomG);
Serial.print("randomB = ");
Serial.println(randomB);
ShiftPWM.SetRGB(randomLed, randomR, randomG, randomB);
randomTimer = 0;
}
}
Also yesterday I swear changing "const bool ShiftPWM_invertOutputs = true;" between true and false and uploading would turn all the leds on or off but now its not doing anything.
Thanks for any incite.