Willkommen auf unserem Seminar-Blog

Immer auf dem aktuellen Stand bleiben

Dieser Seminar-Blog befindet sich noch im Aufbau und wird in den kommenden Tagen entsprechend verfeinert.

Member Login

Lost your password?

Registration is closed

Sorry, you are not allowed to register by yourself on this site!

You must either be invited by one of our team member or request an invitation by email at viad.info {at} zhdk {dot} ch.

LED Treiber

High Power RGB LED Shield Lieferant: Neuroelec Typ: High Power RGB LED Shield Version 2.0 Arduino Library: http://code.google.com/p/neuroelec/downloads/list Simple Code
#include <Wire.h>
#include <HPRGB2.h>

HPRGB ledShield; // default mcp4728 id(0) and default PCA9685 id(0)

// Input Voltage: 12V
void setup()
{
  ledShield.begin();
  ledShield.setCurrent(350,350,350); // set maximum current for channel 1-3 (mA)
  ledShield.setFreq(600 );// operation frequency of the LED driver (KHz)
  ledShield.eepromWrite();// write current settings to EEPROM
  delay(100); // wait for EEPROM writing
}

void loop()
{
  ledShield.goToRGB(255,255,255); //go to RGB color
  delay (1000); 
  ledShield.goToHSB(200,128,200); // go To HSB color
  delay (1000); 
}
3 Sliders, White Button, RGB HSB Switch Code
// Code for the HPRGB board driving a 8.5 Watt Dealextreme LED
// Input Voltage: 12V
// Current per LED: 350mA
// Board Frequency: 600 KHz
// Vf R: 6,39
// Vf G: 9,38
// Vf B: 9,22
// AIN 4 + 5 are used for I2C communication

// Libraries ---------------------------------------------------------
#include <Wire.h>
#include <HPRGB2.h>

// Instance of HPRGB Object ------------------------------------------
HPRGB ledShield; // default mcp4728 id(0) and default PCA9685 id(0)

// Pin definitions ---------------------------------------------------
// define the pins for buttons and switches
#define RGBPIN 4
#define BUT1 3
#define BUT2 2

// Variables ---------------------------------------------------------
boolean rgbState = true;
int slider1 = 0;
int slider2 = 0;
int slider3 = 0;
int whiteState;

// Setup -------------------------------------------------------------
void setup()
{
  ledShield.begin();
  ledShield.setCurrent(350,350,350); // set maximum current for channel 1-3 (mA)
  ledShield.setFreq(600 ); // operation frequency of the LED driver (KHz)
  ledShield.eepromWrite(); // write current settings to EEPROM
  delay(100); // wait for EEPROM writing

  pinMode(RGBPIN, INPUT);
  pinMode(BUT1, INPUT);
  pinMode(BUT2, INPUT);
  digitalWrite(RGBPIN, HIGH);
  digitalWrite(BUT1, HIGH);
  digitalWrite(BUT2, HIGH);  
  
  Serial.begin(9600);
}


// Loop -------------------------------------------------------------
void loop()
{
  rgbState = digitalRead(RGBPIN);     // read state of rgb/hsb switch
  slider1 = analogRead(0);        // read slider 1 - 3 and convert to from 10 to 8 bit
  slider1 = slider1 / 4;
  slider2 = analogRead(1);
  slider2 = slider2 / 4;  
  slider3 = analogRead(2);
  slider3 = slider3 / 4;  
  
  whiteState = digitalRead(BUT1);     // read 'white' button
  
  if (whiteState == LOW){             // 'white' button is pressed
    ledShield.goToRGB(127, 127, 127);
  } 
  
  if (whiteState == HIGH){            // if 'white' button is not pressed
  
    if (rgbState == HIGH){              // we are in rgb mode
      ledShield.goToRGB(slider1, slider2, slider3);
    } 
    if (rgbState == LOW) {                            // we are in hsb mode
      ledShield.goToHSB(slider1, slider2, slider3);  
    }  
  }  
  
//  Serial.println(slider1);
//  Serial.println(slider2);
//  Serial.println(slider3);
//  Serial.println();
//  
//  delay(1000);

}