It's binking I was using the fade code but it bink's no fade
// These constants used to give names
// to the pins used:
const int analogInPin = A0; // Analog input pin that the PIR is attached to
int sensorValue = 0; // value read from the PIR
int ledPin = 8;
void setup() {
pinMode(ledPin, OUTPUT); // sets the digital pin as output
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
// print the results to the serial monitor:
Serial.print("sensor = ");
Serial.print(sensorValue);
Serial.print("\t output = ");
Serial.println(sensorValue);
if (sensorValue >= 500 )
{
digitalWrite(ledPin, HIGH);
}
else
{
// fade out from max to min in increments of 5 points:
for (int fadeValue = 255 ; fadeValue >= 0; fadeValue -= 5) {
// sets the value (range from 0 to 255):
analogWrite(ledPin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
// wait 2 milliseconds before the next loop
// for the analog-to-digital converter to settle
// after the last reading:
delay(200);
}
This is what im trying for if sensor value >= 500 the led stays on if it drops below 500 the led is to fade out.
Then stay off till the sensor value goes above 500
It read about 780 as long as there is something moving
Every time through loop() if the sensor's under 500 it does your 255 to 0 for loop: it doesn't know you only mean to fade once until it goes solid on with a >500 and then hits the new first <500 to fade later.
You need a flag, say a boolean called "goneHigh" which you set when the sensor is over 500, ie when you on the led. Then your test for under 500 needs to include a test to see if goneHigh is true. If it is high, do the dimming thing AND set goneHigh to false.
edgemoron Thanks that was next on my list I was kind of testing it out last night to see if it works and what it pt out
it's going from 0 to around 3.8 volts so it would workout nice.