/*
* Throb
*
* A variation on Blink. This sketch presents the concept of PWM or
* Pulse Width Modulation. It "throbs" the brightness of an LED, making it
* gradually brighter and dimmer.
*
* From Blink: We use pin 13 because,
* depending on your Arduino board, it has either a built-in LED
* or a built-in resistor so that you need only an LED.
*
*/
int ledPin = 9; // LED connected to digital pin 13
// once this is working, reprogram with a cycle time of 100 to see more clearly how the throbbing works
int cycleTime = 30; // the total duration of a PWM cycle
int cycleRepeat=3; // repeat each cycle to slow PWM effect
int changeSpeed = 1; // throb speed, or the number of milliseconds to change the onTimePerCycle per Cycle
boolean brightnessGoingUp = true; // whether the brightness is going up or down
int onTimePerCycle = 0; // the number of milliseconds to turn the LED within a cycle
void setup() // run once, when the sketch starts
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
}
void loop() // run over and over again
{
for (int i=0;i<cycleRepeat;i++) {
digitalWrite(ledPin, HIGH); // sets the LED on
delay(onTimePerCycle); // wait for onTimePerCycle milliseconds
digitalWrite(ledPin, LOW); // sets the LED off
delay(cycleTime - onTimePerCycle); // waitfor the rest of the complete cycle
}
// Now adjust the brightness up or down depending the the current state
if (brightnessGoingUp) {
onTimePerCycle += changeSpeed;
}
else {
onTimePerCycle -= changeSpeed;
}
// if we are at full brightness, where the LED is on for the complete cycle
if (onTimePerCycle >= cycleTime) {
brightnessGoingUp = false; // switch mode to brightness going down
onTimePerCycle = cycleTime; // make sure brightness did not go over
}
// if we are at zero brightness, where the LED is not on at all in a cycle
if (onTimePerCycle <= 0) {
brightnessGoingUp = true; // switch mode to brightness going up
onTimePerCycle = 0; // make sure the onTime didn't go bellow zero
delay(3000);
}
}
Did you simulate this and maybe have an LTSpice circuit?Here is first cut of a lighthouse light ckt; wanted to mimic reverse of RC discharge curve by building charge curve in segments to allow slow buildup, fast peak light then just RC discharge. Total cycle time set by U2 @ about 10 sec. U1 , segment time of about 1/2 sec. ORd first 3 times for slow rise, 4 th transition, & 5 th final rise.. Timing Rs set with R- substitution box. More time slots could be made available by using 4017 with 8 available time slots, 0 saved for reset, 9 for discharge. Pinout different from 4022.
Yes, that's what I had on hand. I was trying to make a slow ramping intensity then quick strobe then ramp back down and repeat. Maybe I should just settle for ramping on and off type setup. Thanks for your help. I have a 12v LED driver circuit.How bright do you want, something like 20 mA, white LED? Power source ?
Man, lot a stuff going on in that circuit. That looks exactly like what I was looking for. Can I use any common transistors within reason? I should have almost everything else. Wish I had more equipment (besides multi-meter and cheap breadboard) My lighthouse is only 10" tall. What kind of LED are you using? I do very little electronic stuff, obviously. Went to tech school 30 years ago in T.O. and never worked in this field so I'm kinda slow. Thanks very much for sending this and I'll take a stab at it (going to take a while) and let you know how it went, if your interested. Kinda cool getting help from 5300 km away. N.S.This works on breadboard. The 555 up & down time can be individually selected by R1 & R2. Ckt is in 3 parts, 555, C3 charging with LED driver U2, & U3, pulser. so can be built & tested in sections.Ramping up to desired brightness controlled by R5 . When U1-3 goes low, neg. edge passes thru C2, is inverted by U3, collector then briefley pulls U2 base high giving bright pulse.. R8 keeps C3 from swamping the short pulse. Will try to answer any questions>View attachment 84442
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
B | Model RC Plane | Marketplace | 2 | |
S | Add Model to SOAtherm-Nmos blocks in LTspice ..#2 | PCB Layout , EDA & Simulations | 0 | |
Y | finding footprint for RF connector model | Wireless & RF Design | 1 | |
SPICE Model for MAX13256 | PCB Layout , EDA & Simulations | 4 | ||
lighthouse in a bottle model. | General Electronics Chat | 100 |