Advertisement
pleasedontcode

greenrobot_old rev_01

Nov 4th, 2023
88
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: greenrobot_old
  13.     - Source Code compiled for: Arduino Nano
  14.     - Source Code created on: 2023-11-05 02:36:36
  15.     - Source Code generated by: Abdul
  16.  
  17. ********* Pleasedontcode.com **********/
  18. /****** DEFINITION OF LIBRARIES *****/
  19. #include <Arduino.h>
  20. #include <EasyButton.h>
  21. #include <QTRSensors.h>
  22.  
  23. /****** SYSTEM REQUIREMENT 1 *****/
  24. /* Motors ON when button PRESSED */
  25. /****** SYSTEM REQUIREMENT 2 *****/
  26. /* Motors ON when button PRESSED */
  27.  
  28. /****** FUNCTION PROTOTYPES *****/
  29. void setup(void);
  30. void loop(void);
  31.  
  32. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  33. const uint8_t ON_OFF_PushButton_PIN_D2 = 2;
  34.  
  35. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  36. EasyButton button(ON_OFF_PushButton_PIN_D2);
  37. QTRSensors qtr;
  38.  
  39. void setup(void)
  40. {
  41.   // put your setup code here, to run once:
  42.   pinMode(ON_OFF_PushButton_PIN_D2, INPUT_PULLUP);
  43.  
  44.   button.begin();
  45.  
  46.   // Initialize QTRSensors
  47.   qtr.setTypeRC();
  48.   qtr.setSensorPins((const uint8_t[]){A0, A1, A2, A3, A4, A5}, 6);
  49.   qtr.setEmitterPin(2);
  50.  
  51.   delay(500);
  52.  
  53.   for (uint16_t i = 0; i < 400; i++)
  54.   {
  55.     qtr.calibrate();
  56.   }
  57.  
  58.   Serial.begin(9600);
  59. }
  60.  
  61. void loop(void)
  62. {
  63.   // put your main code here, to run repeatedly:
  64.   button.read();
  65.  
  66.   uint16_t sensorValues[6];
  67.   qtr.read(sensorValues);
  68.  
  69.   for (uint8_t i = 0; i < 6; i++)
  70.   {
  71.     Serial.print(sensorValues[i]);
  72.     Serial.print('\t');
  73.   }
  74.   Serial.println();
  75.  
  76.   delay(250);
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement