https://github.com/blessedrebus/proximity-light
Sensor Light powered by a ultrasound module (HC-SR04) built on a chip. (SMD for now)
https://github.com/blessedrebus/proximity-light
3d-printing arduino atmega328p electronic sensors
Last synced: about 2 months ago
JSON representation
Sensor Light powered by a ultrasound module (HC-SR04) built on a chip. (SMD for now)
- Host: GitHub
- URL: https://github.com/blessedrebus/proximity-light
- Owner: BlessedRebuS
- License: mit
- Created: 2021-08-30T23:38:28.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-10-25T16:03:13.000Z (over 2 years ago)
- Last Synced: 2025-01-29T07:30:32.537Z (4 months ago)
- Topics: 3d-printing, arduino, atmega328p, electronic, sensors
- Language: C++
- Homepage:
- Size: 8.35 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Proximity-Light

Sensor Light powered by a ultrasound module (HC-SR04) built on a chip. (SMD version).
When the proximity sensor sees an obsacle (for example your hand) the relays are toggled **(ON-OFF)** / **(OFF-OF)** and the 12v powers the pins.
The button triggers an interrupt (ATMega328P comes with D2 and D3 digital pin that can be used as interrupts, in this project only the D3 is used) that cycles 3 states:* Relay 1 ON Relay 2 OFF
* Relay 1 ON Relay 2 ON
* Relay 1 OFF Relay 2 OFFThe project idea is to put two led strips in the pair of pins near the supply that can help you illuminate the kitchen/bathroom/other rooms. Leds can be replaced with all type of stuff you want but it hasn't to drain much current (Max around 0.1 amp), you have only to solder your device in place. Now are only supported devices without data pins, so you have to use only the **VCC** and **GND**.
[See polarity and button](https://github.com/BlessedRebuS/Proximity-Light/blob/main/images/PinButton.png)
# Board
## Electronic Board
Created with Autodesk EAGLE and Fusion360 Electronic.To connect all pins we simply used autorouting.

## Board Schematic - Libraries
You can find all the libraries *(Footprint, Symbols and 3DModels)* [Here](https://github.com/BlessedRebuS/Proximity-Light/tree/main/libraries/Footprints)
## 3D Model
Designed and rendered in Fusion360


# Components* ATMega328P [Read more](#about-the-atmega328p)
* 22 PF Capacitors (Not polarized) 2x
* 20 MHZ Quartz Oscillator
* 220-1k OHM Resistor
* Ultrasonic Sensor (HC-SR04)
* 12 to 5V DC Mosfet
* 12V Supply Holder
* 12v Relays x2
* Button
* 2x1 pins x2
* 2x3 pins# About the ATMega328P
ATMega328p is a very versatile processor, mounted on Arduino, that can be used also separately with a different pinout. In this case the base clock 8MHZ is replaced with the 16MHZ clock (not necessary) connected to the two grounded capacitors to generate the oscillation.
**How to program it?** I suggest to use the [USBASP programmer](www.learningaboutelectronics.com/Articles/Program-AVR-chip-using-a-USBASP-with-10-pin-cable.php) (6 or 10 PIN), but you can use an Arduino using "Arduino as ISP" programming.
## The clock
As [Here](https://doc.riot-os.org/group__boards__atmega328p.html) is explained:> The ATmega328p has two internal oscillators clocked at 8MHz and at 128kHz that allow it to be operated without any external clock source or crystal. By default the fuses are configured to use the internal 8MHz oscillator and a clock divider resulting in a clock speed of 1MHz. By clearing the CKDIV8 fuse the clock divider can be disabled to operate the ATmega328p at 8MHz without an external clock source. This can be done like this:
>
> `avrdude -c usbtiny -p m328p -B 32 -U lfuse:w:0xe2:m`
>
> (Replace usbtiny with the ISP programmer you are using. The -B 32 might be needed on some ISP programmers to communicate with slow ATmega MCUs. It will not be needed anymore after the clock device has been disabled.)
This "board" is configured to use 8MHz as core clock, so that the ATmega328p runs at the highest frequency possible without external clock sources.
By setting the environment variable ATMEGA328P_CLOCK to a custom frequency in Hz (e.g. 1000000 for 1MHz), this core clock can be changed easily. Refer to the datasheet on how to configure the ATmega328p to use an external crystal, an external clock source or the clock divider.
![]()