Week3 Assignment : Digital OUTPUT & Analog OUTPUT

I’ve been tried my Arduino second time~~ Now I can use this program more easily.
So pretty LEDs~~~

 

1. Blinking LEDs continuously

<p><a href=”http://vimeo.com/89885248″>week3loop</a> from <a href=”http://vimeo.com/user22384597″>Suh Ye Jung</a> on <a href=”https://vimeo.com”>Vimeo</a>.</p>

code>>

int pinArray[] = {2,3,4,5,6};

int blinkTime = 20;

int numLEDs = 4;

int count;

void setup()

{

for(count = 0; count <= 4; count++)

{

pinMode(pinArray[count], OUTPUT);

}

}

void loop()

{

for(count = 0;count <= numLEDs; count++)

{

digitalWrite(pinArray[count], HIGH);

delay(blinkTime);

digitalWrite(pinArray[count], LOW);

delay(blinkTime);

}

for(count = numLEDs;count >= 0; count–)

{

digitalWrite(pinArray[count], HIGH);

delay(blinkTime);

digitalWrite(pinArray[count], LOW);

delay(blinkTime);

}

}

2. Analog OUTPUT

<p><a href=”http://vimeo.com/89885283″>week3analog</a> from <a href=”http://vimeo.com/user22384597″>Suh Ye Jung</a> on <a href=”https://vimeo.com”>Vimeo</a>.</p>

code>>

int LED[] = {3,5,6,9,10};

int blinkTime = 4;

int numLEDs = 4;

int count;

void setup()

{ }

void loop() {

for(count = 0; count <= 254; count++)

{

analogWrite(LED[0], count);

analogWrite(LED[2], count);

analogWrite(LED[4], count);

delay(blinkTime);

}

for(count = 254; count >= 0; count–)

{

analogWrite(LED[0], count);

analogWrite(LED[2], count);

analogWrite(LED[4], count);

delay(blinkTime);

}

for(count = 0; count <= 254; count++)

{

analogWrite(LED[1], count);

analogWrite(LED[3], count);

delay(blinkTime);

}

for(count = 254; count >= 0; count–)

{

analogWrite(LED[1], count);

analogWrite(LED[3], count);

delay(blinkTime);

}

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s