Project: Chromatic Clock -//- Forced Synesthesia

73 views
Skip to first unread message

Ian Williamson

unread,
Jan 25, 2013, 10:40:12 AM1/25/13
to not-just...@googlegroups.com
Following Idbl's advice I'm posting up my project details. 

To reiterate, I am a code and electronics novice. I'm an anthropologist, designer and artist and work in and around digital cultures.
If anyone thinks of a way my skills might be useful to them please do let me know.

Also, I'm not looking for a "walkthrough" here just a little tutoring. Enough preamble....

I am working on a Chromatic Clock design that is an experiment in forced synesthesia (the neurological mixing of senses; like tasting colour). What I am hoping is that when I wake at night and look over to a corner of my room I will realise: "Oh crap! it's violet I have to get up soon" And as time passes I will develop a chromatic sense of time. And since I have certain difficulties with letters and numbers I am interested to see if this will aid my organisational abilities.

The clock will have no dials or numbers and will not tell the time in any detail. The current prototype will use a 8X8 RGB LED matrix controlled using an Arduino UNO's PWM outputs to control a 24hr 256 colour RGB spectrum. I have attached a little diagram.

This set up will be linked up to a RTC (DS1307). I already have both aspects (matrix & RTC) of this working independently, that was easy. My issue is in coding these to talk to each other.

The 1440 mins of day /3 = 480.
I am tempted to reduce the 0-255 down to 0-239 as this results in much simpler maths 480/240=2

So the pattern for blue could be 

(Min0 to Min480)= OFF

(Min481 to Min960)= Increment up one every 2 mins

(Min961 to Min1440)= Increment down one every 2 mins

I know that if I had one table that described blue's pattern the other colours could reuse it with a 480 min offset.

All of this logical stuff is quite straight forward but when it comes to writing the code every time I try I realise I have know idea what I'm doing and the computer and Arduino both say NO!

What think ye? I know I am jumping from the flashing LED project to this quickly but I'm an inpatient fellow.

Cheers! Thank for you time


Ben Barwise

unread,
Jan 25, 2013, 12:31:55 PM1/25/13
to Ian Williamson, not-just...@googlegroups.com
I am not coding expert, but I like thinking about it, an idea is you could make it change the state every 2 clock counts not sure if this would work? maybe there is a more elegant way

if ( RTC >= lastRTC+2 )
      { 

          if (RTC <= 240) {redpin++; analogWrite(9,redpin);} else if (RTC >= 241 && <=480){redpin--; analogWrite(9,redpin);}
         etc for green and blue

lastRTC = RTC;

 }

RTC being the direct reading from the clock




--
You received this message because you are subscribed to the Google Groups "Not Just Arduino" group.
To post to this group, send an email to not-just...@googlegroups.com.
To unsubscribe from this group, send email to not-just-ardui...@googlegroups.com.
Visit this group at http://groups.google.com/group/not-just-arduino?hl=en-GB.
 
 

Necati

unread,
Jan 28, 2013, 1:17:29 PM1/28/13
to not-just...@googlegroups.com, Ian Williamson
Hi Ian
I also used DS1307 real time clock chip and 4* 20 LCD module. It should be fairly easy to  get them working together if you have working them separately. there are a couple of different libraries forDS1307 so the actual code will depend on whjich one you are using. Bring your project tonight to NJA group meeting then we should get it working soon like this evening. 

Necati

Ian Williamson

unread,
Jan 29, 2013, 12:23:06 PM1/29/13
to not-just...@googlegroups.com
Thanks Ben and Necati,

I think I see what you mean Ben. The but I am confused as to how this will play into the 1440 minutes of the day.

I was going to go the direction of:

if minute < 480
if minute is <960
else 

It had been suggested to me that 240 * (minute - 480) / 480 will give a number for the LED.


I had planned to attend tonight's meeting but I am already triple booked. I'm a convenor for one of the commitments. 

I WILL be at the next meeting though!!!! I promise. 

Necati

unread,
Jan 29, 2013, 12:40:11 PM1/29/13
to not-just...@googlegroups.com
Hi Ian
If you post your Arduino codes to github web site for code sharing  or just attach in your email then we can suggest exactly what needs to change.

