Simple program to demonstrate the basic functions of the analog comparator of the FRDM-KL25Z board.

Dependencies:   ComparatorIn mbed

Fork of ComparatorIn_demo by Frank Vannieuwkerke

ComparatorIn demo

Simple program to demonstrate the basic functions of the analog comparator of the FRDM-KL25Z board.

The blue LED flashes after 2 sec delay. The green LED is driven by the interrupts of the Analog Comparator (LED ON at rising edge, LED OFF at falling edge).

The output of the Analog Comparatir is also tested by polling, the result is printed out at the standard output (UART0). The default speed and format (9600 bps, 8,N,1) are used.

Credits

This program is based on the ComparatorIn library and the ComparatorIn_demo program written by Frank Vannieuwkerke

Used library:

Hardware requirements:

  • FRDM-KL25 board
  • CdS photoresistor pulled up by 10 k

/media/uploads/icserny/05_comparator_demo.png

Files at this revision

API Documentation at this revision

Comitter:
frankvnk
Date:
Sat Jul 20 16:31:19 2013 +0000
Parent:
3:fc232e248bd0
Child:
5:5161b8d6e695
Commit message:
int_en removed
; rising/falling changed
; improved function names

Changed in this revision

ComparatorIn.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/ComparatorIn.lib	Sun Jun 16 20:06:30 2013 +0000
+++ b/ComparatorIn.lib	Sat Jul 20 16:31:19 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/frankvnk/code/ComparatorIn/#18170968fdc3
+http://mbed.org/users/frankvnk/code/ComparatorIn/#048474f28d28
--- a/main.cpp	Sun Jun 16 20:06:30 2013 +0000
+++ b/main.cpp	Sat Jul 20 16:31:19 2013 +0000
@@ -28,7 +28,6 @@
     compi.rising(&cmp_rise_ISR);                // Set pointer to rising interrupt function
     compi.falling(&cmp_fall_ISR);               // Set pointer to falling interrupt function
     compi.treshold(0.3);                        // Set comparator threshold to 1V = 0.3 * 3.3V
-    compi.int_en(1);                            // Enable comparator interrupts
 
     while(1)
     {