Closed abcdaaaaaaaaa closed 9 months ago
I was a little busy and didn't have much time to reply. This pull request aims to enable the pixy2 camera to work on esp32 models as well. Providing electronics alone is not enough: like this:
------------------------------------------------------ PIXY2 ELECTRONICS ------------------------------------------------------
purple -> 5V
white -> GND
grey -> 23
yellow -> 19
green -> 18
blue -> 5
purple top left (PU) grey middle left (GY) white bottom left (WH)
yellow top right (YL)
green middle right (GR)
blue bottom right (BL)
ESP32 ^ |
---|
(PU)(YL)<----- (GY)(GR) | (WH)(BL) |
---|---|
Pixy2 | |
(1)(2) |
(3)(4)-------- (5)(6) (7)(8) (9)(10)
(1) -> MISO PIN->(19) (2) -> 5V PIN->(5V) (3) -> SCK (CLK) PIN->(18) (4) -> MOSI PIN->(23) (5) -> (NOT IMPORTANT) I2C SCL (6) -> GND PIN->(GND) (7) -> SPI SS PIN-> (5) (8) -> (NOT IMPORTANT) Analog Out (9) -> (NOT IMPORTANT) SDA (10) ->(NOT IMPORTANT) Vin (6-10V)
PAN TILT
pwm0(pan) pwm1 (tilt)
Vout Vout
GND GND
------------------------------------------------------ PIXY2 ELECTRONICS ------------------------------------------------------
I tried other libraries with TX/RX, SCL/SDA or just Pixy2.h and Pixy2_SS.h but the result does not change, some changes are required in the Pixy2_SS.cpp file to be successful:
------------------------------------------------------ CHANGING CODE ------------------------------------------------------
//for Pixy2SPI_SS.h
SPI.beginTransaction(SPISettings(PIXY_SPI_CLOCKRATE, MSBFIRST, SPI_MODE3)); //for ZumoMotors.cpp
/ pinMode(PWM_L, OUTPUT); pinMode(PWM_R, OUTPUT); / pinMode(DIR_L, OUTPUT); pinMode(DIR_R, OUTPUT);
ledcSetup(LEDC_CH_L,20000,10); ledcSetup(LEDC_CH_R,20000,10);
analogWrite(PWM_L, speed * 64 / 25); // default to using analogWrite, mapping 400 to 255 ------------------------------------------------------ CHANGING CODE ------------------------------------------------------
This means a new library. I transferred the Pixy2_SS.h changes to the PixyEsp32.h file and the changes in the ZumoMotors.cpp file to the ZumoMotorsEsp32.cpp file. If there is an error in my pull request, it is due to my haste. I tried to change it as stated above. This pull request is taken from this video. I personally did not create the video and the original code, but I tested it and it really works. After testing, I created a pull request so everyone can access it. I put the changes in the video into a .h file so that future users can access it, and after changing the names and adding the necessary examples to the examples file, I sent my pull request.
------------------------------------------------------ REFERENCES ------------------------------------------------------
Video link and bibliography: https://www.youtube.com/watch?v=38NbnyXSt3U&t=57s
What are you trying to accomplish here? I've also noticed this library will not compile for non-AVR chips, such as ESP32, but a simple workaround for that issue is to delete the ZumoBuzzer files that import the avr modules. From there, I was able to use the Pixy.h module on the ESP32 just like an Arduino. So what does this change accomplish?