Converting Random Binary Data to PWM Signal
So, if you simplu has to convert the binary data to PWM signal there are few things you need to cover:


If the binary data that you are receiving from the sensor is linear or non linear.
What is the size of binary byte. Ex: int(16 bits),char(8 bits),long (32 bits).
If it is linear, then if the data is multiplied by some number it will output a value betwen 0-255.
If the data is not linear than you just need to create an giant array with the pwm intensite value direct without any particular mathematical function. Ex: array[1024] = {0,1,1,2,3,4,5,5,6,6,10,9,...}; (1024 values because if you are using analog input. Then you can direct output the values from array:

analogWrite(3,array[x]); //x being your data



Here's the linear Example:

   //map(value, fromLow, fromHigh, toLow, toHigh);
    y = map(x, 0, 1023, 0, 255);


Doing this, y will receive a value from 0 to 255. You just need to first do a simple serial program that prints you through arduino serial window the binary data and see if the data increases or decreases conform your light project.


I don't know about your programming levels or if you are using a digital sensor or analog sensor, but if you are using a digital sensor, so you are probaly using SPI communication or i2c. Then you just need to read that binary data and take where the values bits are with bit wize manipulation.

y=(x &amp; (0xfff&lt;&lt;3))&gt;&gt;3;



Tell me more about the source of data, how this data is and how is the behavior of the data so i can help you a lot more. Thanks