This shows you the differences between two versions of the page.
|
pm:prj2023:apredescu:cyclocomputer [2023/05/25 22:36] andrei.cioltan [Software Design] |
pm:prj2023:apredescu:cyclocomputer [2023/05/29 22:22] (current) andrei.cioltan [Software Design] |
||
|---|---|---|---|
| Line 36: | Line 36: | ||
| {{ :pm:prj2023:apredescu:cioltan_andrei_hardware1.jpeg?800 |}} | {{ :pm:prj2023:apredescu:cioltan_andrei_hardware1.jpeg?800 |}} | ||
| + | |||
| + | {{ :pm:prj2023:apredescu:cioltan_andrei_h2.jpeg?800 |}} | ||
| + | |||
| + | {{ :pm:prj2023:apredescu:cioltan_andrei_h1.jpeg?800 |}} | ||
| + | |||
| + | |||
| ===== Software Design ===== | ===== Software Design ===== | ||
| Line 41: | Line 47: | ||
| <code> | <code> | ||
| #include <LiquidCrystal_I2C.h> // Library for LCD | #include <LiquidCrystal_I2C.h> // Library for LCD | ||
| - | #define LED 10 | + | #define LED 7 |
| - | #define B1 6 | + | #define B1 9 |
| - | #define B2 7 | + | #define B2 8 |
| - | #define reed 12 | + | #define reed 6 |
| LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C address 0x27, 16 column and 2 rows | LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C address 0x27, 16 column and 2 rows | ||
| - | |||
| float radius = 13;// tire radius (in inches) | float radius = 13;// tire radius (in inches) | ||
| int reedVal; | int reedVal; | ||
| Line 76: | Line 81: | ||
| void setup(){ | void setup(){ | ||
| - | | ||
| lcd.init(); //initialize the lcd | lcd.init(); //initialize the lcd | ||
| lcd.backlight(); //open the backlight | lcd.backlight(); //open the backlight | ||
| + | lcd.begin(16, 2); | ||
| pinMode(B1, INPUT_PULLUP); | pinMode(B1, INPUT_PULLUP); | ||
| pinMode(B2, INPUT_PULLUP); | pinMode(B2, INPUT_PULLUP); | ||
| Line 162: | Line 167: | ||
| if (reedVal != 1){ | if (reedVal != 1){ | ||
| if (reedCounter == 0){//min time between pulses has passed | if (reedCounter == 0){//min time between pulses has passed | ||
| - | kph = (56.8 * float(circumference))/float(timer);//calculate miles per hour | + | //kph = (56.8 * float(circumference))/float(timer);//calculate miles per hour |
| - | kph *= 1.60934;// calculate km per hour | + | //kph *= 1.60934;// calculate km per hour |
| + | kph = (3600 * (float(circumference) * 0.0254)) / float(timer); | ||
| totalDistanceTraveled += (circumference / 39370.07); | totalDistanceTraveled += (circumference / 39370.07); | ||
| totalReadings++; | totalReadings++; | ||
| Line 200: | Line 206: | ||
| lcd.print("Wheel Size "); | lcd.print("Wheel Size "); | ||
| lcd.print(radius * 2); | lcd.print(radius * 2); | ||
| - | delay(1000); | + | delay(700); |
| lcd.clear(); | lcd.clear(); | ||
| lastSize = radius; | lastSize = radius; | ||
| Line 214: | Line 220: | ||
| lcd.print("Sprint"); | lcd.print("Sprint"); | ||
| lcd.print(" Mode"); | lcd.print(" Mode"); | ||
| - | delay(1000); | + | delay(700); |
| lcd.clear(); | lcd.clear(); | ||
| lastMode = mode; | lastMode = mode; | ||
| Line 242: | Line 248: | ||
| delay(500); | delay(500); | ||
| } | } | ||
| + | |||
| </code> | </code> | ||
| Line 269: | Line 276: | ||
| <note> | <note> | ||
| - | Listă cu documente, datasheet-uri, resurse Internet folosite, eventual grupate pe **Resurse Software** şi **Resurse Hardware**. | + | Listă cu documente, datasheet-uri, resurse Internet folosite: |
| + | |||
| + | [[https://en.wikipedia.org/wiki/Cyclocomputer]] | ||
| + | |||
| + | [[https://arduinogetstarted.com/tutorials/arduino-lcd-i2c]] | ||
| + | |||
| + | [[https://sensorkit.joy-it.net/en/sensors/ky-024]] | ||
| </note> | </note> | ||
| <html><a class="media mediafile mf_pdf" href="?do=export_pdf">Export to PDF</a></html> | <html><a class="media mediafile mf_pdf" href="?do=export_pdf">Export to PDF</a></html> | ||