Advertisement
pleasedontcode

"Continuous Mapping" rev_10

Jun 21st, 2024
485
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: "Continuous Mapping"
  13.     - Source Code NOT compiled for: Arduino Mega
  14.     - Source Code created on: 2024-06-21 08:13:07
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Convert potentiometer signal to ppm */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23. /****** DEFINITION OF LIBRARIES *****/
  24. #include <PPMEncoder.h>  //http://github.com/schinken/PPMEncoder
  25.  
  26. /****** FUNCTION PROTOTYPES *****/
  27. void setup(void);
  28. void loop(void);
  29.  
  30. /***** DEFINITION OF ANALOG INPUT PINS *****/
  31. const uint8_t steering_Potentiometer_Vout_PIN_A0 = A0;
  32.  
  33. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  34. PPMEncoder ppmEncoder;  // Create an instance of PPMEncoder
  35.  
  36. /****** DEFINITION OF CONSTANTS *****/
  37. #define OUTPUT_PIN 10  // Define the output pin for PPM signal
  38.  
  39. void setup(void)
  40. {
  41.   // put your setup code here, to run once:
  42.  
  43.   pinMode(steering_Potentiometer_Vout_PIN_A0, INPUT);  // Set the potentiometer pin as input
  44.   ppmEncoder.begin(OUTPUT_PIN);  // Initialize the PPM encoder on the defined output pin
  45. }
  46.  
  47. void loop(void)
  48. {
  49.   // put your main code here, to run repeatedly:
  50.  
  51.   int potValue = analogRead(steering_Potentiometer_Vout_PIN_A0);  // Read the potentiometer value
  52.   int ppmValue = map(potValue, 0, 1023, PPMEncoder::MIN, PPMEncoder::MAX);  // Map the potentiometer value to PPM range
  53.  
  54.   ppmEncoder.setChannel(0, ppmValue);  // Set the PPM value for channel 0
  55. }
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement