Advertisement
pleasedontcode

Digital Interactions rev_01

Jan 21st, 2024
95
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: Digital Interactions
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2024-01-22 04:47:55
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Dancing and walking */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23. /****** DEFINITION OF LIBRARIES *****/
  24. #include <Arduino.h>
  25. #include <EasyButton.h>
  26. #include <Ultrasonic.h>
  27.  
  28. /****** FUNCTION PROTOTYPES *****/
  29. void setup(void);
  30. void loop(void);
  31.  
  32. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  33. const uint8_t pushButton_PIN_D2 = 2;
  34. const uint8_t Camera_HC_SR04_Echo_PIN_D4 = 4;
  35. const uint8_t Camera_HC_SR04_Echo_PIN_D6 = 6;
  36.  
  37. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  38. const uint8_t Camera_HC_SR04_Trigger_PIN_D3 = 3;
  39. const uint8_t Camera_HC_SR04_Trigger_PIN_D5 = 5;
  40.  
  41. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  42. EasyButton pushButton(pushButton_PIN_D2);
  43. Ultrasonic ultrasonic(Camera_HC_SR04_Trigger_PIN_D3, Camera_HC_SR04_Echo_PIN_D4);
  44.  
  45. void setup(void)
  46. {
  47.   // put your setup code here, to run once:
  48.  
  49.   pinMode(pushButton_PIN_D2, INPUT_PULLUP);
  50.   pinMode(Camera_HC_SR04_Echo_PIN_D4, INPUT);
  51.   pinMode(Camera_HC_SR04_Echo_PIN_D6, INPUT);
  52.  
  53.   pinMode(Camera_HC_SR04_Trigger_PIN_D3, OUTPUT);
  54.   pinMode(Camera_HC_SR04_Trigger_PIN_D5, OUTPUT);
  55.  
  56.   pushButton.begin();
  57. }
  58.  
  59. void loop(void)
  60. {
  61.   // put your main code here, to run repeatedly:
  62.  
  63.   pushButton.read();
  64.  
  65.   if(pushButton.isPressed()){
  66.     // Perform dancing and walking actions
  67.   }
  68.  
  69.   int distance = ultrasonic.read();
  70.  
  71.   // Use distance value for dancing and walking
  72.  
  73.   delay(100);
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement