]> git.piffa.net Git - sketchbook_andrea/commitdiff
logic analyzer for PWM
authorAndrea Manni <andrea@piffa.net>
Mon, 2 Mar 2015 02:23:58 +0000 (03:23 +0100)
committerAndrea Manni <andrea@piffa.net>
Mon, 2 Mar 2015 02:23:58 +0000 (03:23 +0100)
advanced_projects/led_PWM_logical_analyzer_demo/led_PWM_logical_analyzer_demo.ino [new file with mode: 0644]
basic/led_PWM_simple/led_PWM_simple.ino
shift_register/shift_register_serial/shift_register_serial.ino

diff --git a/advanced_projects/led_PWM_logical_analyzer_demo/led_PWM_logical_analyzer_demo.ino b/advanced_projects/led_PWM_logical_analyzer_demo/led_PWM_logical_analyzer_demo.ino
new file mode 100644 (file)
index 0000000..5524160
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+    PWM demo with a logical analyzer
+ Connect pin ~11 to a logic analyzer and a multimeter
+ and witness the power of the built-in PWM generator.
+ BTW: Logic comes from: http://downloads.saleae.com/betas/1.1.34/Logic+1.1.34+(64-bit).zip
+ */
+
+int led = 11;
+int c = 0;
+
+
+void setup()
+{
+  pinMode(led, OUTPUT);
+  delay(5000);
+
+}
+
+void loop()
+{  
+  // Static test value, comment exit() or ad a delay()
+  //analogWrite(led, 0) ; // No light
+  //delay(20)
+  //analogWrite(led, 254) ;  // Full light
+  //delay(20)
+  //analogWrite(led, 63) ;   // 1/4
+  //delay(20)
+  //analogWrite(led, 127) ;  // 1/2
+  //delay(20)
+  //analogWrite(led, 191) ;  // 3/4
+  //delay(20)
+  //return ;
+  
+  for ( c = 0; c < 255 ; c++) {
+    analogWrite(led, c) ;
+    delay(2 );
+  }
+  exit(0);
+
+}
+
+
+
+
index 45d3ff9e6a5f1e085c2d48ce36102e83f23441c1..254ad866d0e0e35b4885b71241e7019f880bfd93 100644 (file)
@@ -1,27 +1,32 @@
 /*
-    Adafruit Arduino - Lesson 3. RGB LED
+    LED for PWM
+ LEd PWM routine with a for loop, ascending and descending.
  */
 
-int redPin = 11;
-int greenPin = 10;
-int bluePin = 9;
+int led = 11;
 int c = 0;
 
-//uncomment this line if using a Common Anode LED
-//#define COMMON_ANODE
 
 void setup()
 {
-  pinMode(redPin, OUTPUT);
+  pinMode(led, OUTPUT);
 
 }
 
 void loop()
 {
   for ( c = 0; c < 255 ; c++) {
-    analogWrite(redPin, c) ;
+    analogWrite(led, c) ;
+    delay(5 );
+  }
+  // Now reverse
+    for ( c = 255; c > 0 ; c--) {
+    analogWrite(led, c) ;
     delay(5 );
   }
 }
 
 
+
index bb82c9a69b10c9ee3ec117c23cdefa5720964cde..38b5d7cbe90b90863161c20bb3e68c27e4713955 100644 (file)
@@ -6,7 +6,7 @@
  of a 74HC595 shift register.
 
  Hardware:
- * 74HC595 shift register attached to pins 2, 3, and 4 of the Arduino,
+ * 74HC595 shift register attached to pins 8, 12, and 11 of the Arduino,
  as detailed below.
  * LEDs attached to each of the outputs of the shift register