Show Posts
Pages: [1] 2
1  Forum 2005-2010 (read only) / Interfacing / Re: Arduino and RGB Strip on: October 06, 2010, 05:07:00 pm
Sorry wrong forum
2  Forum 2005-2010 (read only) / Development / Re: Keypad code RGB on: January 19, 2011, 05:53:45 pm
My code:

Code:
//----------------------Info------------------------//
// Coded by The Sinding                             //
// 19-01-2011                                       //
// Project: RGB light                               //
//--------------------------------------------------//






//----------------Included libray-------------------//
#include <Keypad.h>

//----------------Rows and Colloms------------------//
const byte myRows = 4;  
const byte myCols = 3;

//----------------Keypad setup----------------------//
char keys[myRows][myCols] =
{
  {'*','0','*'},
  {'7','8','9'},
  {'4','5','6'},
  {'1','2','3'},
};

//--------------------Pin setup---------------------//
byte rowPins[myRows] = {A5, A4, A3, A2}; //array to map keypad to MCU pins
byte colPins[myCols] = {12, 8, 7}; //array to map keypad to MCU pins

//------initialize an instance of class NewKeypad---//
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, myRows, myCols );

//------------------Define Led Pins-----------------//
#define RedPin 11
#define BluePin 10
#define GreenPin 9
#define redPin 6
#define greenPin 5
#define bluePin 3

//---------------------int--------------------------//
int BlackState;

//--------------------------------------------------//


void setup()
{
//----Set the arduino to send data over band 9600---//
  Serial.begin(9600);
  
//------Set the green, red and blue pin to output---//
  pinMode(GreenPin, OUTPUT);
  pinMode(BluePin,  OUTPUT);
  pinMode(RedPin,   OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin,  OUTPUT);
  pinMode(redPin,   OUTPUT);
}
  
