David Beargie
/
LHS_program_1
Code for LHS 12_12_2013
Diff: code_help.cpp
- Revision:
- 4:3588eff6d065
diff -r 59a9bd160e29 -r 3588eff6d065 code_help.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/code_help.cpp Wed Mar 12 21:38:21 2014 +0000 @@ -0,0 +1,134 @@ +//%%=================================%% +//%% 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) { +// ; +// ; +// } +//