Technology for everyone
- Tech News Today on Reddit
- Pinboard bookmarks
- What am I reading
- What did I say?
- Links
- Sites or services I use
- Facebook founder Mark Zuckerberg marries one day after $104bn IPO - Telegraph
- Mark Zuckerberg gets married at surprise wedding
- Facebook Banker Morgan Stanley Bought A Humongous Amount Of Stock To Try Support Price - Business Insider
- The Associated Press: Facebook's Mark Zuckerberg marries sweetheart
- Google says it won China's approval for Motorola deal | Reuters
- Researchers unveil eerie clothes-scaling robot
- Sprint Capitalizes on Verizon Data Discontent With $100 iPhone Trade-in Offer
- Possible engine problem delays US rocket launch
- Microsoft brings back free Xbox back-to-school PC promo
- Microsoft wins import ban on some Motorola phones
- The Free Ride Is Over For Streaming Video | TechCrunch
- Johnny Chung Lee - Projects - Wii
- Arduino - Reference
- MaKey MaKey Turns Everyday Objects into a Touch Interface | PCWorld
- Cisco IOS DHCP Server - Cisco Systems
- Ring of fire eclipse on May 20 | Bad Astronomy | Discover Magazine
- Interface Commands (show ip interface -- tx-queue-limit) [Support] - Cisco Systems
- Cisco IOS Configuration Fundamentals Command Reference
- Want more from Doctor Tiki? - Let him know!
- Untitled (https://plus.google.com/117161668189080869053/posts/5Zg5FdFEydi)
- Untitled (http://lifehacker.com/5910429/convert-a-bread-box-into-a-charging-station?utm_campaign=socialflow_lifehacker_twitter&utm_source=lifehacker_twitter&utm_medium=socialflow)
- Instapaper
- Untitled (http://twitter.com/doctorow/status/201665091597373441/photo/1)
- The Free Ride Is Over For Streaming Video | TechCrunch
- Johnny Chung Lee - Projects - Wii
- Arduino - Reference
- Instapaper
- The Perfect Milk Machine: How Big Data Transformed the Dairy Industry - Atlantic Mobile
- WTF Is CISPA? - Beth Callaghan - Numbers - AllThingsD
- Is This Censorship? Facebook Stopping Users From Posting ‘Irrelevant Or Inappropriate’ Comments - TechCrunch
- EBSCOhost: Intel Sponsored Survey Ranks RES Software as Top Ten Technology Provider fo...
- USATODAY.com - 'Nature': Wikipedia is accurate
- Check out Downcast, a very cool podcatcher for iOS devices!
- RT @pcworld: Makey Makey turns everything into a touch controller: pcwrld.us/L5iq8l 1 day ago
- RT @BadAstronomer: Wanna see the eclipse on Sunday? Here's how. And where. And, for that matter, why. is.gd/RGSmiR 2 days ago
- RT @Tech_Tidbits: New $74 Android mini computer is slightly larger than a thumb drive: The AllWinner A10 Android 4.0 mi... ht ... 2 days ago
- RT @Tech_Tidbits: UK Police Roll Out On-the-Spot Mobile Data Extraction System: Qedward writes "The Metropolitan Police has rolled... ht ... 3 days ago
- RT @PGE4Me: ALERT: customers, pls be aware of a current phone #scam offering utility bill credits from President Obama. Do not give your ... 3 days ago
Pulsing LED is adjustable!
0Here 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