Advertisement
Guest User

Untitled

a guest
Oct 13th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. #include <Wire.h>
  2. #define ADDS 0x43
  3.  
  4. #define PIN1 0x00
  5. #define PIN2 0x01
  6. #define PIN3 0x02
  7. #define PIN4 0x03
  8. #define PIN5 0x04
  9. #define PIN6 0x05
  10. #define PIN7 0x06
  11. #define PIN8 0x07
  12. #define PIN9 0x08
  13. #define PIN10 0x09
  14.  
  15. #define Servo1 0x30
  16. #define Servo2 0x31
  17. #define Servo3 0x32
  18. #define Servo4 0x33
  19. #define Servo5 0x34
  20. #define Servo6 0x35
  21. #define Servo7 0x36
  22. #define Servo8 0x37
  23.  
  24. uint16_t Readadc(uint8_t pin) {
  25. Wire1.beginTransmission(ADDS);
  26. Wire1.write(0x10 | pin);
  27. Wire1.endTransmission();
  28. Wire1.requestFrom(ADDS, 2);
  29. uint8_t h;
  30. uint8_t l;
  31. while (Wire1.available()) {
  32. h = Wire1.read();
  33. l = Wire1.read();
  34.  
  35. }
  36. return word(h, l);
  37. }
  38.  
  39. void ServowriteM(uint8_t pin, uint16_t M) {
  40. if(M<800){
  41. M =800;
  42. }
  43. if(M>2300){
  44. M =2300;
  45. }
  46. Wire1.beginTransmission(ADDS);
  47. Wire1.write(pin);
  48. Wire1.write(highByte(M));
  49. Wire1.write(lowByte(M));
  50. Wire1.endTransmission();
  51. }
  52. void setup() {
  53. Wire1.begin(4,5);
  54. Wire1.setClock(400000);
  55. Serial.begin(115200);
  56. delay(1000);
  57. //setuppin(PIN1,Amode);
  58.  
  59. }
  60.  
  61. unsigned long previousMillis = 0;
  62. void loop() {
  63. ServowriteM(Servo1,1000);
  64. delay(1000);
  65. ServowriteM(Servo1,2000);
  66. delay(1000);
  67. // unsigned long currentMillis = millis();
  68. //
  69. // if (currentMillis - previousMillis >= 1000) {
  70. // // save the last time you blinked the LED
  71. // previousMillis = currentMillis;
  72. // //uint16_t x = Readadc(PIN1);
  73. //
  74. // //Serial.println(x);
  75. // }
  76.  
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement