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
update.cpp
00001 /* 00002 * update.cpp 00003 * 00004 * Created on: Oct 16, 2015 00005 * Author: User 00006 */ 00007 00008 #include <iostream> 00009 #include <string> 00010 /* 00011 * takes state and num_on_inputs as input variables, if num_on_inputs means been in one state for 0.25s 00012 * it calls the motor movement function according to the state (left/right or key press) 00013 */ 00014 void update(std::string state, int &num_on_inputs) 00015 { 00016 //check if system has been in one state long enough to move 00017 if (num_on_inputs == 250) 00018 { 00019 //reset the number of on inputs so that once function finishes robot is 'reinitialised' 00020 num_on_inputs = 0; 00021 //run left/right motor, key press motor or do nothing depending on the state 00022 if (state == "left" or state == "right") 00023 { 00024 //function to be created and included as h file 00025 //move_horizontal_motor(state) 00026 //std::cout << "left or right \n"; 00027 } 00028 else if (state == "keypress") 00029 { 00030 //function to be created and its h file included 00031 //move_keypress_motor() 00032 //std::cout << "keypress \n "; 00033 } 00034 else if (state == "rest") 00035 { 00036 //if at rest do nothing 00037 //std::cout << "rest "; 00038 } 00039 else 00040 { 00041 //throw an error somehow 00042 //std::cout << "error \n "; 00043 } 00044 } 00045 else if (num_on_inputs > 250) 00046 { 00047 //std::cout << "error \n "; 00048 } 00049 }
Generated on Fri Jul 22 2022 22:40:56 by
1.7.2