David Beargie
/
LHS_program_1
Code for LHS 12_12_2013
code_help.cpp
- Committer:
- dbearg
- Date:
- 2014-03-12
- Revision:
- 4:3588eff6d065
File content as of revision 4:3588eff6d065:
//%%=================================%% //%% FLOWCHART TO CODE CONVERSION %% //%%=================================%% // // DECISION BOX // -------------- // // // ____ // / A=B \__TRUE____> // \_____/ // |______FALSE // // CODE // -------- // // a equals b // // if(a == b){ // ; // ; // } // // a less than or = to b // // if(a <= b){ // ; // ; // } // //======================================= // // INPUTS // -------- // ____ // |____| // | // V // CODE // -------- // type name(pin); // // TYPES: // DigitalIn // AnalogIn // // EXAMPLES: // DigitalIn enable(p30); // AnalogIn ain(p19); // // // //========================================== // // VARIABLES // ----------- // ____ // |____| // | // V // CODE // -------- // // type variable = value; // types: // int.........integer (whole numbers, 1, 4, 128, etc) // float.......floating point decimal (0.1, 3.62783, etc) // // NOTE: value has to match data type. // see website http://mbed.org/handbook/C-Data-Types for more information // // //=========================================== // // // COUNTER LOOP EXAMPLE // ---------------------- // ____________ // | | // | MOTOR | // | SPEED = A | // |____________| // | ___________________________________ // ______V____________ | | // | | | SOME INCREMENTED ACTION, EXAMPLE: | // | IF COUNT = X THEN |<_______| MOTOR SPEED IS MOTOR SPEED + A | // | BREAK THE LOOP | |___________________________________| // |___________________| ^ // | | ___________ | // | | | | | // | |_________>| COUNT + 1 |_____________| // V |___________| // // CODE // ------ // // for(int count = 0; count <10; count = count + 1){ // ; // ; // } // // // //============================================ // // // CONTINUOUS LOOP EXAMPLE // ------------------------- // // _______________ // | | // | START OF LOOP | // |_______________| // | // |<--------------- // | | // ________V________ | // | | | // | LOGIC STATEMENT | | // |_________________| | // | | // ________V________ | // | | | // | LOGIC STATEMENT |_______| // |_________________| // // CODE // ------ // // while(1) { // ; // ; // } //