Advertisement
pleasedontcode

Ai rev_01

Oct 20th, 2023
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: Ai
  13.     - Source Code compiled for: Arduino Nano
  14.     - Source Code created on: 2023-10-20 12:53:41
  15.     - Source Code generated by: Upwork
  16.  
  17. ********* Pleasedontcode.com **********/
  18. /****** DEFINITION OF LIBRARIES *****/
  19. #include <Arduino.h>
  20.  
  21. /****** SYSTEM REQUIREMENT 1 *****/
  22. /* I want to create a bot which automatically turns on/off */
  23. /* the light when a person is in the room. So the light */
  24. /* should automatically turn on when a person is present */
  25. /* in the room and turn off when there is no person. */
  26.  
  27. /****** FUNCTION PROTOTYPES *****/
  28. void setup(void);
  29. void loop(void);
  30. void turnOnLight(void);
  31. void turnOffLight(void);
  32. bool isPersonPresent(void);
  33.  
  34. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  35. const uint8_t boot_LEDRGB_Red_PIN_D2 = 2;    // Pin for red LED
  36. const uint8_t boot_LEDRGB_Green_PIN_D3 = 3;  // Pin for green LED
  37. const uint8_t boot_LEDRGB_Blue_PIN_D4 = 4;   // Pin for blue LED
  38.  
  39. void setup(void)
  40. {
  41.   // put your setup code here, to run once:
  42.   pinMode(boot_LEDRGB_Red_PIN_D2, OUTPUT);
  43.   pinMode(boot_LEDRGB_Green_PIN_D3, OUTPUT);
  44.   pinMode(boot_LEDRGB_Blue_PIN_D4, OUTPUT);
  45. }
  46.  
  47. void loop(void)
  48. {
  49.   // put your main code here, to run repeatedly:
  50.   if (isPersonPresent()) {
  51.     turnOnLight();
  52.   } else {
  53.     turnOffLight();
  54.   }
  55. }
  56.  
  57. void turnOnLight(void)
  58. {
  59.   digitalWrite(boot_LEDRGB_Red_PIN_D2, HIGH);
  60.   digitalWrite(boot_LEDRGB_Green_PIN_D3, HIGH);
  61.   digitalWrite(boot_LEDRGB_Blue_PIN_D4, HIGH);
  62. }
  63.  
  64. void turnOffLight(void)
  65. {
  66.   digitalWrite(boot_LEDRGB_Red_PIN_D2, LOW);
  67.   digitalWrite(boot_LEDRGB_Green_PIN_D3, LOW);
  68.   digitalWrite(boot_LEDRGB_Blue_PIN_D4, LOW);
  69. }
  70.  
  71. bool isPersonPresent(void)
  72. {
  73.   // Add your code to check if a person is present in the room
  74.   // Return true if a person is present, false otherwise
  75.   // You can use sensors like PIR motion sensor or ultrasonic sensor to detect presence
  76.   // Example code: return digitalRead(pirSensorPin) == HIGH;
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement