Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* Pleasedontcode.com **********
- Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- - Terms and Conditions:
- You have a non-exclusive, revocable, worldwide, royalty-free license
- for personal and commercial use. Attribution is optional; modifications
- are allowed, but you're responsible for code maintenance. We're not
- liable for any loss or damage. For full terms,
- please visit pleasedontcode.com/termsandconditions.
- - Project: "Relay Control"
- - Source Code NOT compiled for: Arduino Nano
- - Source Code created on: 2025-03-09 16:45:46
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* "Generate a clear and labeled circuit diagram for */
- /* an Arduino-based misting system using a 2N2222 */
- /* transistor, a relay module, and a 12V water pump. */
- /* : Arduino RF Nano V3.0 D11 → Base of 2N2222 */
- /* transistor (with a 1kΩ resistor i */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- /****** DEFINITION OF LIBRARIES *****/
- #include <Relay.h> //https://github.com/rafaelnsantos/Relay
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
- const uint8_t myRelay_RelayModule_Signal_PIN_D2 = 2; // Relay module signal pin
- const uint8_t transistorBasePin = 11; // Pin connected to the base of the 2N2222 transistor
- /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
- /***** used to store raw data *****/
- bool myRelay_RelayModule_Signal_PIN_D2_rawData = 0;
- /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
- /***** used to store data after characteristic curve transformation *****/
- float myRelay_RelayModule_Signal_PIN_D2_phyData = 0.0;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- // Create an instance of the Relay class
- Relay myRelay(myRelay_RelayModule_Signal_PIN_D2, 10); // Example period of 10 seconds
- void setup(void)
- {
- // put your setup code here, to run once:
- pinMode(myRelay_RelayModule_Signal_PIN_D2, OUTPUT);
- pinMode(transistorBasePin, OUTPUT); // Set the transistor base pin as output
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- updateOutputs(); // Refresh output data
- myRelay.loop(); // Call the relay loop to manage its state
- }
- void updateOutputs()
- {
- digitalWrite(myRelay_RelayModule_Signal_PIN_D2, myRelay_RelayModule_Signal_PIN_D2_rawData);
- digitalWrite(transistorBasePin, myRelay_RelayModule_Signal_PIN_D2_rawData); // Control the transistor
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement