Soluții

Arduino Distance Sensor with OLED Display

This project uses an HC-SR04 Ultrasonic Distance Sensor and a 0.96” I2C OLED display to measure and display the distance to an object in real-time.
It’s an excellent beginner-to-intermediate Arduino project that teaches sensor interfacing, I2C communication, and real-time data display.

In this guide, you’ll learn how to:

  • Connect and use the HC-SR04 Ultrasonic Sensor
  • Display the measured distance on an OLED screen
  • Format readings for easy readability

Components Required

Component Quantity Description
Arduino Uno / Nano / Mega 1 Main controller
HC-SR04 Ultrasonic Sensor 1 Measures distance via sound waves
0.96” OLED Display (SSD1306) 1 I2C display for output
Breadboard 1 For wiring
Jumper wires 6–8 Male-to-male connections
USB cable 1 For programming and power

The HC-SR04 measures distance by sending out an ultrasonic pulse and timing how long it takes to bounce back.
The Arduino calculates the distance based on the time delay and the known speed of sound.

Distance Formula:

Distance (cm) = (Time in microseconds × 0.034) / 2

The division by 2 accounts for the round trip of the sound wave (out and back).

Pin Connections

Component Arduino Pin Notes
HC-SR04 VCC 5V Power supply
HC-SR04 GND GND Common ground
HC-SR04 TRIG D9 Trigger pin
HC-SR04 ECHO D10 Echo pin
OLED VCC 5V Power
OLED GND GND Ground
OLED SDA A4 I2C Data
OLED SCL A5 I2C Clock

Note: On Arduino Mega, use SDA = 20 and SCL = 21 instead.

Arduino Code Example


#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define TRIG_PIN 9
#define ECHO_PIN 10
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

void setup() {
Serial.begin(9600);
pinMode(TRIG_PIN, OUTPUT);
pinMode(ECHO_PIN, INPUT);

// Initialize OLED
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println("OLED not found!");
while (true);
}

display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 0);
display.println("Distance Sensor");
display.display();
delay(1500);
}

void loop() {
long duration;
float distance;

// Send trigger pulse
digitalWrite(TRIG_PIN, LOW);
delayMicroseconds(2);
digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);

// Measure echo time
duration = pulseIn(ECHO_PIN, HIGH);
distance = (duration * 0.034) / 2;

// Print to Serial Monitor
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");

// Display on OLED
display.clearDisplay();
display.setTextSize(1);
display.setCursor(0, 0);
display.println("Distance Sensor");

display.setTextSize(2);
display.setCursor(0, 30);
display.print(distance, 1);
display.println(" cm");
display.display();

delay(500);
}

Explanation: The Arduino sends a pulse from the HC-SR04 and measures the time it takes to return.
It then converts this time into distance and displays it on the OLED screen.

Code Breakdown

  • pulseIn() measures the length of time the echo pin is HIGH.
  • Distance is calculated using the speed of sound (0.034 cm/μs).
  • Adafruit_SSD1306 and Adafruit_GFX libraries drive the OLED.
  • Display refreshes every 0.5 seconds for updated readings.

Install these via Arduino IDE → Sketch → Include Library → Manage Libraries:

  • Adafruit SSD1306
  • Adafruit GFX

Search for “Adafruit SSD1306” and “Adafruit GFX” and click Install.

Troubleshooting

Issue Cause Solution
OLED blank Wrong I2C address Try changing 0x3C to 0x3D
Distance always 0 Echo pin not connected Check TRIG and ECHO wiring
Unstable readings Object too close or far HC-SR04 range: 2–400 cm
Serial Monitor empty Wrong baud rate Ensure 9600 baud in Serial Monitor

Optional Upgrades

  • Add a buzzer that activates when an object is too close.
  • Display a bar graph or animation on the OLED.
  • Send readings to the cloud using ESP8266 / ESP32.
  • Log readings to an SD card.

Applications

  • Parking assist system
  • Object detection robot
  • Smart trash bin (auto open lid)
  • Liquid level detector.
[mai mult...]

How to fix Printers that stop scanning without ink

1. Canon PIXMA Printer Override

Canon often provides the simplest override through a physical button press on the printer itself:

  • Locate the Stop/Reset Button: Look for the button marked with a red circle containing a triangle symbol, or sometimes labelled Resume/Cancel.
  • Perform the Override: Press and hold this Stop/Reset button for 5 to 10 seconds and then release it.
  • Result: This action should disable the ink-level detection for the empty cartridge(s) and allow the scanning function to work. If you receive a warning that ink detection is disabled, confirm it.

2. HP All-in-One Printer Workarounds

HP models are less consistent, but the solution often lies in the software or control panel settings:

  • Adjust Cartridge Settings: Access the printer’s on-screen menu or the HP utility software on your computer. Look for settings related to ‘Ink Alert,’ ‘Low on Ink,’ or ‘Cartridge Protection.’ If an option exists to ‘Continue,’ ‘Ignore,’ or ‘Disable Protection,’ select it.
  • Use the HP Smart App: Initiate the scanning process directly from the HP Smart App on your computer or mobile device. This can sometimes bypass the local printer’s control panel lockout.
  • Check for Hidden Menus: For certain older models with a touch screen, there might be a specific sequence of pressing the screen (like a Back, X, Back, Back, Back sequence) to access a service or support menu where status checks can be toggled. (Use this advanced method with caution.)

