author?
author?
Posted Jan 2, 2008 17:15 UTC (Wed) by cook (subscriber, #4)In reply to: author? by astrophoenix
Parent article: Hardware Fun with the Arduino board
>hey, who wrote this article?
I wrote it but forgot to attribute it to myself. Here's a little Arduino script that improves on the basic blink application, I expect to do more serious projects with this cool device.
/*
* Blink2
* based on the blink example:
* http://www.arduino.cc/en/Tutorial/Blink
* Now the LED blink rate changes from fast to slow and back.
*/
int ledPin = 13; // LED connected to digital pin 13
int dtime = 40;
int flip = 0;
void setup() // run once, when the sketch starts
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
}
void loop() // run over and over again
{
if (flip == 0)
{
oneblink();
dtime += 10;
if (dtime >= 180)
flip = 1;
}
else
{
oneblink();
dtime -= 10;
if (dtime <= 40)
flip = 0;
}
}
void oneblink()
{
digitalWrite(ledPin, HIGH);
delay(dtime);
digitalWrite(ledPin, LOW);
delay(dtime);
}
