![]() ![]() You then perform the analogWrite void updateLED() Then to decrement each value, red -= red > 8 You should be starting with int values scaled up by 255, that is you start with int red = 65536 //RGB values for the LED You are using effectively byte values to perform the calculations. If you really want to do this, you have to use software PWM in which you implement 65536 steps - the size of a standard "int".Īctually, I will give you another hint about your current code, which may just suffice. The limitation here is that the PWM values have only 255 steps. I am sort of sorry to tell you this, but part of your problem is basically insoluble because for very low PWM values, the steps become relatively large - from 5 to 4 for example, is a 20% difference. It's working closer to what I want, but the smaller the smallest value gets, the quicker the LED fades out, also, if there are any 0s in the RGB, for example full red (255,0,0), the LED flashes randomly and turns crazy. If the second is NO, then you have to stop at the 151, 1, 1 line.Īnyway, it is more your perception of the colour/s that is important. I can't remember the name of that colour, but anyway. Your example is not that good in that it is 255, 100, 100. I'm not sure how good with colours are for the ratio but at least it may hold the colour better than taking the LED to ZERO. Then, it will keep the "mixture" the same but then it will keep reducing the other values until they all get to one. It will start with your values, and reduce them by one each pass but NOT take them to 0. This looks a bit strange, but indulge me. It is just putting ideas/suggestions on the table. with the same RGB proportions as when you started out.īrain storming here, so forgive me if I am not 100% correct. Well, let's think about it one step back. You reduce all three values by one on each pass, with a pause so "we" get to see the colour.īut you run into the problem when G and B (in your example) get to 0. So you are starting with 255, 100, 100 in your example. PinMode(ledRedPin, OUTPUT) //Set R, G and B pins to output mode int ledRedPin = 10 //The pins that R, G and B are connected to You'll find that the green and blue turn of first, leaving just the red on for a little while, whereas I'd like the entire color to fade out at the same time, regardless of what the red, green and blue values are set to. ![]() Here's my code, which currently just goes from whatever RGB value is set to 0,0,0. ![]() Could you provide some code?Īt the moment, the lowest color values fade out first, instead of the desired effect of the entire color fading out. Hi, that has helped a bit, but I'm still having trouble getting all of the colors to fade out at the same time. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |