Car avoiding obsticles with support of ultrasonic sensor. Turn left or right decides with RANDOM function. Motors are controled with PWM ( analogwrite()) control. Right motor ( look from back side ) is connected to outputs 10 and 11. Left motor on outputs 6 an 9. Red light is connected to output 3 and green on output 5. Ultrasonic sensor is connected to 5V supply. Signal wire are connected to input 0 (black) and input 1 (blue). On Uno-F5 signal wire are connected to input 2 (black) and input 7 (blue). If you use Uno-F5, then do not forget to change this input numbers in program.
Barrier open when light source is cut. After two seconds, barrier start to close. DC motor is connected to outputs 3 and 5. Sensor light is connected to output 9. Photo sensor is connected to input A5. Micro switch ,under the motor, is connected to input A0 and Micro swithc under barrier on input A2.
Two Arduino UNO moduls with NRF24L01 modul. Sending and reciving data. Program samples are for two LEDs (red and green) and two switches. If you use Uno-F5, not forget to change numbers of INPUTs on which are switches connected (SEND program).
We count the state changes (values 1 and 0). This method is better accurate than the previous one (STEP). The number of impulses we will count depends on the program itself. If the program only controls the engine, or still performs other operations. In the second case, especially at higher engine speed, the program will not be able to read all pulses.
We only count impulses (value 1). So we need to put a little pause to prevent multiple sensor readings. This method is less precise. The number of impulses we will count depends on the program itself. If the program only controls the engine, or still performs other operations. In the second case, especially at higher engine speed, the program will not be able to read all pulses.
Using the ultrasonic sensor, we can measure the distance to the object in front of the sensor. Depending on the sensor, larger or smaller maximum distances can be read. The LED illuminates less when the distance from the sensor to the subject is smaller and vice versa.
With the help of an ultrasonic sensor we can detect an object when it is at a distance less than the one set in the program (the LED lights up). If the object is at a greater distance, the program will not register it.
The color sensor reads colors as values (analog). According to the apparent color value, a certain color of the LED lights up. The readings are VERY dependent on the conditions (illumination) and may vary even though the color patterns are the same