Necati

Ian Williamson

unread,
Jan 30, 2013, 6:18:49 PM1/30/13
to not-just...@googlegroups.com
Nigel Worsley replied to me with this but it didn't seem to post in the group:

"I think you are best forgetting about minutes and just using seconds. Each day is 86,400 seconds and divided by 113 gives you 764.6, pretty much exactly the 765 different states required. The final colour of the day will be 40% shorter than the others, at only 68 seconds.

Thanks Nigel I do like those numbers.


I will do that Necati, but really there is not much to show. I can understand how to write bits of arduino code but I have difficulty composing sketches

Ian Lewis

unread,
Jan 31, 2013, 1:39:49 AM1/31/13
to not-just...@googlegroups.com
you know you can use the Map command to 'make' your values fit http://arduino.cc/en/Reference/map .  Maybe you could map time against 0 255 values on the LED's to match (that is a random, 0630, thought and may not be valid!)

Ian 

Bradley Wood

unread,
Feb 26, 2013, 6:48:42 AM2/26/13
to not-just...@googlegroups.com
I've been thinking of doing something similar on my LED matrix -- in the end I copped out a bit and did this:

ORANGE -- morning - 6am - 11am
RED, -- midday - 11am - 2pm
GREEN -- afternoon - 2pm - 5pm
MAGENTA (pink) -- evening 5pm - 9pm
BLUE -- night -- 9pm - 6am

I like this as the germ of an idea, as I'd like to be able to associate a particular colour with a particular time of day, e.g: Orange = sunset, Red (HOT) = midday, Blue, night, etc...

Maybe an algorithm to consider is to fix 5 or 6 times as specific RGB values during the course of the day and then interpolate RGB values for the intervening periods.

If you know your target color (the next one coming up) and your current colour, as well as the time needed to get to that colour, you should be able to calibrate an algorithm that moves the RGBs linearly towards that target over the allotted time window...

Just an idea...

Brad

On Friday, 25 January 2013 15:40:12 UTC, Ian Williamson wrote:

Bradley Wood

unread,
Mar 14, 2013, 7:36:36 PM3/14/13
to not-just...@googlegroups.com
I've implemented a bit of code for this now, which, while untested, looks like it's working.

Here goes:

Step one -- define a static PROGMEM array of RGB values for each hour in the day (my RGB uses 4 bits per channel = 4096 colors). I did the on-hour interpolation manually in excel to create this static data. It uses an array of struts...

//type definition for defining RGB color codes for each hour of time.
typedef struct RGBT {
int r;
int g;
int b;
};
//colors for the clock for each hour: 0-23....
PROGMEM static RGBT timecolors[] = 
{
{0,0,15}, //0  BLUE
{4,4,12}, //1  
{8,8,8}, //2  
{12,12,4}, //3  
{15,15,0}, //4  YELLOW
{15,13,0}, //5  
{15,11,0}, //6  
{15,9,0}, //7  
{15,7,0}, //8  ORANGE
{15,5,0}, //9  
{15,3,0}, //10  
{15,1,0}, //11  
{15,0,0}, //12  RED
{12,4,0}, //13  
{8,8,0}, //14  
{4,12,0}, //15  
{0,15,0}, //16  GREEN
{4,12,4}, //17  
{8,8,8}, //18  
{12,4,12}, //19  
{15,0,15}, //20  MAGENTA
{12,0,15}, //21  
{8,0,15}, //22  
{4,0,15} //23
};

Then create a function that given an hour or minute, returns an interpolated RGB value between the passed hour and the next hour coming up.

RGBT getTimeColor(int h, int m)
{
// define 3 RGB triplets...
RGBT lower_hour_color, upper_hour_color, interpolated_color;
//lookup the lower and upper RGB triplets from the static table
memcpy_P(&lower_hour_color, &timecolors[h],sizeof(lower_hour_color));
if(h==23) //handle the 23h00-00h00 roll-over
{
memcpy_P(&upper_hour_color, &timecolors[0],sizeof(upper_hour_color));
else 
{
memcpy_P(&upper_hour_color, &timecolors[h+1],sizeof(upper_hour_color));
}
//how we have the RGB triplets for h and h+1 o'click do a linear interpolation
//of their RGB values using the minute passed.
interpolated_color.r = map(m,0,59,lower_hour_color.r,upper_hour_color.r);
interpolated_color.g = map(m,0,59,lower_hour_color.g,upper_hour_color.g);
interpolated_color.b = map(m,0,59,lower_hour_color.b,upper_hour_color.b);
return interpolated_color;
}

then call this function with a given hour and minute and it will give you an RGB value back.

RGBT time_col;
time_col = getTimeColor(hour,minute);
ClockFaceColor = RGB(time_col.r,time_col.g,time_col.b);

Seems to work okay...

Good luck with it.

Brad


On Friday, 25 January 2013 15:40:12 UTC, Ian Williamson wrote:

Ian Williamson

unread,
Apr 3, 2013, 6:41:02 AM4/3/13
to not-just...@googlegroups.com
I have been very very distracted lately. very.



Thanks Bradley, I only just saw your posts today. 

Looks promising, let me test it out a bit.

Cheers!


On Friday, 25 January 2013 15:40:12 UTC, Ian Williamson wrote:

Bradley Wood

unread,
Apr 4, 2013, 7:09:54 AM4/4/13
to not-just...@googlegroups.com
No worries... I have an updated version of this that follows the RGB spectrum graphic you attached below exactly.

It's just a change in the PROGMEM data to be as follows:

//colors for the clock for each hour: 0-23....
PROGMEM static RGBT timecolors[] = 
{
{15,0,0}, //0  red
{13,1,0}, //1  
{11,3,0}, //2  
{9,5,0}, //3  
{7,7,0}, //4  dark yellow
{5,9,0}, //5  
{3,11,0}, //6  
{1,13,0}, //7  
{0,15,0}, //8  green
{0,13,1}, //9  
{0,11,3}, //10  
{0,9,5}, //11  
{0,7,7}, //12  turquoise
{0,5,9}, //13  
{0,3,11}, //14  
{0,1,13}, //15  
{0,0,15}, //16  blue
{1,0,13}, //17  
{3,0,11}, //18  
{5,0,9}, //19  
{7,0,7}, //20  purple
{9,0,5}, //21  
{11,0,3}, //22  
{13,0,1}, //23
};

It still uses hourly static data points which is a little bit inefficient for your algorithm's requirements as yours would only need 4-hourly increments in the static data given the RGB curves shown in the graphic.

You would save yourself a bit of PROGMEM space by doing it only on 4-hourly increments but I couldn't be arsed to make this optimisation as there's probably not much in it and I like having the flexibility of the RGB curve gradient changing on the hour.

Ian Williamson

unread,
Apr 5, 2013, 6:23:03 AM4/5/13
to not-just...@googlegroups.com
Cool. nice one. Have a good slot of time to play around with this later.



On Friday, 25 January 2013 15:40:12 UTC, Ian Williamson wrote:

Ian Williamson

unread,
Apr 5, 2013, 10:55:08 AM4/5/13
to not-just...@googlegroups.com
I may have replied to Bradley with this question already but I can't see any evidence of a sent reply.

I'm not too familiar with the struct type. In this case do I need to create an additional .d file?

I keep getting a error about the RGBT not naming a type. Or maybe I have to declare it somehow.


I think your right about the hourly fine tuning and it's not like I need the the flash mem space anyway. All in all, it seems to be a good route to go, once I overcome a couple of technical obstacles

Cheers!


On Friday, 25 January 2013 15:40:12 UTC, Ian Williamson wrote:

Ian Williamson

unread,
Apr 15, 2013, 10:18:31 AM4/15/13
to not-just...@googlegroups.com
Just to update:

I have a working prototype thanks to Bradley's advice, help and some pasted code.

Cheers. Will post up the code after a little editing and colour tuning

Ian

Ian Williamson

unread,
Apr 15, 2013, 10:18:31 AM4/15/13
to not-just...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages