Mike,
I believe my LED driver board was bricked. I had tried so many different connections today that I zapped it at some point apparently, probably last night. I found this out after my led burned out after being on for approx 15 seconds. I had 12v going straight through the driver board. Now, with a new board and the LED pin 1 from the digispark connected to the PWM pin on the board, my fade sequence is working, although backwards as I have not uploaded my inverted sketch yet.
I did notice that the fading did not seem as 'smooth' as it normally does. I assume this is due to the 500 Hz from the digispark and the 200Hz (+/-) expected by the driver board. Does that make sense? If so, how do I incorporate the Hz frequency code into my sketch? Your modified code has been added to the end of my sketch below: THANK YOU
I believe my LED driver board was bricked. I had tried so many different connections today that I zapped it at some point apparently, probably last night. I found this out after my led burned out after being on for approx 15 seconds. I had 12v going straight through the driver board. Now, with a new board and the LED pin 1 from the digispark connected to the PWM pin on the board, my fade sequence is working, although backwards as I have not uploaded my inverted sketch yet.
I did notice that the fading did not seem as 'smooth' as it normally does. I assume this is due to the 500 Hz from the digispark and the 200Hz (+/-) expected by the driver board. Does that make sense? If so, how do I incorporate the Hz frequency code into my sketch? Your modified code has been added to the end of my sketch below: THANK YOU
Code:
/*
VISIBLE_FEEDER_LIGHT_SKETCH_700ma
The circuit:
* LED (+) attached to PWM pin 1.
* motion sensor 'signal' attached to pin 2
* digispark microcontroller
last edit 8/17/2017
By John A. Austin
*/
int sensorPin = 2; //motion sensor out pin connected to digital pin 2 (P2 on digispark)
int ledPin = 1; // LED connected to digital pin 1 (P1 on digispark)
int fadeValue = 255; //initial led brightness (variable)
//int analogValue = analogRead(ledPin);
void setup()
{
// initialize the sensorPin as an input:
pinMode(sensorPin, INPUT);
// initialize the ledPin as an output:
pinMode(ledPin, OUTPUT);
}
//FUNCTIONALITY is reverse logic based on LED driver board PWM pin:
//read status of motion sensor (HIGH or LOW)
//If HIGH, fade leds from off to on over a one minute period
//then fade to off over a 32 second period
//wait 5 seconds and read sensor pin again
void loop()
{
analogWrite(ledPin, 255);
delay(5000);
if(digitalRead(sensorPin) == LOW) //if no signal is sent to P2 from sensor, it will loop back to start, then delay 5 seconds and read again:
{
loop;
}
else
{
for (int fadeValue = 255 ; fadeValue >= 0; fadeValue -= 1)
{
analogWrite(ledPin, fadeValue);
delay(235);
}
{
analogWrite(ledPin, 0);
delay(300000);
}
{
for (int fadeValue = 0 ; fadeValue <= 255 ; fadeValue += 1)
{
analogWrite(ledPin, fadeValue);
delay(125);
}
}
}
}
}
//loop while ...
//digitalWrite(ledPin,1);
//delayMicroseconds (4750); //95% duty cycle at 200Mz - delay 1
//digitalWrite(ledPin,0);
//delayMicroseconds(250); //delay 2
//end loop
//where 0<x<5000