void loop()
{
  {
//--------------This is the basic state-------------//
   while (BlackState);
  {
//-When the key * is press, it resets to blackstate-//
    
    char key = kpd.getKey();
    if (key=='*')
    {
//---------This is what it do when you press *------//

//---------It prints the line to the serial---------//
      Serial.println("The leds is off");
      
//----------Sets the all the pins to LOW------------//
      digitalWrite(GreenPin,  LOW);
      digitalWrite(RedPin,    LOW);
      digitalWrite(BluePin,   LOW);
      digitalWrite(redPin,    LOW);
      digitalWrite(greenPin,  LOW);
      digitalWrite(bluePin,   LOW);
      delay(1);

    }
//-------This what happens when you press 1---------//

    if (key=='1')
     {
//---------It prints the line to the serial---------//
      Serial.println("The color is now red");

//-----------It sets the redpin to HIGH-------------//
      digitalWrite(GreenPin,  LOW);
      digitalWrite(RedPin,   HIGH);
      digitalWrite(BluePin,   LOW);
      digitalWrite(redPin,   HIGH);
      digitalWrite(greenPin,  LOW);
      digitalWrite(bluePin,   LOW);
      delay(1);
    }
    
//-------This what happens when you press 2---------//
     if (key=='2')
     {

//---------It prints the line to the serial---------//
      Serial.println("The color is now green");
      
//---------It sets the Greenpin to HIGH-------------//
      digitalWrite(GreenPin, HIGH);
      digitalWrite(RedPin,    LOW);
      digitalWrite(BluePin,   LOW);
      digitalWrite(redPin,    LOW);
      digitalWrite(greenPin, HIGH);
      digitalWrite(bluePin,   LOW);
      delay(1);
     }  

//-------This what happens when you press 3---------//
     if (key=='3')
     {
      
//---------It prints the line to the serial---------//
       Serial.println("The color is now blue");
      
//---------It sets the Bluepin to HIGH--------------//
      digitalWrite(GreenPin,  LOW);
      digitalWrite(RedPin,    LOW);
      digitalWrite(BluePin,  HIGH);
      digitalWrite(redPin,    LOW);
      digitalWrite(greenPin,  LOW);
      digitalWrite(bluePin,  HIGH);
      delay(1);
      }

//-------This what happens when you press 4---------//
     if (key=='4')
     {
      
//---------It prints the line to the serial---------//
       Serial.println("The color is now cyan");
      
//------It sets the blue and green pin to HIGH------//
      digitalWrite(GreenPin, HIGH);
      digitalWrite(RedPin,    LOW);
      digitalWrite(BluePin,  HIGH);
      digitalWrite(redPin,    LOW);
      digitalWrite(greenPin, HIGH);
      digitalWrite(bluePin,  HIGH);
      delay(1);
     }

//-------This what happens when you press 5---------//
     if (key=='5')
     {
      
//---------It prints the line to the serial---------//
       Serial.println("The color is now purple");
  
//------It sets the blue and red pin to HIGH--------//
      digitalWrite(GreenPin,  LOW);
      digitalWrite(RedPin,   HIGH);
      digitalWrite(BluePin,  HIGH);
      digitalWrite(redPin,   HIGH);
      digitalWrite(greenPin,  LOW);
      digitalWrite(bluePin,  HIGH);
      delay(1);
      }
      
//-------This what happens when you press 6---------//
     if (key=='6')
     {
      
//---------It prints the line to the serial---------//
       Serial.println("The color is now yellow");
      
//-----It sets the green and red pin to HIGH--------//
      digitalWrite(GreenPin, HIGH);
      digitalWrite(RedPin,   HIGH);
      digitalWrite(BluePin,   LOW);
      digitalWrite(redPin,   HIGH);
      digitalWrite(greenPin, HIGH);
      digitalWrite(bluePin,   LOW);
      delay(1);
      }
      
//-------This what happens when you press 7---------//
     if (key=='7')
     {
    
//---------It prints the line to the serial---------//
       Serial.println("The color is now white");
      
//--It sets the green, blue and red pin to HIGH-----//
      digitalWrite(GreenPin, HIGH);
      digitalWrite(RedPin,   HIGH);
      digitalWrite(BluePin,  HIGH);
      digitalWrite(redPin,   HIGH);
      digitalWrite(greenPin, HIGH);
      digitalWrite(bluePin,  HIGH);
      delay(1);
      }
      
//-------This what happens when you press 7---------//
     if (key=='8')
     {
       {
        
//---------It prints the line to the serial---------//
         Serial.println("It fades between colors");
        
//---------Now it sets all the pins to low----------//
      digitalWrite(GreenPin,  LOW);
      digitalWrite(RedPin,    LOW);
      digitalWrite(BluePin,   LOW);
      digitalWrite(redPin,    LOW);
      digitalWrite(greenPin,  LOW);
      digitalWrite(bluePin,   LOW);
      delay(1);

//-------Then it fades between differnt colors------//
        for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=10)
          {
          analogWrite(RedPin, fadeValue);
          delay(45);                            
          }
        for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=10)
          {
          analogWrite(RedPin, fadeValue);  
          delay(45);                            
          }
        for(int fadeValue = 0 ; fadeValue <=255; fadeValue +=10)
           {
          analogWrite(BluePin, fadeValue);
          delay(45);
          }
        for(int fadeValue = 255 ; fadeValue >=0; fadeValue -=10)
          {
           analogWrite(BluePin, fadeValue);
          delay(45);
          }
         for(int fadeValue = 0 ; fadeValue <=255; fadeValue +=10)
          {
          analogWrite(GreenPin, fadeValue);
          delay(45);
          }
        for(int fadeValue = 255 ; fadeValue >=0; fadeValue -=10)
          {
          analogWrite(GreenPin, fadeValue);
          delay(45);
          }
        for(int fadeValue = 0 ; fadeValue <=255; fadeValue +=10)
          {
          analogWrite(BluePin, fadeValue);
          analogWrite(GreenPin, fadeValue);
          delay(45);
          }
        for(int fadeValue = 255 ; fadeValue >=0; fadeValue -=10)
          {
          analogWrite(BluePin, fadeValue);
          analogWrite(GreenPin, fadeValue);
          delay(45);
          }
        for(int fadeValue = 0 ; fadeValue <=255; fadeValue +=10)
          {
          analogWrite(BluePin, fadeValue);
          analogWrite(RedPin, fadeValue);
          delay(45);
          }
        for(int fadeValue = 255 ; fadeValue >=0; fadeValue -=10)
          {
          analogWrite(BluePin, fadeValue);
          analogWrite(RedPin, fadeValue);
          delay(45);
          }
        for(int fadeValue = 0 ; fadeValue <=255; fadeValue +=10)
          {
          analogWrite(RedPin, fadeValue);
          analogWrite(GreenPin, fadeValue);
          delay(45);
          }
        for(int fadeValue = 255 ; fadeValue >=0; fadeValue -=10)
          {
          analogWrite(RedPin, fadeValue);
          analogWrite(GreenPin, fadeValue);
          delay(45);
          }
        for(int fadeValue = 0 ; fadeValue <=255; fadeValue +=10)
          {
          analogWrite(RedPin, fadeValue);
          analogWrite(GreenPin, fadeValue);
          analogWrite(BluePin, fadeValue);
          delay(45);
          }
        for(int fadeValue = 255 ; fadeValue >=0; fadeValue -=10)
          {
          analogWrite(RedPin, fadeValue);
          analogWrite(GreenPin, fadeValue);
          analogWrite(BluePin, fadeValue);
          delay(45);
          }
        }      
      }
    }
  }
}
//-------------Now the script ends-----------------//

