]> git.piffa.net Git - sketchbook_andrea/blobdiff - multitasking/blink_0_soluzione/blink_0_soluzione.ino
Clean up multitasking, bottoni con pooling e interrupts
[sketchbook_andrea] / multitasking / blink_0_soluzione / blink_0_soluzione.ino
index e9312e0d0d27a7614c3d0027f97bd9114a14b84a..2077b6b624bc5d01f3b50dbc193157fe11794825 100644 (file)
@@ -4,6 +4,13 @@
  Aggiungere un secondo LED e farlo brillare ogni 500ms
  mentre il primo brilla ogni 1000ms
  
+ Massimo comun denominatore 1000 MCD 500 = 500ms
+ Durata Periodo = 500ms
+ Schema: https://lab.piffa.net/schemi/millis_bb.png
+ Stati: 
  a  |  b    Changes
  ========   =========
  1  |  1    x   |   x
  0  |  1    x   |   x
  0  |  0        |   x
  
- Periodo = 500ms
  
  */
 
 // Pin 13 has an LED connected on most Arduino boards.
 // give it a name:
-int ledA = 13; //Primo LED
-int ledB = 12; //Secondo LED, con resistenza
+const int ledA = 13; //Primo LED
+const int ledB = 12; //Secondo LED, con resistenza
 
 // the setup routine runs once when you press reset:
 void setup() {                
@@ -29,48 +35,28 @@ void setup() {
 
 // the loop routine runs over and over again forever:
 void loop() {
+  // Primo periodo
   digitalWrite(ledA, HIGH);   // turn the LED on (HIGH is the voltage level)
   digitalWrite(ledB, HIGH);
-
   delay(500);               // Minimo comun denominatore del periodo
+
+  // Secondo periodo
   //digitalWrite(ledA, HIGH); // ledA non cambia
   digitalWrite(ledB, LOW);
-
-
   delay(500);
+
+  // Terzo periodo
   digitalWrite(ledA, LOW);
   digitalWrite(ledB, HIGH);
+  delay(500);
 
-  delay(500);          
+  // Quarto periodo
   //digitalWrite(ledA, LOW);  
   digitalWrite(ledB, LOW);
-
-
   delay(500);
-  digitalWrite(ledA, LOW);
-  digitalWrite(ledB, LOW);
-  ;
 }
 
 /* Domande
- 1. Altro scenartio: fare brillare un LED ogni 300ms mentre il secondo brilla ogni 400m
- 2. Aggiungere un terzo LED
+ 1. Altro scenario: fare brillare un LED ogni 300ms mentre il secondo brilla ogni 400m
+ 2. ...valutare come aggiungere un terzo LED, gestire altri intevalli.
  */
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-