I am trying to make a interactive LED lights (addressable LED strip) with DIY IR range sensors, it all works fine but I just can't figure out a way to calibrate them. I made few attempts but all totally failed, I'm working with 3x3 for testing but i want to expand it to the limits of the poor little arduino when it all works.
(gif of the working(ish) prototype)>>>>>> https://gfycat.com/lightheartedvaguebobolink <<<<<<<<
any help will be appreciated
The issue is that the values arduino reads are kinda allover for eac sensor but remain sonsistant for each sesor.
first reading second reading ..... and so on
LED 0 Value : 43 >> LED 0 Value : 52
LED 1 Value : 80 >> LED 1 Value : 78
LED 2 Value : 9 >> LED 2 Value : 11
LED 3 Value : 49 >> LED 3 Value : 49
LED 4 Value : 158 >> LED 4 Value : 159
LED 5 Value : 11 >> LED 5 Value : 9
LED 6 Value : 11 >> LED 6 Value : 7
LED 7 Value : 280 >> LED 7 Value : 277
LED 8 Value : 323 >> LED 8 Value : 328
I can't figure out how to map the values for each sensor
(some lines of code might be unnecessary but i left them in for the duration of bug fixes ill clean it up when it's working and i know what i don't need)
#include <FastLED.h>
#define COLOR_ORDER GRB
#define LED_TYPE WS2811
#define LED_PIN 5
#define NUM_LEDS 9 //LED count
#define MAX_BRIGHTNESS 50
#define MIN_BRIGHTNESS 50
#define BRIGHTNESS 50
#define SPEED 1000
struct CRGB leds[NUM_LEDS];
const int numOfInputs = 3;
const int inputPins[numOfInputs] = {0,1,2};
unsigned int analogVal[numOfInputs];
int analogPin[] = {0,1,2};
int digitalPin []={2,3,4};
int counter;
unsigned int analogSensorRead[2];
int i;
int j;
int hue;
int mappedHue;
int LEDno;
void setup() {
Serial.begin(9600);
LEDS.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(BRIGHTNESS);
for (int counter=0; counter <= 2; counter++){
pinMode(digitalPin [counter], OUTPUT);
}
}
void loop() {
for(int i=0; i<=2; i++){
digitalWrite(digitalPin[i], HIGH);
for(int j=0; j<=2; j++){
LEDno = ((numOfInputs-1)*i+i+j);
delay(5);
analogSensorRead[j] = analogRead(analogPin[j]);
//Serial.println((String) +"Sensor "+ LEDno + " Value: " + analogSensorRead[j]);
//Serial.println((String) +"Row "+ i + " Column " + j + " Value: " + analogSensorRead[j]);
//Serial.println(analogSensorRead[i][j]);
// LEDno = ((numOfInputs-1)*i+i+j+1);
hue = (analogSensorRead[j]);
mappedHue = map(hue, 0, 1023, 0, 255);
leds[LEDno] = CHSV(mappedHue, 255, 255);
Serial.println((String) +"LED "+ LEDno + " Value : " + hue);
//delay(300);
FastLED.show();
}
digitalWrite(digitalPin[i], LOW);
}
}
Thank you in advance ![]()