Advertisement
pleasedontcode

Analog Sensor Output rev_01

Feb 11th, 2024
48
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: Analog Sensor Output
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2024-02-11 13:56:47
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Rad and Print Values of the sensor at A0 and A1 */
  21.     /* pins. */
  22. /****** END SYSTEM REQUIREMENTS *****/
  23.  
  24. /****** DEFINITION OF LIBRARIES *****/
  25. #include <Arduino.h>
  26.  
  27. /****** FUNCTION PROTOTYPES *****/
  28. void setup(void);
  29. void loop(void);
  30.  
  31. /***** DEFINITION OF ANALOG INPUT PINS *****/
  32. const uint8_t CurrentSensor_PIN_A0 = A0;
  33. const uint8_t LDR_PIN_A1 = A1;
  34.  
  35. void setup(void)
  36. {
  37.   // Set the serial baud rate to 9600
  38.   Serial.begin(9600);
  39.  
  40.   // Set the pin modes for the analog input pins
  41.   pinMode(CurrentSensor_PIN_A0, INPUT);
  42.   pinMode(LDR_PIN_A1, INPUT);
  43. }
  44.  
  45. void loop(void)
  46. {
  47.   // Read and print the values of the sensor at A0 and A1 pins
  48.   int currentSensorValue = analogRead(CurrentSensor_PIN_A0);
  49.   int ldrValue = analogRead(LDR_PIN_A1);
  50.  
  51.   Serial.print("Current Sensor Value at A0: ");
  52.   Serial.println(currentSensorValue);
  53.  
  54.   Serial.print("LDR Value at A1: ");
  55.   Serial.println(ldrValue);
  56.  
  57.   delay(1000); // Delay for 1 second
  58. }
  59.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement