Go Down

Topic: Seeed Studio RGY programming (Read 716 times) previous topic - next topic

Gizmobizmo8

Good evening.  I'm having a lot of trouble finding a source code for RGB (I don't have blue, so mine is yellow) :D Are there any codes for a Seeed Studio RGB on my Arduino Mega?  I've been looking for days, because everything I've tried returns error messages.  Can someone please help me?

UKHeliBob

Quote
I've been looking for days, because everything I've tried returns error messages.
How about posting what you tried and the error messages it produced ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

septillion

What is a "Seeed Studio RGY"? Have a link?
Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake
https://github.com/septillion-git/FadeLed

Gizmobizmo8

Thanks you all for responding.  It's supposed to be RGB, but its RGY,(y is for yellow since I don't have blue).  Maybe I hooked it up wrong, but I'm not sure if Seeed Studio has a RGB display for their 2.8 tft screen.  I'm using 3 220 ohm resistors (well 1 is 150), and 3 led's.  Would you all know of a library for operating RGB on a touchscreen.  Thanks again.

Gizmobizmo8

#4
Aug 21, 2019, 02:33 am Last Edit: Aug 21, 2019, 03:34 am by Gizmobizmo8
Okay, so now I'm trying it without the tft screen with 3 led's and this code: 




 
Source Code
Now let's see the Arduino sketch. I will use the pins number 7, 6 and 5 and I will name them redPin, greenPin and bluePin. In the setup section we need to define them as outputs. At the bottom of the sketch we have this custom made function named setColor() which takes 3 different arguments redValue, greenValue and blueValue. These arguments represents the brightness of the LEDs or the duty cycle of the PWM signal which is created using the analogWrite() function. These values can vary from 0 to 255 which represents 100 % duty cycle of the PWM signal or maximum LED brightness.

int redPin= 7;
int greenPin = 6;
int bluePin = 5;
void setup() {
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT);
}
void loop() {
  setColor(255, 0, 0); // Red Color
  delay(1000);
  setColor(0, 255, 0); // Green Color
  delay(1000);
  setColor(0, 0, 255); // Blue Color
  delay(1000);
  setColor(255, 255, 255); // White Color
  delay(1000);
  setColor(170, 0, 255); // Purple Color
  delay(1000);
}
void setColor(int redValue, int greenValue, int blueValue) {
  analogWrite(redPin, redValue);
  analogWrite(greenPin, greenValue);
  analogWrite(bluePin, blueValue);
}

I keep getting this message though:  A function definition is not allowed  here before '{' token.  It shows up on the loop option, after the end of the code.  Any suggestions?

UKHeliBob

The code that you posted compiles for me
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Gizmobizmo8

So what do you think is the reason I keep getting this message, "A function definition is not allowed  here before '{' token."  In another forum it said something about the {'s weren't closed.  Would you mind showing me your format for the source code?  Also, do you have a code for controlling this with a Seeed Studio touchscreen?

septillion

Code compiles for me as well. So clearly you are compiling different code than you posted ;)

PS Please post code in code-tags next time. See "How to use the forum"
PPS Errors DO contain more useful info. So DO post the complete error ;)
Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake
https://github.com/septillion-git/FadeLed

Gizmobizmo8

Code compiles for me as well. So clearly you are compiling different code than you posted ;)

PS Please post code in code-tags next time. See "How to use the forum"
PPS Errors DO contain more useful info. So DO post the complete error ;)
Okay, thanks.  Sorry about that.  So code tags is a forum?

septillion

Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake
https://github.com/septillion-git/FadeLed

Gizmobizmo8

void setup() {
  // put your setup code here, to run once:int redPin= 7;
int greenPin = 6;
int bluePin = 5;
void setup() {
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT);
}
void loop() {
  setColor(255, 0, 0); // Red Color
  delay(1000);
  setColor(0, 255, 0); // Green Color
  delay(1000);
  setColor(0, 0, 255); // Blue Color
  delay(1000);
  setColor(255, 255, 255); // White Color
  delay(1000);
  setColor(170, 0, 255); // Purple Color
  delay(1000);
}
void setColor(int redValue, int greenValue, int blueValue) {
  analogWrite(redPin, redValue);
  analogWrite(greenPin, greenValue);
  analogWrite(bluePin, blueValue);

}



$$$$$void loop() {
  // put your main code here, to run repeatedly:

}

This is how I inputed the code, I used $'s to indicate where the error message is showing.

septillion

Did you read the topic suggested?
Clearly you did not... Is it really to much of your precious time to do that?

I'm out, good luck with the project!
Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake
https://github.com/septillion-git/FadeLed

david_2018

There should only be one loop() function.

Gizmobizmo8

Clearly you did not... Is it really to much of your precious time to do that?

I'm out, good luck with the project!
Sorry for the improper use of the forum.  I was reading a little of it after you mentioned it. I'll read through it today.  Thank you.

Gizmobizmo8

There should only be one loop() function.
Okay, so that's what I thought.  I erased the 1st line, I guess I have to erase the whole command.  I didn't have to erase the whole command on my infrared project. Thanks for your help.

Go Up