Hello everyone. I am trying to make an alarming system to protect my eyes from laptop's screen radiation. I wrote this code and made the circuit. The code doesn't give any error messages and I also double checked my circuit according to the diagram. But when I plug the Arduino Nano in and upload the code, nothing really happens. No readings from the sonar sensor, the OLED display stays black, the LEDs don't light up and the buzzer also stays silent. I tried same circuit with the same code with another Arduino Uno. But same case. But when I test the HC-SR04 Ultrasonic Sonar Sensor or the OLED display individually, it works completely fine whether I'm using the nano or uno. Can someone help me find out where is the problem?
You must also detect if the user is not present (out of range) for a sufficiently long interval so you can reset sTime. sTime must be either a global variable or , if you keep it in the loop(), a static variable.
Have a look at debugging methods ( google Arduino debugging)
Add code to just print to the display or print to the serial monitor the value of some of your variables to help you spot what is going wrong , flash the leds in setup , write your code in small sections and check each as you go etc etc..
Aaaarrgh too late .. my iPhone has damaged my eyes ..
You have red and yellow swapped. The wiring diagram shows yellow on Pin 5 and red on Pin 7.
Your wiring diagram doesn't show a "Reset" line from the OLED to Pin 4.
WARNING: Some breadboards have a break in the power rails half-way down each side. If yours does, that could explain why some parts of the circuit are not getting power and/or ground.
Same problem i have also face. Alter the HCSR04 module with another one and also change the Arduino UNO board. But problem is same. In serial monitor always get 0.00 (ZERO distance).
#include <HCSR04.h>
HCSR04 hc(13,11);//initialisation class HCSR04 (trig pin , echo pin)
void setup()
{ Serial.begin(9600); }
void loop()
{ Serial.println(hc.dist()); } //return curent distance in serial
// End of the Code
This is the simple code get from the official website. But distance is not be measured.