@woodinblack, thanks for your input! for a newbie, your code is impressively complex! i'm not quite sure how i can revise it, given my skill level.
in the meantime, i've adjusted my code to include a sine wave, which has brought me much closer to my end goal. here's what i have so far . . . please disregard the artifacts from the earlier version, i'll be editing them out soon.
#include <SPI.h>
/*
Fade
This example shows how to fade an LED on pin 9
using the analogWrite() function.
This example code is in the public domain.
*/
int sensorPin = A3; // the pin that the sensor is attached to
int LEDpin = 9; // the pin that the LED is attached to
int brightness = 0; // how bright the LED is
int fadeAmount = 1; // how many points to fade the LED by
int proximity;
int maxBrightness;
int pwmActual[] = {
0, 1, 2, 3, 4, 5, 7, 9,
12, 15, 18, 22, 27, 32, 37, 44,
50, 58, 66, 75, 85, 96, 107, 120,
133, 147, 163, 179, 196, 215, 234, 255
};
float counter;
float val;
int minMap, maxMap;
// the setup routine runs once when you press reset:
void setup() {
// declare pin 9 to be an output:
pinMode(LEDpin, OUTPUT);
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
proximity = analogRead(sensorPin); // returns 0 to 1023 in theory (0-5V), but TEST SENSOR
// Serial.println(proximity);
minMap = map(proximity, 0,1023, 0,45);
maxMap = minMap + 128;
counter += .1;
val = sin(counter) * 1000;
val = map(val, -1025,1025, minMap, maxMap);
analogWrite(LEDpin, val);
//Serial.println(sin(counter));
Serial.println(maxMap);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
i suppose my remaining issue is this:
i'd like to lower the peak brightness value when the viewer is not in close range of the IR proximity sensor. i tried to revise the value here:
minMap = map(proximity, 0,1023, 0,45);
i experimented with bringing 45 down to various other values, but i didn't see any perceptible difference.
i feel like the answer is really obvious, yet i just can't fix this.