Sunday, November 21, 2010

Ds Cartridge Corrupts

Create a semaphore with Arduino Arduino Massimo Banzi has

Wandering the Internet, I realized that there are few guides or examples in Italian about Arduino, so I wanted to help try to give some examples with explanation.
And here is a source code that allows you to enable multiple outputs, so as to create a "traffic light". Let's see how:

# include "WProgram.h"

void setup () {
pinMode ( LED_PIN, OUTPUT ) / / enable pin 10 for output
pinMode ( LED_PIN1, OUTPUT ) / / enable pin 11 for output
pinMode ( LED_PIN2, OUTPUT ) / / enable pin 12 for output

}
void loop () {
digitalWrite ( LED_PIN, HIGH ) / / red LED lights
delay ( 10000 ) / / wait 10 seconds
digitalWrite ( LED_PIN, LOW ) / / RED LED
digitalWrite ( LED_PIN2, HIGH ) / / green LED lights
delay ( 10000 ) / / wait 10 seconds
digitalWrite ( LED_PIN2, LOW ) / / the green LED
digitalWrite ( LED_PIN1, HIGH ) / / Yellow LED lights
delay ( 2000 ) / / wait 2 seconds
digitalWrite ( LED_PIN1, LOW ) / / off LED YELLOW

}

Obviously you have to respect the colors of the LEDs according to the pin, then:

RED LED PIN 10
LED YELLOW PIN 11
GREEN LED PIN 12

0 comments:

Post a Comment