Advertisement
pleasedontcode

**Input Monitor** rev_01

Feb 15th, 2025
67
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: **Input Monitor**
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2025-02-15 20:53:00
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* The system shall initialize connected components */
  21.     /* and execute a loop that monitors input signals, */
  22.     /* triggering specific actions based on user */
  23.     /* interactions with the hardware. */
  24. /****** END SYSTEM REQUIREMENTS *****/
  25.  
  26. /* START CODE */
  27.  
  28. /****** DEFINITION OF LIBRARIES *****/
  29. #include <Keyboard.h> // Added to support Keyboard functionality
  30.  
  31. /****** FUNCTION PROTOTYPES *****/
  32. void setup(void);
  33. void loop(void);
  34. void updateOutputs(void); // Function prototype for updating outputs
  35.  
  36. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  37. const uint8_t myLED_LED_PIN_D2 = 2; // LED pin
  38. const int dah = 3;                  // Declaring paddle input pin for dah
  39. const int dit = 4;                  // Declaring paddle input pin for dit (Updated to avoid conflict)
  40.  
  41. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  42. /***** used to store raw data *****/
  43. bool myLED_LED_PIN_D2_rawData = 0;
  44.  
  45. /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
  46. /***** used to store data after characteristic curve transformation *****/
  47. float myLED_LED_PIN_D2_phyData = 0.0;
  48.  
  49. int previousdahState = HIGH;
  50. int previousditState = HIGH;
  51.  
  52. void setup(void)
  53. {
  54.     // Initialize connected components
  55.     pinMode(myLED_LED_PIN_D2, OUTPUT);
  56.    
  57.     // Declare the inputs as input_pullup
  58.     pinMode(dah, INPUT_PULLUP);  
  59.     pinMode(dit, INPUT_PULLUP);  
  60.     Keyboard.begin(); // Initialize Keyboard library
  61. }
  62.  
  63. void loop(void)
  64. {
  65.     // Execute a loop that monitors input signals
  66.     updateOutputs(); // Refresh output data
  67.  
  68.     // Checking the state of the inputs
  69.     int dahState = digitalRead(dah);
  70.     int ditState = digitalRead(dit);
  71.  
  72.     // Trigger specific actions based on user interactions
  73.     // Replaces left paddle input with dit using "[" as defined by VBand website
  74.     if (dahState == LOW && previousdahState == HIGH) {
  75.         // and it's currently pressed:
  76.         Keyboard.press(93);
  77.         delay(50);
  78.     }
  79.     if (dahState == HIGH && previousdahState == LOW) {
  80.         // and it's currently released:
  81.         Keyboard.release(93);
  82.         delay(50);
  83.     }
  84.  
  85.     // Replaces right paddle input with dah using "]" as defined by VBand website
  86.     if (ditState == LOW && previousditState == HIGH) {
  87.         // and it's currently pressed:
  88.         Keyboard.press(91);
  89.         delay(50);
  90.     }
  91.     if (ditState == HIGH && previousditState == LOW) {
  92.         // and it's currently released:
  93.         Keyboard.release(91);
  94.         delay(50);
  95.     }
  96.  
  97.     // Update previous states
  98.     previousdahState = dahState;
  99.     previousditState = ditState;
  100. }
  101.  
  102. void updateOutputs()
  103. {
  104.     digitalWrite(myLED_LED_PIN_D2, myLED_LED_PIN_D2_rawData);
  105. }
  106.  
  107. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement