An Arduino UNO example that measures the time a pushbutton is pressed. Has the possibility to use these durations to trigger different actions.

In my honest opinion, OLED is so much easier to use than LCD display technology, for just a few bucks more!
Here is an example with lots of pertinent comments added by myself. Have fun!

Most sensor assortments for the Arduino contain a DHT11 tmeperature and humidity sensor. This example will test it out, showing the results on an OLED display. Just about any Arduino UNO version will do, even the tiny Nano ESP32. The line Serial.println(humidity); was used for testing.

The HC-SR501 Motion Detector is included in many Arduino sensor kits. It is recognizable by its dome shaped white plastic Fresnel lens. It detects any infra red emitting moving object. Pets, humans yes, but no ghosts! The sensor pairs up very well with any Arduino UNO or Nano.

You must have heard the story about the person getting into a dark room, frantically waving arms, only to find out that the room had an ordinary light switch.

Absolutely! Arduino is a great way to turn a computer from something that only processes information into something that can actually interact with the physical world. I especially like how beginner-friendly it is. Being able to start with simple sensors and gradually move into motors, automation and more makes it a fun project for learning.

commented: I agree, it is fun! +4

The HC-SR04 Distance Sensor looks like a pair of eyes. It does not use light, it uses sonar, more correctly Ultra Sound to measure distances. Each 'eye' contains a membrane speaker/microphone. One is a transmitter called 'Trigger' and the other a receiver called 'Echo'. The Trigger sends out a pulse of 40 kHz ultra sound (beyond human hearing), whose echo comes back to the Echo receiver. A set of ICs times the duration, which relates to the distance. The Arduino does the calculation based on the speed of sound. The result is fairly accurate within a range of 2 to 400 cm.

The Arduino UNO has a good number of C++ based functions available through its Arduino IDE. Just check
https://docs.arduino.cc/language-reference/ if you are curious.
The older UNO R3 is a little limited in memory, but the UNO R4 has removed that concern, so you can write much longer C++ code.

The Arduino engineers in Italy have not sat still, they went to bed with Qualcomm and basically added a Qualcomm Dragonwing QRB2210 chip running Debian Linux on the Arduino R4 WiFi board and increased memory drastically to several Giga Bytes. A full version of Python3 is also on board. The two systems can 'talk' to each other. They call the whole thing an 'Arduino UNO Q', the price is an affordable $55. I have mine on order to evaluate.

The best of two worlds, you can still use C++ for the R4, but also Python to handle data generated.

In the distance measurement with ultra sound there is a bobo in the remarks, I meant to say:
At 20C the speed of sound is 0.0343 cm/microsec, duration in microsec
distance_cm = (duration/2)*0.0343

This way the dimensions come out correctly, a rule of Physics!

If you play around with Arduino computer interface boards, you most likely have also invested a few bucks in a sensor assortment. On a number of these tiny sensor boards the bottom half looks much the same. The blue plastic box with a small screw is a potentiometer that adjusts the threshold voltage to the 8 pin integrated circuit next to it. That IC is a comparator whose output flips LOW to HIGH at the threshold set. There is a tiny red LED turning on when HIGH just below the potentiometer. If you are lucky, you have one of those eyeglass repair screwdrivers needed for the adjustment.

The top half of the sensor board shows the actual sensing element. Some are easy to figure out. If it look like a microphone in a round metal container, then it will sense sound. A shiny black thing with two wires is most likely a temperature sensor. Another has a black plastic body with shiny metal through its center, that is a finger touch sensor. A dome shaped black item with 2 wires will be the flame sensor. A black rectangular plastic thing with 3 wires could be a Hall effect sensor that measures the strength and polarity of a magnetic field near it.

These sensors are quite sophisticated for a mere 50 cents a piece. The best place to get information (with pictures) is:
https://arduinomodules.info/

One of the items in the sensor assortment was a gated laser diode. So right now I am shooting those red laser beams, familiar from the James Bond movies, through my office. Hoping to avoid them through proper gymnastics.

The Arduino UNO can impose some kind of Morse code onto the beam.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.