Advertisement
pleasedontcode

Nimo rev_04

Nov 12th, 2023
93
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: Nimo
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2023-11-13 03:08:37
  15.     - Source Code generated by: personal
  16.  
  17. ********* Pleasedontcode.com **********/
  18.  
  19. /********* User code review feedback **********
  20. #### Feedback 1 ####
  21. - Command a and b  not in the code
  22. ********* User code review feedback **********/
  23.  
  24. /****** DEFINITION OF LIBRARIES *****/
  25. #include <Arduino.h>
  26. #include <Servo.h>
  27.  
  28. /****** SYSTEM REQUIREMENT 1 *****/
  29. /* When 'a' command is received, the servo turns to 10 degrees */
  30. /* and when 'b' command is received, the servo returns to its */
  31. /* original position */
  32.  
  33. /****** FUNCTION PROTOTYPES *****/
  34. void setup(void);
  35. void loop(void);
  36.  
  37. /***** DEFINITION OF PWM OUTPUT PINS *****/
  38. const uint8_t V3003_Servomotor_PWMSignal_PIN_D3 = 3;
  39.  
  40. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  41. Servo myservo; // Instantiate the Servo class object
  42.  
  43. void setup(void)
  44. {
  45.   // put your setup code here, to run once:
  46.   myservo.attach(V3003_Servomotor_PWMSignal_PIN_D3); // Attach the servo to the PWM pin
  47. }
  48.  
  49. void loop(void)
  50. {
  51.   // put your main code here, to run repeatedly:
  52.   if (Serial.available() > 0) {
  53.     char command = Serial.read();
  54.     if (command == 'a') {
  55.       myservo.write(10); // Turn the servo to 10 degrees
  56.     } else if (command == 'b') {
  57.       myservo.write(90); // Return the servo to its original position (90 degrees)
  58.     }
  59.   }
  60.   delay(1000); // Wait for 1 second
  61. }
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement