Technology for everyone
- New Hope For Open Source Textbooks
- Archaeologists strike gold in quest to find Queen of Sheba's wealth
- Bringing a 50,000-ton forging press back to Life
- What to make of AT&T’s vanishing spectrum crisis | Broadband News and Analysis
- Piltdown Man: British archaeology's greatest hoax
- Nearly Continuous Ashfall Damages Forests Near Chile's Puyehue Cordon Caulle Volcanic Complex
- Quantum Entanglement Observed Macroscopically in Distant Diamonds | Beyond Science | Science | Epoch Times
- Russian Scientists Poised to be First to Reach Ice-Buried Antarctic Lake: Scientific American
- Article: Newfound Alien Planet is Best Candidate Yet to Support Life, Scientists Say
- The Dropa Incident: The Ancient Eastern Roswell | Beyond Science | Science | Epoch Times
- RT @SkyandTelescope: Tonight N. Americans have a rare chance to see really thin crescent Moon paired with Mercury low in west after suns ... 12 hours ago
- RT @Tech_Tidbits: Syrian live streamer killed after being watched by millions: Syrian citizen journalist Rami Ahmad Alsayeed was k... ht ... 1 day ago
- RT @Tech_Tidbits: Moon May Not Be As Dead As We Thought: rivin2e writes "It would seem our neighbor, the moon, has something hidde... ht ... 1 day ago
- RT @Tech_Tidbits: Physicists Create a Working Transistor From a Single Atom: stupendou writes "Australian and American physicists ... ht ... 3 days ago
- RT @BoingBoing: Cop spends weeks to trick an 18-year-old into possession and sale of a gram of pot http://t.co/pxb3bDxt 4 days ago
- Microsoft Slams Google on Patents
- The Pokemon Company issues statement on fake App Store game
- South African Fuel-Free Generator Preparing for Market
- Adobe lays out the future for Flash: a platform for the next 5-10 years.
- Google to Sell Heads-Up Display Glasses by Year’s End.
- 'Faster than light' measurement blamed on loose cable
- Ridiculous: A Loose Cable Caused Those 'Faster-Than-Light' Particles
- Leaked Facebook document reveals website's secretive and bizarre 'graphic content' policy. No sex, but crushed heads are OK.
- Google Fiber just got better? Big G asks for permission to provide video service to Kansas City -- Engadget
- If a Tesla Roadster EVs batteries go completely flat, it "bricks" it. $40,000 for the repair.
- New Hope For Open Source Textbooks
- Understanding Spanning-Tree Protocol
- Archaeologists strike gold in quest to find Queen of Sheba's wealth
- Bringing a 50,000-ton forging press back to Life
- What to make of AT&T’s vanishing spectrum crisis | Broadband News and Analysis
- Piltdown Man: British archaeology's greatest hoax
- Nearly Continuous Ashfall Damages Forests Near Chile's Puyehue Cordon Caulle Volcanic Complex
- Quantum Entanglement Observed Macroscopically in Distant Diamonds | Beyond Science | Science | Epoch Times
- Russian Scientists Poised to be First to Reach Ice-Buried Antarctic Lake: Scientific American
- VLANs and Trunking > VLAN Configuration
- Article: Newfound Alien Planet is Best Candidate Yet to Support Life, Scientists Say
- The Dropa Incident: The Ancient Eastern Roswell | Beyond Science | Science | Epoch Times
- Catalyst 2900 Series Configuration Guide and Command Ref - Switch Command Reference [Cisco Catalyst 2900 Series Switches] - Cisco Systems
- Real time footage of aurora shows them dancing and shimmering | Bad Astronomy | Discover Magazine
- This Week in Radio Tech 111 | TWiT.TV
Pulsing LED is adjustable!
Here is the second installment of Arduino projects.
This time I have jumped several stages and am giving you two types of functions, serial monitoring and schematics using tinycad.
As I worked with this sketch I found that using the input values and a millisecond delay made it way to long and interval to brighten and dim.
I changed to microsecond and used the analogRead value as the interval.
I also found that if the delay value became zero, delay behaved badly. To fix this I put a 330 ohm resistor on the ground side of the potentiometer so that the analogRead would never be zero.
You will notice some code left in that appears to be not needed. You are right! Some lines are left over from what I tried to do first;.
If the notes in the sketch are not clear please let me know in the comments. I have left out the video, for now
adjustable_PULSE_LED_schematic
/*
Pulse an led on a pin. Go from dark to full bright in an adjustable interval then back down to dark in the same interval. The interval is adjusted via a potentiometer.
*/
int ledPin = 11; // led pin used for LED in entire program
int sensorPin = 0; // pin pot is tied to
int interval = 1000; // interval for change in microsecond, 100000 is one second up and one second down
int sensor1 = 0; // sensor raw
int sensor1a = 0; // sensor expanded
int waitforit = (interval/255); //delay this much between each increment
void setup () {
Serial.begin(9600); //start serial comm
pinMode(ledPin, OUTPUT); //initialize ledPin for OUTPUT
pinMode(sensorPin, INPUT); // initialize sensorPin for INPUT
}
void loop() {
waitforit = readSensor(); //
/*
The Serial.print lines are a debugging aid printing out the value used to count up and down in the bright functions
*/
Serial.print(“waitforit is “);
Serial.println(waitforit, DEC);
brightup(); //call the brightup function to raise the led brightness from 0 to 255
brightdown(); //call the brightdown function to lower the led brightness from 255 to 0
}
/*****************************************************************************************
additional functions defined below
*****************************************************************************************/
int readSensor () {
/* This is the subroutine to read the potentiometer and return the value 0 – 1023
*/
sensor1 = analogRead(sensorPin); // read sensor
/*
The Serial.print lines are a debugging aid printing out the value read from the potentiometer
a 330 ohm resistor was added to the ground leg of the potentiometer as a current limiter and to disallow
a reading of “0″. Zero as a value for delayMicrosecond statement causes the loop to behave abnormally
*/
Serial.print(“Sensor1 is “);
Serial.println(sensor1, DEC);
sensor1a = sensor1 * 1; //stretch the interval out, if needed
sensor1a = sensor1a / 1 ; //divide value by a number for use as the count delay waitforit
return sensor1a; // return the adjusted value for the interval
}
void brightup () {
/* this is the subroutine to raise the brightness from zero to 255 over a specific delay
brightness is declared and initialized in this function
waitforit was declared and initialized for the entire program first
*/
for (int brightness = 0; brightness < 255; brightness ++){
analogWrite(ledPin,brightness); //write the brightness value
delayMicroseconds(waitforit); // delay 1/255 of the interval to maximum brightness
}
}
void brightdown () {
/* this is the subroutine to lower the brightness from zero to 255 over a specific delay
brightness is declared and initialized in this function
waitforit was declared and initialized for the entire program first
*/
for (int brightness = 255; brightness > 0; brightness — ){
analogWrite(ledPin,brightness); //write the brightness value
delayMicroseconds(waitforit); // delay 1/255 of the interval to maximum brightness
}
}
About Jerry
This entry was posted by jcoffey on June 28, 2011 at 12:00 pm, and is filed under Arduino, commentary. Follow any responses to this post through RSS 2.0.You can leave a response or trackback from your own site.