Offline
Newbie
Karma: 0
Posts: 26
|
 |
« on: April 20, 2012, 06:02:08 am » |
Im using touchosc to control the level on the RGB LED, I have the touchosc layout on my ipod and its changing the processing on my computer. It changes the colour of the LED but not to red, green or blue. Is this due to the Resistor, LED, or the code ? Thanks import cc.arduino.*; import processing.serial.*; import oscP5.*; import netP5.*;
Arduino arduino;
OscP5 oscP5;
float redAmount = 0.0f; float greenAmount = 0.0f; float blueAmount = 0.0f;
void setup () { size(320, 480); background(0); oscP5 = new OscP5(this,8000); arduino = new Arduino(this, Arduino.list()[1],57600); }
void draw (){ background(redAmount, greenAmount, blueAmount); fill(0); //red rect stroke(255, 0, 0); rect(34,39,67,255); fill(50,40,40); rect(34,39+255,67,-redAmount); //green rect fill(0); stroke(0,255,0); rect(124,39,67,255); fill(40,50,40); rect(124,39+255,67,-greenAmount); //blue rect fill(0); stroke(0,0,255); rect(216,39,67,255); fill(40,40,50); rect(216,39+255,67,-blueAmount); //write to arduino arduino.analogWrite(11, int(redAmount)); arduino.analogWrite(10, int(greenAmount)); arduino.analogWrite(9, int(blueAmount)); }
void oscEvent(OscMessage theOscMessage){ String addr = theOscMessage.addrPattern(); float val = theOscMessage.get(0).floatValue(); String iPadIP = "192.168.1.3"; // change this to the address of your iPad / iPhone println(addr); // uncomment for debug print of all recieved messages if(addr.equals("/1/red")){ redAmount = val;} if(addr.equals("/1/green")){ greenAmount = val;} if(addr.equals("/1/blue")){ blueAmount = val;}
}
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 138
Posts: 19067
I don't think you connected the grounds, Dave.
|
 |
« Reply #1 on: April 20, 2012, 06:44:45 am » |
It changes the colour of the LED but not to red, green or blu Are you saying you see colours, but never pure primaries? What does your debug output tell you is going on?
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 26
|
 |
« Reply #2 on: April 20, 2012, 06:55:15 am » |
Yeah, when I move the faders up and down there are some colours but not the primaries and the output im getting /1/red, /1/green and /1/blue?? Is this what you mean?
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 138
Posts: 19067
I don't think you connected the grounds, Dave.
|
 |
« Reply #3 on: April 20, 2012, 07:12:58 am » |
No, I'm asking what values is your Processing writing for the individual channels of red, green and blue.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 26
|
 |
« Reply #4 on: April 20, 2012, 07:20:03 am » |
Sorry, but i'm a new to this where am I looking for these values ? In the code? all the code is above ?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 26
|
 |
« Reply #5 on: April 20, 2012, 08:32:07 am » |
Hi I have touchosc working with the arduino controlling the colour of the LEDs. But for some reason the RGB LEDs are constantly on, with all the colours been on at the same time I emit the primary colour I want eg Red.
I want to know how to have the LED off until I have an input?
Many thanks
|
|
|
|
« Last Edit: April 20, 2012, 08:34:24 am by barry1234 »
|
Logged
|
|
|
|
|
New Zealand
Offline
Full Member
Karma: 0
Posts: 105
Just this guy you know.
|
 |
« Reply #6 on: April 20, 2012, 08:41:38 am » |
What does the code look like?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 26
|
 |
« Reply #7 on: April 20, 2012, 08:48:49 am » |
This is in processing, going to the arduino. import cc.arduino.*; import processing.serial.*; import oscP5.*; import netP5.*;
Arduino arduino;
OscP5 oscP5;
float redAmount = 0.0f; float greenAmount = 0.0f; float blueAmount = 0.0f;
void setup () { size(320, 480); background(0); oscP5 = new OscP5(this,8000); arduino = new Arduino(this, Arduino.list()[1],57600); }
void draw (){ background(redAmount, greenAmount, blueAmount); fill(0); //red rect stroke(255, 0, 0); rect(34,39,67,255); fill(50,40,40); rect(34,39+255,67,-redAmount); //green rect fill(0); stroke(0,255,0); rect(124,39,67,255); fill(40,50,40); rect(124,39+255,67,-greenAmount); //blue rect fill(0); stroke(0,0,255); rect(216,39,67,255); fill(40,40,50); rect(216,39+255,67,-blueAmount); //write to arduino arduino.analogWrite(11, int(redAmount)); arduino.analogWrite(10, int(greenAmount)); arduino.analogWrite(9, int(blueAmount)); }
void oscEvent(OscMessage theOscMessage){ String addr = theOscMessage.addrPattern(); float val = theOscMessage.get(0).floatValue(); String iPadIP = "192.168.1.3"; // change this to the address of your iPad / iPhone println(addr); // uncomment for debug print of all recieved messages if(addr.equals("/1/red")){ redAmount = val;} if(addr.equals("/1/green")){ greenAmount = val;} if(addr.equals("/1/blue")){ blueAmount = val;}
}
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 138
Posts: 19067
I don't think you connected the grounds, Dave.
|
 |
« Reply #8 on: April 20, 2012, 02:03:26 pm » |
I really do hope I don't have to merge another of your cross posted threads. Please consider this a final warning.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 26
|
 |
« Reply #9 on: April 20, 2012, 02:38:56 pm » |
Some asked for the code, on the LED. I didn't intently put the code on because I knew you would say this. But if someone asks then I have to give it them.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 138
Posts: 19067
I don't think you connected the grounds, Dave.
|
 |
« Reply #10 on: April 20, 2012, 02:52:36 pm » |
No, you didn't have to post the code again - you could have referred them to your other thread on the same subject.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 314
Posts: 35507
Seattle, WA USA
|
 |
« Reply #11 on: April 20, 2012, 07:42:05 pm » |
No, you didn't have to post the code again - you could have referred them to your other thread on the same subject. Even better, make up your mind where you want to ask the question, and ask it there. Quit running all over the place with the same problem. We do get tired of that, and will start ignoring you.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 26
|
 |
« Reply #12 on: April 21, 2012, 04:51:38 am » |
My apologises.
|
|
|
|
|
Logged
|
|
|
|
|
New Zealand
Offline
Full Member
Karma: 0
Posts: 105
Just this guy you know.
|
 |
« Reply #13 on: April 21, 2012, 05:21:31 am » |
In the setup put the line: Serial.begin(9600); // serial debugging port Unless your serial is already being used by arduino = new Arduino(this, Arduino.list()[1],57600); //write to arduino arduino.analogWrite(11, int(redAmount)); arduino.analogWrite(10, int(greenAmount)); arduino.analogWrite(9, int(blueAmount));
Serial.print(int(redAmount)); Serial.println(" redAmount"); Serial.print(int(greenAmount)); Serial.println(" greenAmount"); Serial.print(int(blueAmount)); Serial.println(" blueAmount"); }
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 277
Posts: 25506
Solder is electric glue
|
 |
« Reply #14 on: April 21, 2012, 05:36:41 am » |
barry1234 You are not helping yourself by not saying what your setup actually is. I assume you are using firmata on the arduino, but you haven't said. You also haven't said what sort of arduino you have because firmata is not fully implemented on all arduinos, the mega in particular does not implement all the calls. You have not said how you have wired up the LEDs, current sourcing, current sinking what resistors you have used. I notice you say:- Is this due to the Resistor, There should be three resistors in your circuit not one. To see the values you are sending from processing then add this line in the place after you do the arduino write:- //write to arduino arduino.analogWrite(11, int(redAmount)); arduino.analogWrite(10, int(greenAmount)); arduino.analogWrite(9, int(blueAmount)); println("RGB value " + redAmount + " " + greenAmount + " " + blueAmount);
The values will be seen at the bottom of the processing window.
|
|
|
|
|
Logged
|
|
|
|
|
|