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
Arduino ho!!
0This will be my first post about arduino although not my first program. I waited until I had done some basic stuff and had something interesting to say.
I have done the blink and press button to blink. I decided the one to post about would be my venture into functions.
I needed to be able to call functions to allow for a program that had more flexibility to it. To that end I made what is a simple program to raise and lower the brightness of a led over a flexible period of time. I am going to post the program with what I hope are copious notes to make it understandable. If you have any trouble with it just leave a comment and I will try to clear the fog.
Here it is:
/*
Pulse an led on a pin. Go from dark to full bright in a designated interval then back down to dark in the same interval
*/
int ledPin = 11; // led pin used for LED in entire program
int interval = 500; // interval for change in milliseconds, 1000 is one second up and one second down
int waitforit = (interval/255); //delay this much between each increment
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
delay(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
delay(waitforit); // delay 1/255 of the interval to maximum brightness
}
}
void setup () {
pinMode(ledPin, OUTPUT); //initialize ledPin for OUTPUT
}
void loop() {
brightup(); //call the brightup fuction to raise the led brightness from 0 to 255
brightdown(); //call the brightdown fuction to lower the led brightness from 255 to 0
}
This is it working