This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
haas:fall2019:c4eng:projects:epf1 [2019/09/30 13:02] – [Program] wedge | haas:fall2019:c4eng:projects:epf1 [2019/09/30 19:08] (current) – wedge | ||
---|---|---|---|
Line 16: | Line 16: | ||
To refresh your memory, here is a diagram of the circuit you can build to drive the LEDbar: | To refresh your memory, here is a diagram of the circuit you can build to drive the LEDbar: | ||
+ | {{: | ||
+ | |||
+ | Be sure to use 220 Ohm resistors for this. | ||
+ | |||
+ | =====Program===== | ||
+ | It is your task to adapt your bcf0 program so that, upon accepting various pieces of input from the user, acts as a binary counter, lighting up the resultant LEDs in binary (1 being on, 0 being off), inserting an adequate delay so we can watch as it proceeds from a starting to an ending value. | ||
+ | |||
+ | =====Specifications===== | ||
+ | Your program should: | ||
+ | |||
+ | * have valid, descriptive variable names of length //no shorter than// 4 symbols | ||
+ | * have consistent, well-defined indentation (no less than 4 spaces per level of indentation) | ||
+ | * all code within the same scope aligned to its indentation level | ||
+ | * have proximal comments explaining your rationale and what is going on, throughout your code | ||
+ | * to STDERR, prompt for the starting value (0-1023) | ||
+ | * properly store this in a variable of type **signed short int** | ||
+ | * to STDERR, prompt for the ending value (0-1023) | ||
+ | * properly store this in a variable of type **signed short int** | ||
+ | * immediately after each input, check to make sure starting and ending values fall appropriately in the range stated; if in violation, display an error (to STDERR) and exit with a non-zero value. | ||
+ | * check the starting and ending values to determine if we are to perform an incrementation or a decrementation. | ||
+ | * in binary, display the starting number and all the others as well to the LEDs | ||
+ | * proceed to the next value in sequence, doing the same | ||
+ | * keep going until you have arrived at the ending value, visualizing it on the LEDs it as well | ||
+ | * using a single return statement at the conclusion of the code, return a 0 indicating successful operation | ||
+ | * if you do not have an LEDbar component (or a fully working LEDbar component), substitute as appropriate with individual LEDs (don't forget the resistors!) | ||
+ | |||
+ | Some additional points of consideration: | ||
+ | * Note that the driving variables in your loops need to be at least of type **short int**, otherwise you may get a warning when you compile it. | ||
+ | |||
+ | =====Execution===== | ||
+ | |||
+ | ====Sample incrementation run==== | ||
+ | <cli> | ||
+ | pi@raspberrypi: | ||
+ | Enter starting value (0-1023): 12 | ||
+ | Enter ending value (0-1023): 28 | ||
+ | pi@raspberrypi: | ||
+ | </ | ||
+ | |||
+ | The execution of the program is short and simple- obtain the input, do the processing, produce the output, and then terminate. | ||
+ | |||
+ | ====Sample decrementation run==== | ||
+ | <cli> | ||
+ | pi@raspberrypi: | ||
+ | Enter starting value (0-1023): 17 | ||
+ | Enter ending value (0-1023): 0 | ||
+ | pi@raspberrypi: | ||
+ | </ | ||
+ | |||
+ | ====Sample run with invalid input given (scenario 1)==== | ||
+ | <cli> | ||
+ | lab46: | ||
+ | Enter starting value (0-1023): 5543 | ||
+ | ERROR: input value must be between 0-1023! | ||
+ | lab46: | ||
+ | </ | ||
+ | |||
+ | ====Sample run with invalid input given (scenario 2)==== | ||
+ | <cli> | ||
+ | lab46: | ||
+ | Enter starting value (0-1023): 255 | ||
+ | Enter ending value (0-1023): 7168 | ||
+ | ERROR: input value must be between 0-1023! | ||
+ | lab46: | ||
+ | </ | ||
=====Obtaining binary values===== | =====Obtaining binary values===== | ||
Line 77: | Line 142: | ||
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | | | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | | ||
- | =====Program===== | + | So, if we wanted |
- | It is your task to adapt your bcf0 program so that, upon accepting various pieces of input from the user, acts as a binary counter, lighting up the resultant LEDs in binary (1 being on, 0 being off), inserting an adequate delay so we can watch as it proceeds from a starting to an ending value. | + | |
- | =====Specifications===== | + | <code c> |
- | Your program should: | + | value |
+ | </ | ||
- | * have valid, descriptive variable names of length //no shorter | + | We can then check of value is greater |
- | * have consistent, well-defined indentation (no less than 4 spaces per level of indentation) | + | |
- | * all code within the same scope aligned to its indentation level | + | |
- | * have proximal comments explaining your rationale and what is going on, throughout your code | + | |
- | * to STDERR, prompt for the starting value (0-1023) | + | |
- | * properly store this in a variable of type **signed short int** | + | |
- | * to STDERR, prompt for the ending value (0-1023) | + | |
- | * properly store this in a variable of type **signed short int** | + | |
- | * immediately after each input, check to make sure starting and ending values fall appropriately in the range stated; if in violation, display an error (to STDERR) and exit with a non-zero value. | + | |
- | * check the starting and ending values to determine if we are to perform an incrementation or a decrementation. | + | |
- | * in binary, display the starting number and all the others as well to the LEDs | + | |
- | * proceed to the next value in sequence, doing the same | + | |
- | * keep going until you have arrived at the ending value, visualizing it on the LEDs it as well | + | |
- | * using a single return statement at the conclusion of the code, return | + | |
- | * if you do not have an LEDbar component (or a fully working LEDbar component), substitute as appropriate with individual LEDs (don't forget the resistors!) | + | |
- | Some additional points of consideration: | + | We can then repeat |
- | * Note that the driving variables in your loops need to be at least of type **short int**, otherwise you may get a warning when you compile it. | + | |
- | =====Execution===== | + | NOTE that I have only taken us out to 8-bits. You may need to extend this to incorporate all the allowed values for this project. |
- | + | ||
- | ====Sample incrementation run==== | + | |
- | < | + | |
- | pi@raspberrypi: | + | |
- | Enter starting value (0-1023): 12 | + | |
- | Enter ending value (0-1023): 28 | + | |
- | pi@raspberrypi: | + | |
- | </ | + | |
- | + | ||
- | The execution of the program is short and simple- obtain the input, do the processing, produce the output, and then terminate. | + | |
- | + | ||
- | ====Sample decrementation run==== | + | |
- | < | + | |
- | pi@raspberrypi: | + | |
- | Enter starting value (0-1023): 17 | + | |
- | Enter ending value (0-1023): 0 | + | |
- | pi@raspberrypi: | + | |
- | </ | + | |
- | + | ||
- | ====Sample run with invalid input given (scenario 1)==== | + | |
- | < | + | |
- | lab46: | + | |
- | Enter starting value (0-1023): 5543 | + | |
- | ERROR: input value must be between 0-1023! | + | |
- | lab46: | + | |
- | </ | + | |
- | + | ||
- | ====Sample run with invalid input given (scenario 2)==== | + | |
- | < | + | |
- | lab46: | + | |
- | Enter starting value (0-1023): 255 | + | |
- | Enter ending value (0-1023): 7168 | + | |
- | ERROR: input value must be between 0-1023! | + | |
- | lab46: | + | |
- | </ | + | |
=====Submission===== | =====Submission===== | ||
Line 162: | Line 177: | ||
You should get some sort of confirmation indicating successful submission if all went according to plan. If not, check for typos and or locational mismatches. | You should get some sort of confirmation indicating successful submission if all went according to plan. If not, check for typos and or locational mismatches. | ||
- | |||
- | What I'll be looking for: | ||
- | |||
- | < | ||
- | 78: | ||
- | *: | ||
- | *: | ||
- | *: | ||
- | *: | ||
- | *:epf1:no negative compiler messages for program [13/13] | ||
- | *:epf1:code is pushed to lab46 repository [13/13] | ||
- | </ | ||
- | |||
- | Additionally: | ||
- | * Solutions not abiding by spirit of project will be subject to a 25% overall deduction | ||
- | * Solutions not utilizing descriptive why and how comments will be subject to a 25% overall deduction | ||
- | * Solutions not utilizing indentation to promote scope and clarity will be subject to a 25% overall deduction | ||
- | * Solutions not organized and easy to read are subject to a 25% overall deduction |