3. General Troubleshooting Steps (All Brands)

If the brand-specific methods fail, try these common steps:

A. Power Cycle / Hard Reset

  1. Turn the printer OFF using the power button.
  2. Unplug the power cord completely from both the printer and the wall outlet.
  3. Wait for a full 60 seconds.
  4. Plug the power cord back in and power the printer on. This clears the temporary error status.

B. Use Native Computer Scanning Software

Bypass the printer’s restrictive drivers by using the operating system’s built-in tools, which communicate more directly with the scanner hardware:

  • Windows: Use the Windows Fax and Scan utility or the Windows Scan app.
  • macOS: Use Image Capture (found in the Applications folder).

C. Clean Cartridge Contacts

A recognition error can sometimes be mistaken for an empty cartridge:

  1. Turn the printer off and unplug it.
  2. Remove the empty cartridge(s).
  3. Gently wipe the copper or gold contacts on the cartridge (and inside the carriage) with a lint-free cloth.
  4. Re-insert the cartridges firmly.

D. Update/Reinstall Drivers

  • Visit the manufacturer’s website and install the latest full driver software package for your model.
  • Alternatively, uninstalling all existing printer software and reinstalling only the basic native driver can remove restrictive software components.
[mai mult...]

How to stop iPhone battery throttling

The iPhone (typically models 6, 6s, SE, 7, and 7 Plus) becomes noticeably slow, apps take a long time to load, and frame rates drop significantly. This is caused by Apple’s “Performance Management” software, which is automatically enabled after the device experiences an unexpected shutdown, due to the aged battery being unable to supply the necessary power during peak demand.

[mai mult...]

Remediere: Apple CarPlay not working

CarPlay poate să nu funcționeze din mai multe motive: conexiune defectuoasă, restricții iOS, probleme cu mașina sau bug software. Mai jos ai toți pașii de depanare, în ordine logică:

1. Verifică cerințele de bază

  1. iPhone compatibil: CarPlay funcționează pe iPhone 5 sau mai nou, cu iOS 7.1+.

  2. Mașina compatibilă: nu toate modelele au CarPlay (verifică manualul sau site-ul producătorului).

  3. Cablu Lightning original Apple — cablurile necertificate pot cauza deconectări.
    Dacă folosești wireless CarPlay, treci la pasul 4.

2. Verifică dacă CarPlay este activat pe iPhone

  1. Mergi la Settings → General → CarPlay.

  2. Dacă mașina ta apare în listă:

    • Apasă pe ea → „Forget This Car”.

    • Repornește iPhone-ul și reconectează-l.

  3. Dacă nu apare deloc, conectează iPhone-ul cu cablul și vezi dacă apare în listă.

3. Depanare pentru CarPlay cu cablu (USB)

Verifică:

  • Portul USB — curăță-l ușor; încearcă alt port (unele mașini au un singur port dedicat CarPlay).

  • Încearcă alt cablu original.

  • Asigură-te că iPhone-ul este deblocat la prima conectare.

Dacă nu se conectează:

  • Mergi la Settings → General → CarPlay → Available Cars și reconectează manual.

4. Depanare pentru CarPlay Wireless

  1. Activează Wi-Fi și Bluetooth pe iPhone

  2. Mergi la Settings → Wi-Fi → Activează Wi-Fi (chiar dacă e conectat deja la mașină)

  3. Mergi la Settings → Bluetooth și uită conexiunea mașinii („Forget This Device”)

  4. Repornește iPhone-ul și sistemul multimedia al mașinii

  5. Reasociază din meniul mașinii → „Add Apple CarPlay Device”

5. Verifică restricțiile

Uneori CarPlay e blocat de setările de ecran.

  1. Mergi la Settings → Screen Time → Content & Privacy Restrictions.

  2. Activează „Content & Privacy Restrictions”.

  3. Apoi mergi la:

    • Allowed Apps → CarPlay → ON

    • Allowed Content → Privacy → Allow CarPlay

6. Repornește tot

  1. Repornește iPhone-ul

  2. Repornește sistemul multimedia al mașinii (uneori ținând apăsat butonul Power 10 secunde)

  3. Reconectează cablul sau reinițiază conexiunea wireless.

7. Actualizează software-ul

  • iPhone: Settings → General → Software Update

  • Mașina: verifică la dealer dacă există update pentru sistemul de infotainment

Bug-urile CarPlay se remediază adesea prin actualizări.

8. Resetează setările de rețea (dacă nimic nu funcționează)

  1. Settings → General → Transfer or Reset iPhone → Reset → Reset Network Settings.
  2. iPhone-ul va uita toate conexiunile Wi-Fi / Bluetooth.

  3. Repornește și reconectează CarPlay.

9. Dacă apare mesajul „CarPlay not available” sau „Connection failed”

 Posibile cauze:

  • Sistemul mașinii e ocupat cu alt dispozitiv Bluetooth.

  • Portul USB nu e dedicat CarPlay.

  • Senzorul MFi (Made for iPhone) e defect → necesită service.

[mai mult...]