Did someone created something similar or something that I can look at?
3  Forum 2005-2010 (read only) / Development / Keypad code RGB on: January 19, 2011, 05:53:03 pm
So i created this code for my RGB project and it works, sort of (the fading between colors is´nt polished, maybe you guys can help with that?), but i wanna add 2 features, but i dont know how.
I want:
  • When I press 9 i want it to go in a mode where I change the hue with a potentiometer..
  • Another potentiometer to control the brightness.

Can you guys help with this?
I´m pretty new at coding, and i only created this code by looking at some other´s created, and learned it from there..
4  Forum 2005-2010 (read only) / Scandinavia / Re: Arduino og LED Kæde. on: October 22, 2010, 08:41:40 am
Det er ligemeget. Jeg har fået den til og virke nu ..
5  Forum 2005-2010 (read only) / Scandinavia / Arduino og LED Kæde. on: October 21, 2010, 05:58:08 pm
Jeg undskylder for ikke og have svaret på den anden post jeg har lavet.

Men jeg har købt 3 IRL530NPBF mosfets, og en Uno.
Jeg har en RGB led kæde på 4,3m med 30led/m = 129 LEDs,
Kæden er sat sådan op at RGB, altså de 3 ledninger der er til farverne, de er GND og så er der én ledning til 12v.

Nu har jeg så prøvet at sætte Uno til gate, den røde fra led kæden på, altså GND fra kæde, til drain og GND fra min ATX strømforsygning til source. Det eneste jeg får ud af dette er et meget svagt lys i kæden.

Hvad gør jeg glat, det er sådan jeg har fået at vide jeg skal sætte den til?
6  Forum 2005-2010 (read only) / Scandinavia / Re: TSOP4837 IR sensor hjælp on: October 24, 2010, 04:31:05 am
Det ved jeg heller ikke.. Vil bare gerne have noget hjælp til det..
7  Forum 2005-2010 (read only) / Scandinavia / TSOP4837 IR sensor hjælp on: October 23, 2010, 10:32:27 am
Hej.

Jeg har fået denne sensor fra en gammel herstal lampe, hvor der var fjernbetjening til, og så vil jeg gerne bruge den til min arduino

