Struct
authorAndrea Manni <andrea@piffa.net>
Mon, 25 Sep 2017 12:57:41 +0000 (14:57 +0200)
committerAndrea Manni <andrea@piffa.net>
Mon, 25 Sep 2017 12:57:41 +0000 (14:57 +0200)
RGB_LED/rgb_5_struct/rgb_5_struct.ino
basic/blinks/blink/blink.ino [new file with mode: 0644]

index 181a90d..0ac4364 100644 (file)
@@ -7,16 +7,16 @@
  Schema: http://lab.piffa.net/schemi/rgb.jpg
  */
 
-byte pin[3]   = {11, 10, 9};   // 2v a 20ma: che resistenza dovro usare?
+byte pin[3]   = {11, 10, 9};   // 2v a 20ma: che resistenza dovro' usare?
 
 struct color {
-  byte red ;
-  byte blue;
-  byte green;
+  byte rpin ;
+  byte bpin;
+  byte gpin;
 
 } ;
 
-color led;
+color rosso = {255,0,0};
 
 void setup()
 {
@@ -27,9 +27,9 @@ void setup()
 
 void loop()
 {
-  analogWrite(pin[0], led.red);
-  analogWrite(pin[1], led.green);
-  analogWrite(pin[2], led.blue);
+  analogWrite(pin[0], rosso.rpin);
+  analogWrite(pin[1], rosso.gpin);
+  analogWrite(pin[2], rosso.bpin);
 }
 
 /* Domande:
diff --git a/basic/blinks/blink/blink.ino b/basic/blinks/blink/blink.ino
new file mode 100644 (file)
index 0000000..4d3829a
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+  Blink 
+
+  Accensione e spegnimanto di un LED.
+ */
+void setup() {                
+  pinMode(13, OUTPUT); 
+}
+
+void loop() {
+  digitalWrite(13, HIGH);
+  delay(200);            
+  digitalWrite(13, LOW); 
+  delay(500);            
+}