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: MySampleProject
- - Source Code compiled for: Arduino Uno
- - Source Code created on: 2023-10-23 01:56:35
- - Source Code generated by: Jhon
- ********* Pleasedontcode.com **********/
- /****** DEFINITION OF LIBRARIES *****/
- #include <Arduino.h>
- /****** SYSTEM REQUIREMENT 1 *****/
- /* Turn On and off LED using Relay Module */
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- void turnOnLED(void);
- void turnOffLED(void);
- /***** DEFINITION OF ANALOG INPUT PINS *****/
- const uint8_t Led_PIN_A0 = A0;
- const uint8_t Relay_PIN = 2;
- void setup(void)
- {
- // put your setup code here, to run once:
- pinMode(Led_PIN_A0, INPUT);
- pinMode(Relay_PIN, OUTPUT);
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- int sensorValue = analogRead(Led_PIN_A0);
- if (sensorValue > 500) {
- turnOnLED();
- } else {
- turnOffLED();
- }
- }
- void turnOnLED(void)
- {
- digitalWrite(Relay_PIN, HIGH);
- }
- void turnOffLED(void)
- {
- digitalWrite(Relay_PIN, LOW);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement