Arduino Ambilight on MacBook Pro
Uploader Comments (MeierUTube)
All Comments (19)
-
Great work man, easy enough perhaps but still a really great project!
-
@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 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};
-
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 */
Do you have an email where we coulf talk about your project.
torresfelipe 1 year ago
@torresfelipe Sure. Send me a personal message with your e-mail address and I will reply to that address.
MeierUTube 1 year ago
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 1 year ago
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;
MeierUTube 1 year ago
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
MeierUTube 1 year ago
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);
MeierUTube 1 year ago