Emergency Button Test Code

Dependencies:   mbed mbed-rtos

main.cpp

Committer:
t1jain
Date:
2019-06-26
Revision:
1:3a8cde678b38
Parent:
0:e23e7393f8cc

File content as of revision 1:3a8cde678b38:

#include "mbed.h"
#include "rtos.h"

DigitalIn button(D4, PullDown);
DigitalOut signal(D5);
Serial pc(USBTX, USBRX, 57600);

int i = 0;
int val;
Thread thread;


void Printing () {  
    i = 0;
    pc.printf("RESET\n");
    while(1) {    
        pc.printf("I'm running! Iteration: %d \n", i);
        i++;
    }
}


int main() {

    bool killed = 1;    
    thread.start(Printing);
    //Main Code
    
    while(1) {
    signal = 0;
    while(!button) {
                
        //Send something to stop wheelchair
        signal = 1;
        pc.printf("Hello there!\n");
        pc.printf("I'm dead\n\n\n");
        //Reset Board
        NVIC_SystemReset();

    }
    
    }
}