Jeg har prøvet allemulige kombinationer ved og sætte den til. Jeg har også kigget på datasheetet, osv osv. Men skal jeg bruge en kondensator og modstande eller hvad skal jeg gøre for at sætte den til?
Eller har det bare noget og gøre med noget kode ?

Jeg er helt på bar bund. Er helt ny i denne verden.
8  Forum 2005-2010 (read only) / Scandinavia / LED RGB kæde og audrino on: October 07, 2010, 09:16:09 am
Hej alle sammen.
Jeg har fået en 4.3 lang RGB kæde/strip i gave.
Men jeg vil rigtig gerne have en arduino til og styre den, så jeg har googlet lidt på emnet og fundet ud af man skal bruge PWM output på arduinoen.. Men man skal også bruge mosfet osv osv.
Nogen der kan fortælle mig helt præcist hvad jeg skal bruge?
Jeg er ny i denne DIY elektronik verden, men jeg kan da finde ud af noget af det, men lige dette er ud over min kapacitet.
Og er der nogle der kan fortælle mig om jeg kan bruge en gammel strømforsygning fra en computer til og drive kæden med? Jeg har prøvet at sætte den til og den lyser godt nok og bliver ikke varm eller noget af den, men bare lidt bange for at den bliver brændt af?
9  Forum 2005-2010 (read only) / Interfacing / Re: PWM, mosfet and LED strip on: October 21, 2010, 07:17:08 pm
Quote
If it is really 5V.  Some computer power supplies don't behave well without a significant load (like a PC motherboard with CPU). I would measure it before assuming it is really 5V.

It is, just measured it and it´s okay, also tried it on the Uno. Thanks man!
10  Forum 2005-2010 (read only) / Interfacing / Re: PWM, mosfet and LED strip on: October 21, 2010, 06:22:25 pm
Oh thanks, now it works!..
I was wondering, can I connect the 5v from the ATX to the Uno ?..
11  Forum 2005-2010 (read only) / Interfacing / Re: PWM, mosfet and LED strip on: October 21, 2010, 06:09:38 pm
Quote
I can guarantee that it will never work WITHOUT that connection.
There is an excellent chance that it will work WITH that connection. But there could be other issues we haven't discovered yet.

Is it just any of the GND from the Uno or is a specific one?

It have to look like this?

12  Forum 2005-2010 (read only) / Interfacing / Re: PWM, mosfet and LED strip on: October 21, 2010, 06:02:53 pm
Quote
If we assume that you have the pins on the FET connected properly (they are not identified in your circuit diagram), then the most glaring problem is that there is no connection between the Arduino GND and the GND on the ATX power supply.

Assuming, also, that when you connect the ATX power supply directly to the LED strip, it lights as expected.

The first pin on the FET is gate, the middel is drain, and the last is source. That´s what my datasheet says.

The strip works if I connect it directly to the ATX powersupply.

So I just have to connect the GND from the Uno to the ATX?
13  Forum 2005-2010 (read only) / Interfacing / Re: PWM, mosfet and LED strip on: October 21, 2010, 05:47:55 pm
Quote
Dunno about anyone else, but I can not follow your verbal description of how you are connecting things?
Draw a circuit diagram showing what is connected where. Include everything, even the power supply.


Here is the diagram ..
14  Forum 2005-2010 (read only) / Interfacing / Re: PWM, mosfet and LED strip on: October 21, 2010, 05:02:07 pm
The LED strip got on wire to 12v and RGB is GND, so i connect the 12v to the powersupply and the RGB to the mosfets
15  Forum 2005-2010 (read only) / Interfacing / PWM, mosfet and LED strip on: October 21, 2010, 04:30:21 pm
Hey.

So i bought 3 IRL530NPBF and a Arduino Uno, and I´ve got 4,3m LED strip.
There is resistors built in the led strip so i dont need any resistors to the strip, just 12v.

So I´ve tried connecting the LED strip´s GND to the drain and GND to source, and the arduino to the gate, as I was told. But nothing happens..
What am i doing wrong?
Pages: [1] 2