#include <Adafruit_NeoPixel.h>
// Which pin on the Arduino is connected to the NeoPixels?
#define PIN 5 // On Trinket or Gemma, suggest changing this to 1
// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS 16 // Popular NeoPixel ring size
// When setting up the NeoPixel library, we tell it how many pixels,
// and which pin to use to send signals. Note that for older NeoPixel
// strips you might need to change the third parameter -- see the
// strandtest example for more information on possible values.
Adafruit_NeoPixel strip(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
#define M_ENA 13
#define M_DIR 12
#define M_STEP 14
int dir = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
strip.begin();
strip.clear();
strip.show();
pinMode(M_ENA,OUTPUT);
pinMode(M_DIR,OUTPUT);
pinMode(M_STEP,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
// The first NeoPixel in a strand is #0, second is 1, all the way up
// to the count of pixels minus one.
// for(int i=0; i<NUMPIXELS; i++) { // For each pixel...
// // pixels.Color() takes RGB values, from 0,0,0 up to 255,255,255
// // Here we're using a moderately bright green color:
// pixels.setPixelColor(i, pixels.Color(0, 150, 0));
// pixels.show(); // Send the updated pixel colors to the hardware.
// delay(500); // Pause before next pass through loop
// }
Serial.println("Hello, ESP32!");
rainbowCycle(10);
}
// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if(WheelPos < 85) {
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
}
if(WheelPos < 170) {
WheelPos -= 85;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
WheelPos -= 170;
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}
// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
uint16_t i, j;
dir = !dir;
for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
for(i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
}
strip.show();
delay(wait);
mstep(dir);
}
}
void mstep(int dir) {
digitalWrite(M_ENA,LOW);
digitalWrite(M_DIR,dir==1? HIGH:LOW);
digitalWrite(M_STEP,HIGH);
digitalWrite(M_STEP,LOW);
}
esp:VIN
esp:GND.2
esp:D13
esp:D12
esp:D14
esp:D27
esp:D26
esp:D25
esp:D33
esp:D32
esp:D35
esp:D34
esp:VN
esp:VP
esp:EN
esp:3V3
esp:GND.1
esp:D15
esp:D2
esp:D4
esp:RX2
esp:TX2
esp:D5
esp:D18
esp:D19
esp:D21
esp:RX0
esp:TX0
esp:D22
esp:D23
ring1:GND
ring1:VCC
ring1:DIN
ring1:DOUT
drv1:ENABLE
drv1:MS1
drv1:MS2
drv1:MS3
drv1:RESET
drv1:SLEEP
drv1:STEP
drv1:DIR
drv1:GND.1
drv1:VDD
drv1:1B
drv1:1A
drv1:2A
drv1:2B
drv1:GND.2
drv1:VMOT
stepper1:A-
stepper1:A+
stepper1:B+
stepper1:B-