Affordable Smart Wheelchair
/
ButtonTest
Emergency Button Test Code
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 #include "rtos.h" 00003 00004 DigitalIn button(D4, PullDown); 00005 DigitalOut signal(D5); 00006 Serial pc(USBTX, USBRX, 57600); 00007 00008 int i = 0; 00009 int val; 00010 Thread thread; 00011 00012 00013 void Printing () { 00014 i = 0; 00015 pc.printf("RESET\n"); 00016 while(1) { 00017 pc.printf("I'm running! Iteration: %d \n", i); 00018 i++; 00019 } 00020 } 00021 00022 00023 int main() { 00024 00025 bool killed = 1; 00026 thread.start(Printing); 00027 //Main Code 00028 00029 while(1) { 00030 signal = 0; 00031 while(!button) { 00032 00033 //Send something to stop wheelchair 00034 signal = 1; 00035 pc.printf("Hello there!\n"); 00036 pc.printf("I'm dead\n\n\n"); 00037 //Reset Board 00038 NVIC_SystemReset(); 00039 00040 } 00041 00042 } 00043 }
Generated on Mon Jul 25 2022 00:53:28 by 1.7.2