User Tools

Site Tools


shiftpwm-led-controls

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision Both sides next revision
shiftpwm-led-controls [2015/01/22 15:34]
zoza created
shiftpwm-led-controls [2015/01/22 15:35]
zoza
Line 1: Line 1:
-lala +/​************************************************************************************************************************************ 
 + * ShiftPWM blocking RGB fades example, (c) Elco Jacobs, updated August 
 +2012. 
 + * 
 + * ShiftPWM blocking RGB fades example. This example uses simple delay 
 +loops to create fades. 
 + * If you want to change the fading mode based on inputs (sensors, 
 +buttons, serial), use the non-blocking example as a starting point. 
 + * Please go to www.elcojacobs.com/​shiftpwm for documentation,​ fuction 
 +reference and schematics. 
 + * If you want to use ShiftPWM with LED strips or high power LED'​s,​ 
 +visit the shop for boards. 
 + ​************************************************************************************************************************************/​ 
 +  
 +  
 +// You can choose the latch pin yourself. 
 +const int ShiftPWM_latchPin=8;​ 
 +  
 +const bool ShiftPWM_invertOutputs = false; 
 +  
 +const bool ShiftPWM_balanceLoad = false; 
 +  
 +#include <​ShiftPWM.h> ​  // include ShiftPWM.h after setting the pins! 
 +  
 +unsigned char maxBrightness = 128; 
 +unsigned char pwmFrequency = 75; 
 +int numRegisters = 3; 
 +int numRGBleds = 4; 
 +  
 +void setup(){ 
 +  Serial.begin(115200);​ 
 +  
 +  // Sets the number of 8-bit registers that are used. 
 +  ShiftPWM.SetAmountOfRegisters(numRegisters);​ 
 +  
 +  
 +  ShiftPWM.SetPinGrouping(1);​  
 +  
 +  ShiftPWM.Start(pwmFrequency,​maxBrightness);​ 
 +  
 +
 +  
 +  
 +  
 +void loop() 
 +
 +  
 +  /*for(int led=0;​led<​numRGBleds;​led++){ // loop over all LED'​s 
 +  for(int intensity=0;​intensity<​255;​intensity++){ // loop over all LED'​s 
 +    ShiftPWM.SetRGBW(led,​ intensity, 0, 0, 0); 
 +    delay(5); 
 +   } 
 +   ​for(int intensity=255;​intensity>​0;​intensity--){ // loop over all LED'​s 
 +    ShiftPWM.SetRGBW(led,​ intensity, 0, 0, 0); 
 +    delay(5); 
 +   } 
 +   }*/ 
 +   while (Serial.available() > 0) { 
 +     int led = Serial.parseInt();​ 
 +     int red = Serial.parseInt();​ 
 +     int green = Serial.parseInt();​ 
 +     int blue = Serial.parseInt();​ 
 +     //int white = Serial.parseInt();​ 
 +     ​ShiftPWM.SetRGBW(led,​ red, green, blue, 0); 
 +   } 
 +}
shiftpwm-led-controls.txt · Last modified: 2015/04/30 08:44 by zoza