Pages: [1]   Go Down
Author Topic: RGB LED, guidence! (New arduino user)  (Read 536 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have been programming with Processing and for 3-4 weeks I bought my first Arduino...

I just bought RGB LEDs and I want to put in a value like i could do in Processing...

I found this: http://arduino.cc/en/Reference/EsploraWriteRGB

But i need the Esplora.h file, i was wondering if its possible to somehow write similar to the reference in the URL..? (without the Esplora.h file)

Like:

digitalWrite(ledPin, HIGH(255,255,0);

or something like that?
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 180
Posts: 8108
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
// Pick the three PWM output pins that the RGB LED is connected to.
const int redPin = 3;
const int greenPin = 5;
const int bluePin = 6;

void setup() {
    pinMode(redPin, OUTPUT);
    pinMode(greenPin, OUTPUT);
    pinMode(bluePin, OUTPUT);
}

void loop()
{
 writeRGB(0, 128, 255);
 delay(1000);
 writeRGB(255, 0, 128);
 delay(1000);
 writeRGB(128, 255, 0);
}

void writeRGB( int red, int green, int blue) {
    analogWrite(redPin, red;
    analogWrite(greenPin, green);
    analogWrite(bluePin, blue);
}
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset



// Pick the three PWM output pins that the RGB LED is connected to.
const int redPin = 5; 
const int greenPin = 10;
const int bluePin = 9;

void setup() {
    pinMode(redPin, OUTPUT);
    pinMode(greenPin, OUTPUT);
    pinMode(bluePin, OUTPUT);
}

void loop()
{
 writeRGB(255, 255, 255); //White

}

void writeRGB( int red, int green, int blue)
{
    analogWrite(redPin, red);
    analogWrite(greenPin, green);
    analogWrite(bluePin, blue);
}

 


Logged

Pages: [1]   Go Up
Jump to: