Bukit Mertajam, Penang

Make Your Own Colourful Plate for Your Home


Hi everyone, did you watch our Selamat Hari Raya Aidilfitri 2015 video? In that video I use Cytron RainbowBit to make the colourful plate. The number of  the RainbowBit that light up is controlled by the analog distance sensor. When the analog distance sensor detect the object nearer, more RainbowBit will light up and when the distance is less than or equal to 20 cm, all the RaibowBit will light up and make a beautiful cycle of colours.



All this 10 component is needed to make this robot.  



The Analog Distance Sensor need to use ADC to convert the analog value to digital value for distance reading value. This sensor needs 5 Volts to operate. From the figure above, the valid output voltage value when the sensor detect the reflective object between 10cm to 80cm is from 0.4 Volts to 2.79 Volts.

The distance will be calculated by 5 Volts divided by 2^10 and multiply with analogRead(ADC), (5 / 2^10)*analogRead(ADC) ). The analogRead(ADC) will give valid value when it is between 0.4 Volts and 2.79 Volts. So, the value can be constrain to 82 and 573.


To make the graph linear, just use the basic line equation.



y = linearized range = 1/distance+k

x = ADCacc

k = 4 (From datasheet)

Line equation after substitution : 1/(distance+k) = m*ADCacc+c

Now, arrange the formula to get the distance value :

distance = (1 / (m*ADCacc + c)) – 4

To make simple to pre-compute : 

distance = (1 / m) / (ADCacc + c / m) – 4

Thus, by solving the equation :

distance = (6787 / (ADCacc – 3)) – 4

Please make sure the object is in the sensor’s range (c/m value is greater than 3), else it will be divided by zero error.

For more information, you can refer here.



1. Firstly, you have to solder all the six holes of RainbowBit wit straight pin header. For this project, I use 77 RainbowBit.

2. Then, I stack all the RainbowBits to the softboard and form a word of ‘Cytron’. You can use your own creativity for your RainbowBit.

This is the connection of the wire for the RainbowBit. Please make sure that the connection is from

i).   “-” to “-“

ii).  “+” to “+”

iii). “O” to “In” 

3. Cuteduino runs on 5V. So I need to adjust the potentiometer to make sure that the output voltage is 5V. 

4. Next, I made a simple circuit by using adjustable DC to DC converter, Cuteduino, HL2527 Dc Plug. I connect all the RainbowBits and the Analog distance sensor to the Cuteduino.

I made this circuit because the current needed for all 77 RainbowBit is not enough if it depends on Cuteduino only .

Lastly, I just connect the Adapter 12V 2A with the HL2527 DC plug and turned ON the switch. Now I finished create this DIY home plate.


Please refer to CuteDuino USB Tutorial.


Since number of the RainbowBit that light up is controlled by the analog distance sensor, we need to calculate the distance for the sensor. The code below show formula to calculate distance and this has been explained in the additional information earlier on how the formula is obtained.

[code lang=”c” highlight=””]
ADCacc = constrain (ADCacc, 82, 573);
distance = (6787/(ADCacc -3)) – 4 ;

You also can control the brightness of the rainbow bit by using the source code shown below. The full brightness of the RainbowBit is 255.

[code lang=”c” highlight=””]




Related Posts

Leave a comment