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.
Fork of Muscle_Controlled_Servo by
main.cpp@5:11489c0bd020, 2018-04-05 (annotated)
- Committer:
- BenRJG
- Date:
- Thu Apr 05 15:54:48 2018 +0000
- Revision:
- 5:11489c0bd020
- Parent:
- 2:b615682e3e4f
- Child:
- 6:a61b01442f37
Separated functions to individual SPI, FPGA, LCD and ADC files
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| BenRJG | 5:11489c0bd020 | 1 | #include "FPGA.h" |
| BenRJG | 5:11489c0bd020 | 2 | #include "LCD.h" |
| BenRJG | 5:11489c0bd020 | 3 | #include "ADC.h" |
| BenRJG | 5:11489c0bd020 | 4 | float adval; |
| BenRJG | 5:11489c0bd020 | 5 | char adstr[32]; |
| BenRJG | 5:11489c0bd020 | 6 | int err; //error variable used for debugging, trapping etc |
| BenRJG | 0:87903e5535bc | 7 | |
| BenRJG | 0:87903e5535bc | 8 | int main (void) |
| BenRJG | 2:b615682e3e4f | 9 | { |
| BenRJG | 2:b615682e3e4f | 10 | SPI_INIT(); |
| BenRJG | 5:11489c0bd020 | 11 | /*err = 0; |
| BenRJG | 5:11489c0bd020 | 12 | |
| BenRJG | 5:11489c0bd020 | 13 | adval =0.0f; |
| BenRJG | 5:11489c0bd020 | 14 | |
| BenRJG | 5:11489c0bd020 | 15 | adval = read_adc(); |
| BenRJG | 5:11489c0bd020 | 16 | |
| BenRJG | 5:11489c0bd020 | 17 | sprintf(adstr,"%.3f",adval); //Store in an array string |
| BenRJG | 5:11489c0bd020 | 18 | lcd_locate(1,8); //and display on LCD |
| BenRJG | 5:11489c0bd020 | 19 | lcd_display(adstr); // |
| BenRJG | 5:11489c0bd020 | 20 | |
| BenRJG | 5:11489c0bd020 | 21 | err = bar_graph(((adval/3.3f)*4095)/255); // 16*256 =4096 12 bit ADC! |
| BenRJG | 5:11489c0bd020 | 22 | |
| BenRJG | 5:11489c0bd020 | 23 | if (err < 0){printf("Display Overload\r\n");}*/ |
| BenRJG | 5:11489c0bd020 | 24 | |
| BenRJG | 1:acc66d3a1a1c | 25 | while(true) //Loop forever Knight Rider Display on FPGA |
| BenRJG | 0:87903e5535bc | 26 | { |
| BenRJG | 2:b615682e3e4f | 27 | SPI_TEST(); |
| BenRJG | 0:87903e5535bc | 28 | } |
| BenRJG | 0:87903e5535bc | 29 | } |
