From 8b90d31b85a905efa989b2700f2ef5777cf832bb Mon Sep 17 00:00:00 2001 From: root Date: Mon, 16 Feb 2015 16:08:45 +0100 Subject: [PATCH] Blink sviluppo. --- .../blink_3_variables_two_led.ino | 34 +++++++++++++ .../blink_3_variables_two_led_functions.ino | 42 ++++++++++++++++ ..._variables_two_led_functions_arguments.ino | 45 +++++++++++++++++ ...les_two_led_functions_arguments_button.ino | 48 +++++++++++++++++++ libraries/readme.txt | 1 + 5 files changed, 170 insertions(+) create mode 100644 basic/blink_sviluppo/blink_3_variables_two_led/blink_3_variables_two_led.ino create mode 100644 basic/blink_sviluppo/blink_3_variables_two_led_functions/blink_3_variables_two_led_functions.ino create mode 100644 basic/blink_sviluppo/blink_3_variables_two_led_functions_arguments/blink_3_variables_two_led_functions_arguments.ino create mode 100644 basic/blink_sviluppo/blink_3_variables_two_led_functions_arguments_button/blink_3_variables_two_led_functions_arguments_button.ino create mode 100644 libraries/readme.txt diff --git a/basic/blink_sviluppo/blink_3_variables_two_led/blink_3_variables_two_led.ino b/basic/blink_sviluppo/blink_3_variables_two_led/blink_3_variables_two_led.ino new file mode 100644 index 0000000..49b10a8 --- /dev/null +++ b/basic/blink_sviluppo/blink_3_variables_two_led/blink_3_variables_two_led.ino @@ -0,0 +1,34 @@ +/* + Blink v3 + Now with 2 variables and an extra LED (remember a ~320 ohms resistor). + Turns on an LED on for one second, then off for one second, repeatedly. + + This example code is in the public domain. + */ + +// Pin 13 has an LED connected on most Arduino boards. +// give it a name: +int led = 13; +int red = 12; +int breve = 200; +int lunga = 1000; + +// the setup routine runs once when you press reset: +void setup() { + // initialize the digital pin as an output. + pinMode(led, OUTPUT); + pinMode(red, OUTPUT); +} + +// the loop routine runs over and over again forever: +void loop() { + digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) + delay(breve); // wait for a second + digitalWrite(led, LOW); // turn the LED off by making the voltage LOW + delay(breve); // wait for a second + + digitalWrite(red, HIGH); // turn the LED on (HIGH is the voltage level) + delay(lunga); // wait for a second + digitalWrite(red, LOW); // turn the LED off by making the voltage LOW + delay(lunga); +} diff --git a/basic/blink_sviluppo/blink_3_variables_two_led_functions/blink_3_variables_two_led_functions.ino b/basic/blink_sviluppo/blink_3_variables_two_led_functions/blink_3_variables_two_led_functions.ino new file mode 100644 index 0000000..ae8a6cd --- /dev/null +++ b/basic/blink_sviluppo/blink_3_variables_two_led_functions/blink_3_variables_two_led_functions.ino @@ -0,0 +1,42 @@ +/* + Blink v3 + Now with 2 variables and an extra LED (remember a ~320 ohms resistor). + Turns on an LED on for one second, then off for one second, repeatedly. + + This example code is in the public domain. + */ + +// Pin 13 has an LED connected on most Arduino boards. +// give it a name: +int led = 13; +int red = 12; +int breve = 200; +int lunga = 1000; + +// the setup routine runs once when you press reset: +void setup() { + // initialize the digital pin as an output. + pinMode(led, OUTPUT); + pinMode(red, OUTPUT); +} + +// the loop routine runs over and over again forever: +void loop() { +lightRed(); +lightGreen(); +} + +void lightRed() { + digitalWrite(red, HIGH); // turn the LED on (HIGH is the voltage level) + delay(lunga); // wait for a second + digitalWrite(red, LOW); // turn the LED off by making the voltage LOW + delay(lunga); +} + +void lightGreen() { + digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) + delay(breve); // wait for a second + digitalWrite(led, LOW); // turn the LED off by making the voltage LOW + delay(breve); // wait for a second +} + diff --git a/basic/blink_sviluppo/blink_3_variables_two_led_functions_arguments/blink_3_variables_two_led_functions_arguments.ino b/basic/blink_sviluppo/blink_3_variables_two_led_functions_arguments/blink_3_variables_two_led_functions_arguments.ino new file mode 100644 index 0000000..7996555 --- /dev/null +++ b/basic/blink_sviluppo/blink_3_variables_two_led_functions_arguments/blink_3_variables_two_led_functions_arguments.ino @@ -0,0 +1,45 @@ +/* + Blink v3 + Now with 2 variables and an extra LED (remember a ~320 ohms resistor). + Turns on an LED on for one second, then off for one second, repeatedly. + + This example code is in the public domain. + */ + +// Pin 13 has an LED connected on most Arduino boards. +// give it a name: +int led = 13; +int red = 12; +int breve = 200; +int lunga = 1000; + +// the setup routine runs once when you press reset: +void setup() { + // initialize the digital pin as an output. + pinMode(led, OUTPUT); + pinMode(red, OUTPUT); +} + +// the loop routine runs over and over again forever: +void loop() { +lightRed(lunga); +lightRed(breve); + +lightGreen(breve); +lightGreen(lunga); +} + +void lightRed(int length) { // Argomento + digitalWrite(red, HIGH); // turn the LED on (HIGH is the voltage level) + delay(length); // wait for a second + digitalWrite(red, LOW); // turn the LED off by making the voltage LOW + delay(length); +} + +void lightGreen(int length) { + digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) + delay(length); // wait for a second + digitalWrite(led, LOW); // turn the LED off by making the voltage LOW + delay(length); // wait for a second +} + diff --git a/basic/blink_sviluppo/blink_3_variables_two_led_functions_arguments_button/blink_3_variables_two_led_functions_arguments_button.ino b/basic/blink_sviluppo/blink_3_variables_two_led_functions_arguments_button/blink_3_variables_two_led_functions_arguments_button.ino new file mode 100644 index 0000000..39ae271 --- /dev/null +++ b/basic/blink_sviluppo/blink_3_variables_two_led_functions_arguments_button/blink_3_variables_two_led_functions_arguments_button.ino @@ -0,0 +1,48 @@ +/* + Blink v3 + Now with 2 variables and an extra LED (remember a ~320 ohms resistor). + Turns on an LED on for one second, then off for one second, repeatedly. + + This example code is in the public domain. + */ + +// Pin 13 has an LED connected on most Arduino boards. +// give it a name: +int led = 13; +int red = 12; +int button = 2; +int breve = 200; +int lunga = 1000; + +// the setup routine runs once when you press reset: +void setup() { + // initialize the digital pin as an output. + pinMode(led, OUTPUT); + pinMode(red, OUTPUT); + pinMode(button, INPUT); +} + +// the loop routine runs over and over again forever: +void loop() { + if (digitalRead(button) == HIGH) { // HIGH sta per +5v + lightRed(breve); + } + if (digitalRead(button) == LOW) { // LOW sta per 0v + lightGreen(breve); + } +} + +void lightRed(int length) { // Argomento + digitalWrite(red, HIGH); // turn the LED on (HIGH is the voltage level) + delay(length); // wait for a second + digitalWrite(red, LOW); // turn the LED off by making the voltage LOW + delay(length); +} + +void lightGreen(int length) { + digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) + delay(length); // wait for a second + digitalWrite(led, LOW); // turn the LED off by making the voltage LOW + delay(length); // wait for a second +} + diff --git a/libraries/readme.txt b/libraries/readme.txt new file mode 100644 index 0000000..a8f1390 --- /dev/null +++ b/libraries/readme.txt @@ -0,0 +1 @@ +For information on installing libraries, see: http://arduino.cc/en/Guide/Libraries -- 2.39.2