Hi,
I'm working on a GPS clock that will express each hour with different color (12 would be red and the fading to yellowish until green around 3 o'clock). I was trying to modify NeoPixel Ring Clock, but didn't succeed. I'm using flora with GPS and NeoPixel strip. Do you guys have any advise where to search for a fix? I tried youtube and google, but it seems that everyone is showing time by moving pixels, where I want to play with color.
Thanks
Rainbow GPS clock
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_bill
- Posts: 88091
- Joined: Sat Feb 07, 2009 10:11 am
Re: Rainbow GPS clock
What exactly is broken? If you can describe the problem more precisely and post the code you are using someone might be able to help.Do you guys have any advise where to search for a fix?
- kldfkw
- Posts: 7
- Joined: Fri Aug 07, 2015 7:37 am
Re: Rainbow GPS clock
Where should I search for more tutorials with GPS clock and NeoPixels that will change color instead of location to reflect the time.
I tried using currentHour with if function to set the color of the strip, but didn't work. Any guides/readings that you can recommend for me?
I tried using currentHour with if function to set the color of the strip, but didn't work. Any guides/readings that you can recommend for me?
- kldfkw
- Posts: 7
- Joined: Fri Aug 07, 2015 7:37 am
Re: Rainbow GPS clock
Here's my code - can anyone help or just advise me some tutorials that will help me understand changing the color of the NeoPixel while GPS time passes
https://codebender.cc/sketch:140842
https://codebender.cc/sketch:140842
- adafruit_support_bill
- Posts: 88091
- Joined: Sat Feb 07, 2009 10:11 am
Re: Rainbow GPS clock
Take a look at the 'strandtest' sketch from the neopixel library. There is a 'Wheel' function that maps a value from 0-255 into a color of the rainbow.
To map an hour into a wheel color, you first need to convert it to a value between 0 and 255. This can be done with the map() function:
https://www.arduino.cc/en/reference/map
So if you add the Wheel() function to your program, your code could look something like this:
Code: Select all
// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if(WheelPos < 85) {
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
}
if(WheelPos < 170) {
WheelPos -= 85;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
WheelPos -= 170;
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}
https://www.arduino.cc/en/reference/map
So if you add the Wheel() function to your program, your code could look something like this:
Code: Select all
uint32_t color = Wheel(map(hour, 0, 11, 0, 255));
strip.setPixelColor(color);
Please be positive and constructive with your questions and comments.