Differences

This shows you the differences between two versions of the page.

Link to this comparison view

pm:prj2025:avaduva:sorin.popescu2306 [2025/05/17 23:59]
sorin.popescu2306 [Hardware Design]
pm:prj2025:avaduva:sorin.popescu2306 [2025/05/26 00:06] (current)
sorin.popescu2306 [Rezultate Obţinute]
Line 58: Line 58:
 | HX711 Module | [OptimusDigital](https://​www.optimusdigital.ro/​en/​others/​130-hx711-instrumentation-module.html) | HX711 Instrumentation Module | | HX711 Module | [OptimusDigital](https://​www.optimusdigital.ro/​en/​others/​130-hx711-instrumentation-module.html) | HX711 Instrumentation Module |
 | Breadboard Kit | [OptimusDigital](https://​www.optimusdigital.ro/​en/​kits/​2222-breadboard-kit-hq-830-p.html) | Breadboard Kit HQ 830 points | | Breadboard Kit | [OptimusDigital](https://​www.optimusdigital.ro/​en/​kits/​2222-breadboard-kit-hq-830-p.html) | Breadboard Kit HQ 830 points |
 +
 +{{:​pm:​prj2025:​avaduva:​circuitscheme.png?​800|}}
  
 == Hardware Connections == == Hardware Connections ==
Line 112: Line 114:
 '''​Power Source:'''​ USB AM-BM connected to Arduino Mega '''​Power Source:'''​ USB AM-BM connected to Arduino Mega
 ''​Note:'''​ 5V and GND lines distributed on both sides of breadboard ''​Note:'''​ 5V and GND lines distributed on both sides of breadboard
 +
 +{{:​pm:​prj2025:​avaduva:​pozacurent.jpg?​600|}}
 +
 +Both the display and the buzzer works, the dislpay can be seen in the picture, as for the buzzer, it was tested using a script.
  
 ===== Software Design ===== ===== Software Design =====
  
 +=== Development Environment ===
 +The firmware was developed using '''​Visual Studio Code'''​ with the '''​PlatformIO'''​ extension. This setup offers efficient dependency management, integrated serial monitor support, and cross-platform compilation.
 +
 +=== Libraries and Third-Party Sources ===
 +The following third-party libraries were used:
 +
 + '''​Adafruit_SSD1306'''​ – controls the OLED display via I2C.
 + '''​Adafruit_GFX'''​ – provides graphics primitives for the display.
 + '''​HX711'''​ – interfaces with the load cell and reads weight data.
 + '''​Keypad'''​ – handles input from the 4x3 matrix keypad.
 +
 +These libraries simplify hardware communication and allow for clean, readable application logic.
 +
 +=== Algorithms and Structures Implemented ===
 +
 + A simple '''​menu system'''​ navigated using the keypad, allowing selection between two modes:
 +** '''​Guess the Weight'''​ – user estimates an object’s weight and inputs the guess via keypad.
 +** '''​Match the Weight'''​ – user adds objects to match a previously recorded weight.
 + The '''​buzzer'''​ plays dynamic tones in "Match the Weight"​ mode. The rhythm (tone interval) increases as the current weight gets closer to the target.
 + A '''​state-driven structure'''​ manages transitions between menu, gameplay, and results.
 + The OLED screen provides '''​real-time feedback''',​ such as instructions,​ results, and animated weight indicators.
 +
 +=== Implemented Functions and Sources ===
 +
 + <​code>​drawMenu()</​code>​ – displays the main menu with selection cursor.
 + <​code>​startGuessTheWeight()</​code>​ – logic for guessing the weight of an object.
 + <​code>​startMatchTheWeight()</​code>​ – records a target weight, provides animation and rhythm-based buzzer feedback as the player matches it.
 + <​code>​playMatchingTones(currentWeight,​ targetWeight)</​code>​ – adjusts buzzer rhythm according to proximity to target.
 + <​code>​drawWeightAnimation(animY)</​code>​ – animates a simple visual indicator on the OLED screen.
 + <​code>​playSuccessTone()</​code>​ – plays a tone sequence when the task is completed correctly.
 +
 +The software combines interaction,​ sound, and visual elements to create an engaging user experience.
 +
 +
 +==== Justification for Using Laboratory Functionalities in the Project ====
 +
 +=== OLED Display and I2C Communication (Lab 6 - I2C) ===
 +The OLED screen is used to display menus, game instructions,​ and feedback to the user. It communicates via the I2C protocol using the Wire library. Functions such as <​code>​display.begin()</​code>,​ <​code>​display.clearDisplay()</​code>,​ and <​code>​display.display()</​code>​ reflect the practical application of Lab 6 concepts.
 +
 +=== Buzzer and Tone Generation (Lab 3 - PWM) ===
 +The buzzer is used to provide audio feedback in the "Match the Weight"​ game. The <​code>​tone()</​code>​ function utilizes the PWM feature to generate audio signals. As the weight approaches the target value, the rhythm speeds up, demonstrating real-time control over frequency generation.
 +
 +=== Weight Reading via HX711 (Lab 4 - ADC) ===
 +The weight sensor is interfaced using the HX711 ADC module, which reads analog signals from a load cell. This directly implements the analog-to-digital conversion concepts introduced in Lab 4. The function <​code>​scale.get_units()</​code>​ reads these values in digital form.
 +
 +=== Matrix Keypad Input (Lab 0 - Digital Inputs) ===
 +The 4x3 matrix keypad allows the user to input commands and navigate the menu. It is scanned to detect key presses by reading digital signals, which aligns with the digital input techniques introduced in Lab 0.
 +
 +=== Serial Communication (Lab 1 - USART) ===
 +<​code>​Serial.print()</​code>​ and <​code>​Serial.println()</​code>​ are used for debugging and displaying values such as the current weight. This is a practical use of USART, as explored in Lab 1.
 +
 +=== Timing and Delays (Lab 2 / Lab 3) ===
 +Delays using <​code>​delay()</​code>​ are introduced to manage user interaction timing (e.g., allowing the user to see feedback before the next step). These practices relate to timing management topics covered in Labs 2 and 3.
 +
 +== Summary Table ==
 +
 +|-
 +| OLED (I2C) || Lab 6 || Display via I2C; menu and feedback interface
 +|-
 +| Buzzer (PWM) || Lab 3 || Audio feedback using PWM and tone frequency
 +|-
 +| HX711 (ADC) || Lab 4 || Reading analog signals via ADC
 +|-
 +| Matrix Keypad || Lab 0 || Digital input and key scanning
 +|-
 +| Serial Communication || Lab 1 || Debugging and displaying weight values
 +|-
 +| Menu / State Logic || Lab 2 || Event-based state handling
 +|-
 +| Timing / Delays || Lab 2 / Lab 3 || Managing time-based interactions
 +|}
 +
 +==== Project Structure and Feature Interaction ====
 +
 +=== OLED Display (Adafruit SSD1306 128x64) ===
 + Shows the main menu, game instructions,​ user prompts, and results.
 + ​Provides all visual feedback to the user during setup and gameplay.
 +
 +=== HX711 Weight Sensor + Load Cell ===
 + ​Accurately measures the weight of objects placed on the device.
 + Used in both games to set or check the weight value.
 +
 +=== 4x3 Keypad ===
 + Lets the user navigate menus, select game modes, and enter numerical guesses or commands (such as start, confirm, or return to menu).
 +
 +=== Buzzer ===
 + ​Outputs audio signals for feedback.
 + Plays different tones to indicate success or to help the user get closer to the target weight in the matching game.
 +
 +=== Arduino Board ===
 + ​Central controller that runs the main program.
 + Reads inputs from the keypad and weight sensor, updates the display, and controls the buzzer.
 +
 +==== Functionalities Validation ====
 +To test the weight sensor, I weighed an object with a kitchen scale and checked if the values matched.
 +
 +==== Sensor Calibration ====
 +For the weight sensor, I used an object with a known weight (75 grams) and observed the sensor reading (approximately 148,500). Based on this, I calculated the calibration factor as (sensor_value / actual_weight).
 +
 +==== Optimization ====
 +
 +Used modular functions for clarity and easier maintenance.
 +
 +Limited display updates to only when changes occur, reducing flicker.
 +
 +Grouped hardware initialization in setup for faster start.
 +
 +Provided immediate feedback with the buzzer for better user experience.
 +  ​
 +Used keypad library debouncing for reliable input.
 +
 +Calibrated the weight sensor once for consistent measurements.
  
-<note tip> 
-Descrierea codului aplicaţiei (firmware): 
-  * mediu de dezvoltare (if any) (e.g. AVR Studio, CodeVisionAVR) 
-  * librării şi surse 3rd-party (e.g. Procyon AVRlib) 
-  * algoritmi şi structuri pe care plănuiţi să le implementaţi 
-  * (etapa 3) surse şi funcţii implementate 
-</​note>​ 
  
 ===== Rezultate Obţinute ===== ===== Rezultate Obţinute =====
  
-<note tip> 
-Care au fost rezultatele obţinute în urma realizării proiectului vostru. 
-</​note>​ 
  
 +**Demo**
 +
 +<​html><​iframe width="​560"​ height="​315"​ src="​https://​youtube.com/​embed/​iKKtlptE3Co"​ title="​YouTube video player"​ frameborder="​0"​ allow="​accelerometer;​ autoplay; clipboard-write;​ encrypted-media;​ gyroscope; picture-in-picture;​ web-share"​ referrerpolicy="​strict-origin-when-cross-origin"​ allowfullscreen></​iframe></​html>​
 ===== Concluzii ===== ===== Concluzii =====
  
 ===== Download ===== ===== Download =====
  
-<note warning>​ +{{:pm:prj2025:avaduva:guesstheweight.zip}}
-O arhivă (sau mai multe dacă este cazul) cu fişierele obţinute în urma realizării proiectului:​ surse, scheme, etc. Un fişier README, un ChangeLog, un script de compilare şi copiere automată pe uC crează întotdeauna o impresie bună ;-). +
- +
-Fişierele se încarcă pe wiki folosind facilitatea **Add Images or other files**. Namespace-ul în care se încarcă fişierele este de tipul **:​pm:​prj20??:​c?​** sau **:​pm:​prj20??:​c?:​nume_student** (dacă este cazul). **Exemplu:​** Dumitru Alin, 331CC -> **:pm:prj2009:cc:dumitru_alin**. +
-</​note>​+
  
 ===== Jurnal ===== ===== Jurnal =====
pm/prj2025/avaduva/sorin.popescu2306.1747515595.txt.gz · Last modified: 2025/05/17 23:59 by sorin.popescu2306
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0