Show Posts
|
|
Pages: [1] 2
|
|
3
|
Using Arduino / LEDs and Multiplexing / Re: High Power LED - Fade on, flicker and fade off.
|
on: March 11, 2013, 02:16:48 pm
|
"Delay" is the devil's function.
^^^^  Starting to see this in my own code. But the delay function is why. To fix this, use the functionality like that in the "BlinkWithoutDelay" example provided in the Arduino IDE. It's also available on their website. The turning off will occur when your flicker is happening, you just have to hit the button a very precise time. The blinkwithoutdelay code basically reads a button according to time. Check out that example, and it should be able to help. I'm actually trying to use it in my code as well (I was running into the same problem as you are.)
|
|
|
|
|
5
|
Using Arduino / LEDs and Multiplexing / Re: Need 10v PWM signal
|
on: March 11, 2013, 11:54:03 am
|
According to the datasheet the PWM input needs 2.5-6V. 10V would break it.
It will break it. Trust me. Twice burning boards was due to using more than 5V. As everyone says, we don't completely understand what you're doing. If anything, plug in a 10V source and use the Vin to get the 10V back (in an Uno, for instance). All you should need to do is use the 10V for power. Everything else is done with 5V (buttons, etc). Basically, use only the 10V for power. Touch nothing else with it. You will not be happy with results of burning boards. Hope this helps.
|
|
|
|
|
7
|
Using Arduino / Programming Questions / Mode Switch Middle of if statement??
|
on: March 07, 2013, 11:33:41 pm
|
Hey all, I have some code that runs a LED strip. My problem is one of the "effects" I have is that it turns on different LED's (Making a rainbow)(red on, blue on, red off, green on, etc...). However, the thing I don't like is that it is not being registered that a button is being pushed to switch modes until it reaches the end of the effect.... Is there a piece of code (or a command) that will read in a button push in the middle of an if statement? I know that it's in the middle of an if while in a loop, so it may not be possible and mode switch may only be able to happen at the end of the command. I don't know if there is an on button interrupt? Mode 8 in the code is the one I'm looking at...mode 7 does the same as well. Thanks in advance for help! /* Not all code is mine!! Some code by Joshua David --- TechHelpBlog.com Some code by Arduino.CC Some code by Adafruit for SetColor; Some code found for public domain use (author not in comments) all compliled by Lance == cub526 and free to use!! */
// this constant won't change: const int buttonPin = 2; // the pin that the pushbutton is attached to const int ledPin = 13; // the pin that the LED is attached to
// Variables will change: int buttonPushCounter = 0; // counter for the number of button presses int buttonState = 0; // current state of the button int lastButtonState = 0; // previous state of the button
//variables for our pins int redPin = 9; int greenPin = 10; int bluePin = 11;
//Set Initial Values int RedVal = 0; int GreenVal = 0; int BlueVal = 0; int fade = 15; // Delay Time
//two colors below are my school colors //midnight blue int RedVal1 = 25; int GreenVal1 = 25; int BlueVal1 = 112;
//gold // Colour Value 2 int RedVal2 = 255; int GreenVal2 = 215; int BlueVal2 = 0;
int mode = 1; //used for mode slection in certain if's
void setup() { pinMode(redPin, OUTPUT); pinMode(greenPin, OUTPUT); pinMode(bluePin, OUTPUT);
// initialize the button pin as a input: pinMode(buttonPin, INPUT); // initialize the LED as an output: pinMode(ledPin, OUTPUT); // initialize serial communication: Serial.begin(9600); }
void loop() { // read the pushbutton input pin: buttonModeChange(); if (buttonPushCounter == 10) { //we've hit the end of the loop, go back to one! buttonPushCounter = 1; Serial.println("Change"); } if (buttonPushCounter == 1) {//red setColor(255, 0, 0); Serial.println("1"); } if (buttonPushCounter == 2) { setColor(0, 255, 0); // green Serial.println("2"); } if (buttonPushCounter == 3) { setColor(0, 0, 255); // blue Serial.println("3"); } if (buttonPushCounter == 4) { setColor(255, 255, 0); // YELLOW Serial.println("4"); } if (buttonPushCounter == 5) { //fade between two colors if(mode == 1){ if(RedVal < RedVal1){ // If RedVal is less than desired RedVal1 RedVal ++; // increment RedVal } else if(RedVal > RedVal1){ // If RedVal is more than desired RedVal1 RedVal --; // decrement RedVal } else if(RedVal == RedVal1){ // If RedVal is equal to desired RedVal1 //Do Nothing } // Repeated as above for BlueVal if(BlueVal < BlueVal1){ BlueVal ++; } else if(BlueVal > BlueVal1){ BlueVal --; } else if(BlueVal == BlueVal1){ //Do Nothing } // Repeated as above for GreenVal if(GreenVal < GreenVal1){ GreenVal ++; } else if (GreenVal > GreenVal1){ GreenVal --; } else if (GreenVal == GreenVal1){ // Do Nothing } // Now we have a new set of values, we write them to the PWM Pins. analogWrite(redPin, RedVal); analogWrite(greenPin, GreenVal); analogWrite(bluePin, BlueVal); delay(fade); // Implement a bit of delay to slow the change of colour down a bit
if(RedVal == RedVal1 && GreenVal == GreenVal1 && BlueVal == BlueVal1){ // If RedVal & GreenVal & BlueVal are all at the desired values delay(1500); // Delay to hold this colour for a little while mode = 2; // Change the mode to the next colour. Exiting this while loop and into the next one } } if (mode == 2){ if(RedVal < RedVal2){ // If RedVal is less than desired RedVal1 RedVal ++; // increment RedVal } else if(RedVal > RedVal2){ // If RedVal is more than desired RedVal1 RedVal --; // decrement RedVal } else if(RedVal == RedVal2){ // If RedVal is equal to desired RedVal1 //Do Nothing } // Repeated as above for BlueVal if(BlueVal < BlueVal2){ BlueVal ++; } else if(BlueVal > BlueVal2){ BlueVal --; } else if(BlueVal == BlueVal2){ //Do Nothing } // Repeated as above for GreenVal if(GreenVal < GreenVal2){ GreenVal ++; } else if (GreenVal > GreenVal2){ GreenVal --; } else if (GreenVal == GreenVal2){ // Do Nothing } // Now we have a new set of values, we write them to the PWM Pins. analogWrite(redPin, RedVal); analogWrite(greenPin, GreenVal); analogWrite(bluePin, BlueVal); delay(fade); // Implement a bit of delay to slow the change of colour down a bit
if(RedVal == RedVal2 && GreenVal == GreenVal2 && BlueVal == BlueVal2){ // If RedVal & GreenVal & BlueVal are all at the desired values delay(1500); // Delay to hold this colour for a little while mode = 1; // Change the mode to the next colour. Exiting this while loop and into the next one } } } if (buttonPushCounter == 6){ // all white setColor(255,255,255); Serial.println("6"); mode = 1; //for the previous effect, need to change this back to 1 for future use (we don't know what it was before) } if (buttonPushCounter == 7) //fourth of july Effect { if (mode == 1){ setColor(255, 0, 0); // red delay(250); mode = 2; } if (mode ==2) { setColor(255, 255, 255); // white delay(250); mode = 3; } if (mode ==3) { setColor(0, 0, 255); // blue delay(250); mode = 1; } }
if (buttonPushCounter == 8) { int r, g, b;
// fade from blue to violet for (r = 0; r < 255; r++) { analogWrite(redPin, r); delay(fade); } // fade from violet to red for (b = 255; b > 0; b--) { analogWrite(bluePin, b); delay(fade); } // fade from red to yellow for (g = 0; g < 255; g++) { analogWrite(greenPin, g); delay(fade); } // fade from yellow to green for (r = 255; r > 0; r--) { analogWrite(redPin, r); delay(fade); } // fade from green to teal for (b = 0; b < 255; b++) { analogWrite(bluePin, b); delay(fade); } // fade from teal to blue for (g = 255; g > 0; g--) { analogWrite(greenPin, g); delay(fade+3); }
}
if (buttonPushCounter == 9) { setColor(0,0,0); //all off Serial.println("ALL OFF: 8"); mode =1; //all done for loop, mode = 1 again just in case; } }
void setColor(int red, int green, int blue) { analogWrite(redPin, red); analogWrite(greenPin, green); analogWrite(bluePin, blue); }
void buttonModeChange () { buttonState = digitalRead(buttonPin);
// compare the buttonState to its previous state if (buttonState != lastButtonState) { // if the state has changed, increment the counter if (buttonState == HIGH) { // if the current state is HIGH then the button // wend from off to on: buttonPushCounter++; Serial.println("on"); Serial.print("number of button pushes: "); Serial.println(buttonPushCounter); } else { // if the current state is LOW then the button // wend from on to off: Serial.println("off"); } } lastButtonState = buttonState; }
|
|
|
|
|
8
|
Using Arduino / LEDs and Multiplexing / Re: led fader project
|
on: March 06, 2013, 12:31:33 pm
|
Apologies for not giving more info on the led strips. I am using the single colour white led strips, so they will only have 2 wires 12v+ and neg. Is it possible with these? Thanks
Anything is possible in the world of Electronics. Yes, it is possible with these. As i said earlier though, each strip (so 5 strips) will need to be PWM-ed. Since there is only one color, you will only need 5 PWM ports, so an Uno, for example, will work perfectly!! Instead of trying to explain, this example from Adafruit is what I am using doing this project. Granted, it uses a RGB strip, but it should be the same thing (and according to their site it is!): http://learn.adafruit.com/rgb-led-strips/usageHope this helps!!
|
|
|
|
|
9
|
Using Arduino / LEDs and Multiplexing / Re: led fader project
|
on: March 06, 2013, 12:52:18 am
|
Hi Everyone I am new to Arduino and I have an led project i'd like to attempt. I have 5 x 1m strips of led's operating on a 12vdc supply. I need to have them switch on sequentially, but with fading. When triggered, strip 1 needs to fade in to maximum brightness, stay on for 2 minutes and fade out. Strip 2 will then fade in and do the same for the rest until strip 5 fades out. Sequence would then start again. I have fairly good electronic knowledge but not on arduino. Please advise as to what I require to get me started. Thanks Guys.
I'm assuming you are using static strips. Meaning, The four wires are 12V DC, Red, Blue, and Green. (not in that order, possibly). For these types of strips, what you want to do is impossible, unless you connect each strip to it's own ports in the arduino (All can use 12 V). However, if you want them to fade, each wire would have to be connected into a PWM Port. I know for the arduino, there is only 6 of these (So only 2 total strips could fade). So for 3 colors * 5 strips, you'd need 15 PWM ports. You may be able to do it with a latch and such. But pure Arduino, it's impossible. **Note: I'm also assuming you're using RGB LED strips.**
|
|
|
|
|
10
|
Using Arduino / General Electronics / Soldering LED Strip
|
on: February 24, 2013, 07:49:19 pm
|
|
Hey all,
I am trying to solder some LED strips together. I removed the silicon with a carpenter knife and can't seem to still get a good solder (probably left over silicon still)
I read online to use sandpaper on the connectors to try and get a better surface.
Has anyone done this before?? Any recommendations on the type of sandpaper?
Thanks!!
|
|
|
|
|
14
|
Using Arduino / Installation & Troubleshooting / Re: Ardruino Uno Not Uploading After using 12V
|
on: February 17, 2013, 06:27:05 pm
|
|
Hey Nick, I have the LED's connected straight into the breadboard. I followed this exact schematic, except I plugged into Vin. Also, my power supply is 3A, 12V
Somehow though, it started doing this when incorporating a button into the mix (I'm trying to switch LED modes).
I did the arduino set up using the LED on the board, then set up the LED strip. Then i ran the voltage to the LED's
If you want and if it would help, I can do a breadboard design. I hope you understand what I"m saying.
Thanks again for the help...kind of frustrating when the button was working, the LED strip was working, but together it doesn;t.
|
|
|
|
|
15
|
Using Arduino / Installation & Troubleshooting / Ardruino Uno Not Uploading After using 12V
|
on: February 17, 2013, 04:37:41 pm
|
|
Hey all,
I'm running Win7 using an arduino Uno. I am running 12 V into it to use it for an LED strip.
However, it will no longer upload code and I get the avrdude: stk500_getsync(): not in sync: resp=0x00 error.
Nothing seems fried (no markings)
Any ideas? I bought two new chips (this is the second time this has happened...), and replacing it on the first one did nothing.
I really hope I don't have to buy another board....let me know any suggestions.
|
|
|
|
|