Lights blink when a magnet is detected

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
m211002
Date:
Mon Apr 29 17:20:55 2019 +0000
Parent:
0:f556205c07a6
Commit message:
hall effect code

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Mon Apr 29 17:16:18 2019 +0000
+++ b/main.cpp	Mon Apr 29 17:20:55 2019 +0000
@@ -13,7 +13,7 @@
 int hallstatus=0;
 void trigger()
 {
-    while (hallstatus!=0) {
+    while (hallstatus!=0) { // when triggered the lead will send out a light and reset the  hallstatus
         led1=1;
         wait(1);
         led1=0;
@@ -22,15 +22,15 @@
 }
 int main()
 {
-    hall.mode(PullUp);
-    hallpwr=0;
+    hall.mode(PullUp); // brings up the sensor values
+    hallpwr=0; // sets the power readings
     wait(0.2);
-    hallpwr =1;
+    hallpwr =1;// sets the power readings
     wait(0.2);
-    event.rise(&trigger);
+    event.rise(&trigger); //starts the outside tigger fuctions when something happens on pin 21
     while(1) {
-        hallvalue=hall.read();
-        if (hallvalue==1) {
+        hallvalue=hall.read();// reads in hall effect values of (0 &1)
+        if (hallvalue==1) { // if the value read in is 1 then there is a change in status
             hallstatus=1;
         }
         pc.printf("hallvalues:%d\n\r",hallvalue);