This is the application of d.c motor as a hand dryer .

Dependencies:   mbed

Committer:
Akshayiupui
Date:
Sat May 07 01:03:18 2016 +0000
Revision:
0:5d05007d486e
d.c motor application as a hand dryer

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Akshayiupui 0:5d05007d486e 1 #include "mbed.h"
Akshayiupui 0:5d05007d486e 2 InterruptIn motion(PTB9);
Akshayiupui 0:5d05007d486e 3 DigitalOut vcc(PTC16);
Akshayiupui 0:5d05007d486e 4 int motion_detected = 0;
Akshayiupui 0:5d05007d486e 5 int l=1;
Akshayiupui 0:5d05007d486e 6 void irq_handler(void)
Akshayiupui 0:5d05007d486e 7 {
Akshayiupui 0:5d05007d486e 8 motion_detected = 1;
Akshayiupui 0:5d05007d486e 9 }
Akshayiupui 0:5d05007d486e 10
Akshayiupui 0:5d05007d486e 11 int main(void)
Akshayiupui 0:5d05007d486e 12 {
Akshayiupui 0:5d05007d486e 13 motion.rise(&irq_handler);
Akshayiupui 0:5d05007d486e 14
Akshayiupui 0:5d05007d486e 15 while(1) {
Akshayiupui 0:5d05007d486e 16 if(motion_detected==1){
Akshayiupui 0:5d05007d486e 17 motion_detected = 0;
Akshayiupui 0:5d05007d486e 18 l++;
Akshayiupui 0:5d05007d486e 19 if(l==3){printf("Motor is working\n");
Akshayiupui 0:5d05007d486e 20 vcc=!vcc;}
Akshayiupui 0:5d05007d486e 21 if(l==6){vcc=0;
Akshayiupui 0:5d05007d486e 22 l=0;}
Akshayiupui 0:5d05007d486e 23 }
Akshayiupui 0:5d05007d486e 24 }
Akshayiupui 0:5d05007d486e 25 }