Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
main.cpp
00001 #include "mbed.h" 00002 Serial pc(USBTX,USBRX); 00003 00004 // Hall effect sensor 00005 DigitalIn hall(p21); 00006 DigitalOut hallpwr(p22); 00007 00008 InterruptIn event(p21); 00009 DigitalOut led1(LED1); 00010 DigitalOut led4(LED4); 00011 00012 int hallvalue; 00013 int hallstatus=0; 00014 void trigger() 00015 { 00016 while (hallstatus!=0) { // when triggered the lead will send out a light and reset the hallstatus 00017 led1=1; 00018 wait(1); 00019 led1=0; 00020 hallstatus=0; 00021 } 00022 } 00023 int main() 00024 { 00025 hall.mode(PullUp); // brings up the sensor values 00026 hallpwr=0; // sets the power readings 00027 wait(0.2); 00028 hallpwr =1;// sets the power readings 00029 wait(0.2); 00030 event.rise(&trigger); //starts the outside tigger fuctions when something happens on pin 21 00031 while(1) { 00032 hallvalue=hall.read();// reads in hall effect values of (0 &1) 00033 if (hallvalue==1) { // if the value read in is 1 then there is a change in status 00034 hallstatus=1; 00035 } 00036 pc.printf("hallvalues:%d\n\r",hallvalue); 00037 wait(0.25); 00038 } 00039 }
Generated on Sat Jul 23 2022 22:40:45 by
