Added: 2 years ago
From: MeierUTube
Views: 3,267
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:

All Comments (19)

Sign In or Sign Up now to post a comment!
  • Do you have an email where we coulf talk about your project.

  • @torresfelipe Sure. Send me a personal message with your e-mail address and I will reply to that address.

  • Great work man, easy enough perhaps but still a really great project!

  • Code, Part 6 (last part): // calculate the average: average[i] = total[i] / numReadings; // Set the LED color delay(3); analogWrite(outputPin[i], average[i]); }

    }

  • @MeierUTube Thanks for help I will try to make something similar. I will publish the result when it will be done and let You know about it. Thanks again. Cheers! :D

  • Code, Part 5: // add the reading to the total: total[i] = total[i] + readings[i][index]; // advance to the next position in the array: index = index + 1; // if we're at the end of the array...  if (index >= numReadings) // ...wrap around to the beginning: index = 0;

  • Code, Part 3:

    // Averaging

    int readings[3][numReadings]; // the readings from the analog input

    int index = 0; // the index of the current reading

    int total[3] = {0, 0, 0}; // the running total

    int average[3] = {0, 0, 0}; // the average

  • Code, Part 4:

    void setup() {

    }

    void loop() { // read the analog in values: for (int i = 0; i <= 2; i++) { // subtract the last reading: total[i] = total[i] - readings[i][index]; // read from the sensor: readings[i][index] = analogRead(inputPin[i]); // Correct maximum if necessary rangeMax = min(max(readings[i][index], rangeMax), maxMax); readings[i][index] = map(min(max(rangeMin, readings[i][index]), rangeMax), rangeMin, rangeMax, 0, 255);

  • Are those filters made for definite screen resolution or these are the parameters of low pass filter for any resolution? Is it possible to rectify the output signal of the low pass filters with usage of a simple diode rectifier and a capacitor? Can You upload the project somewhere?

  • @macigli I'm going to break up my response into multiple comments because it is going to be too long to fit into one.

    Part 1:

    The filter works for most resolutions (at least the ones I tried) reasonably well. The current code just runs the A/D converter freely and not synchronized to the VGA frame rate at all.

  • @macigli, Part 2:

    A better way would be to use the VSYNC to trigger an interrupt once per frame and sample the VGA signals in the interrupt service routine so that they are always acquired at the same timing position within the frame. It's currently just a proof of concept, and I haven't had a chance to look into that to see how to implement interrupts triggered by events on digital I/Os. If you have any insight, please let me know.

  • Part 3:

    You can experiment with the filter values to make it faster or slower. Slower means that your will see less fluctuations but transitions will be slower (softer). I prefer them to be not too slow, but others may like the softer transitions better.

  • Part 4:

    Instead of an RC filter to extract the DC average, you can use a diode and a capacitor, but you would extract the envelope of the signal instead, which works great for fast transitions from dark to bright, but will be very slow going from bright to dark because there is nothing discharging the capacitor unless you add a load resistor. But it may actually look very cool, it wouldn't hurt trying it out. The current code should work with any type of filter pretty well.

  • Part 5:

    The source code is actually pretty simple and short enough to be posted here as a comment (multiple, actually).

  • Code, Part 1:

    /* VGA Ambilight Reads 3 analog input pins, maps the result to a range from 0 to 255 and uses the result to set the pulsewidth modulation (PWM) of 3 output pins. The circuit: * Analog inputs on pins 0/1/2. * PWM ouputs on pins 9/10/11 created 1/7/2010 by Roger Meier */

  • Code, Part 2:

    // Constants

    const int numReadings = 10;

    int rangeMin = 0; // Range of the ADC values

    int rangeMax = 255; // Range of the ADC values

    int maxMax = 1023;

    // Pins and Values

    int inputPin[3] = {0, 1, 2};

    int outputPin[3] = {9, 10, 11};

  • How do you do that? I want it to!

  • The trick is to extract the DC offset of the three color signals on the VGA port. The DC offset corresponds to the current 'average' color of the picture. I found that a good filter is a simple first-order low pass using a 100k resistor and a 100nF capacitor. Use one for each color signal. This will give you 3 DC signals (with a 60Hz ripple), that are proportional to the average color values. Use the Arduino to sample (and filter out the ripple) these signals and generate PWMs to drive the LEDs.

Loading...
Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more