From: eaman Date: Thu, 15 Dec 2016 15:00:10 +0000 (+0100) Subject: multi cleanup X-Git-Url: http://git.piffa.net/web?p=sketchbook_andrea;a=commitdiff_plain;h=2a204bfbbd1557204b4f1e90b0b322231ac346c1 multi cleanup --- diff --git a/basic/blinks/blink_1_variabili/blink_1_variabili.ino b/basic/blinks/blink_1_variabili/blink_1_variabili.ino index ec6c3c0..86a1171 100644 --- a/basic/blinks/blink_1_variabili/blink_1_variabili.ino +++ b/basic/blinks/blink_1_variabili/blink_1_variabili.ino @@ -11,8 +11,7 @@ // ////////////// // Dichiarazione variabili -// Pin 13 has an LED connected on most Arduino boards. -// give it a name: +// Pin 13 ha un LED preconfigurato su molte schede Arduino int led = 13; int breve = 200; // Variabile richiambile nel corso dell'esecuzione int lunga = 1000; @@ -20,7 +19,7 @@ int lunga = 1000; // ///////////////// // Setup: eseguita una volta sola all'accensione della scheda void setup() { - // initialize the digital pin as an output. + // Inizializziamo il PIN 13 come OUTPUT pinMode(led, OUTPUT); } diff --git a/multitasking/BlinkWithoutDelay_1/BlinkWithoutDelay_1.ino b/multitasking/BlinkWithoutDelay_1/BlinkWithoutDelay_1.ino index 72a9694..b7a04a9 100644 --- a/multitasking/BlinkWithoutDelay_1/BlinkWithoutDelay_1.ino +++ b/multitasking/BlinkWithoutDelay_1/BlinkWithoutDelay_1.ino @@ -1,5 +1,13 @@ /* Blink without Delay + Utilizziamo la funzione millis() al posto di delay() + per poter gestire il lampeggio di un LED senza bloccare + il processore. + + Questo esercizio e' strutturato in una serie di passaggi incrementali + nei quali una versione minimale si evolve per introdurre + programmazione ad oggetti, interrupts, pointers. + Turns on and off a light emitting diode(LED) connected to a digital pin, without using the delay() function. This means that other code can run at the same time without being interrupted by the LED code. @@ -14,7 +22,7 @@ by David A. Mellis modified 8 Feb 2010 by Paul Stoffregen - modified by eaman + 2015 modified by Andrea Manni This example code is in the public domain. @@ -66,7 +74,9 @@ void loop() } /* Domande - 1. Aggioungere un LED che brilli ogni 500ms + 1. Aggioungere un LED che brilli ogni 500ms: iniziare pensando + a quali variabili gestiscono l'attuale LED e a quali si + dovranno aggiungere. 2. E' ora agevole cambiare gli intervalli dei due LED? Modificare gli intervalli dei due led (es 500ms - 320ms) */ diff --git a/multitasking/BlinkWithoutDelay_3_funzione/BlinkWithoutDelay_3_funzione.ino b/multitasking/BlinkWithoutDelay_3_funzione/BlinkWithoutDelay_3_funzione.ino index e27cf55..a77faca 100644 --- a/multitasking/BlinkWithoutDelay_3_funzione/BlinkWithoutDelay_3_funzione.ino +++ b/multitasking/BlinkWithoutDelay_3_funzione/BlinkWithoutDelay_3_funzione.ino @@ -1,4 +1,4 @@ -/* Blink without Delay +/* Blink without Delay: Refactoring Blink con funzione @@ -7,27 +7,29 @@ - Quali variabili determinano il comportamento del LED? - Come cambiano durante il corso dello script? - Sono globali o locali? - + +Variabili: http://www.maffucci.it/2011/12/15/appunti-di-programmazione-su-arduino-variabili/ + */ ///////////// // First LED -const int ledA = 13; // the number of the LED pin +const int ledA = 13; // the number of the LED pin // Variables will change: -int ledStateA = LOW; // ledState used to set the LED -long previousMillisA = 0; // will store last time LED was updated +int ledStateA = LOW; // ledState used to set the LED +long previousMillisA = 0; // will store last time LED was updated // the follow variables is a long because the time, measured in miliseconds, // will quickly become a bigger number than can be stored in an int. -long intervalA = 1000; // interval at which to blink (milliseconds) +long intervalA = 1000; // interval at which to blink (milliseconds) void lightLedA () ; ////////////// // Second LED // Now with less global variables thanks to static (see function body) const int ledB = 12; //Secondo LED - // ledState used to set the LED -long previousMillisB = 0; // will store last time LED was updated - // interval at which to blink (milliseconds) + // ledState used to set the LED +long previousMillisB = 0; // will store last time LED was updated + // interval at which to blink (milliseconds) void lightLedB () ; diff --git a/multitasking/blink_0/blink_0.ino b/multitasking/blink_0/blink_0.ino index 96f6921..1b7c15b 100644 --- a/multitasking/blink_0/blink_0.ino +++ b/multitasking/blink_0/blink_0.ino @@ -1,26 +1,24 @@ /* - Blink - Turns on an LED on for one second, then off for one second, repeatedly. - - This example code is in the public domain. + Blink v1 + + Accensione e spegnimanto di un LED utilizzando variabili + per impostare la velocita' del lampeggio. + */ -// Pin 13 has an LED connected on most Arduino boards. -// give it a name: +// Pin 13 ha un LED collegato di default int led = 13; -// the setup routine runs once when you press reset: void setup() { - // initialize the digital pin as an output. + // Inizializziamo il PIN 13 come OUTPUT pinMode(led, 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(1000); // wait for a second - digitalWrite(led, LOW); // turn the LED off by making the voltage LOW - delay(1000); // wait for a second + digitalWrite(led, HIGH); + delay(1000); + digitalWrite(led, LOW); + delay(1000); } /* Domande diff --git a/multitasking/blink_0_soluzione/blink_0_soluzione.ino b/multitasking/blink_0_soluzione/blink_0_soluzione.ino index 53aec5d..8c302d9 100644 --- a/multitasking/blink_0_soluzione/blink_0_soluzione.ino +++ b/multitasking/blink_0_soluzione/blink_0_soluzione.ino @@ -57,7 +57,7 @@ void loop() { /* Domande 1. Altro scenartio: fare brillare un LED ogni 300ms mentre il secondo brilla ogni 400m - 2. Aggiungere un terzo LED + 2. ...valutare come aggiungere un terzo LED, gestire altri intevalli. */