Compare commits

..

No commits in common. "45f76500f9bb65afbfaba111cb727529a0fc438f" and "51e15a6e58951bcadbefef12b8f2622639e293dc" have entirely different histories.

3 changed files with 1 additions and 129 deletions

View File

@ -1,4 +1,5 @@
#include "ContactPrinter.h";
void setup () {}
void loop () {}

View File

@ -1,73 +0,0 @@
//https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/master/Projects/ESP32/ESP32_DC_Motor.ino
/*********
Rui Santos
Complete project details at http://randomnerdtutorials.com
*********/
// Motor A
int motor1Pin1 = 27;
int motor1Pin2 = 26;
int enable1Pin = 14;
// Setting PWM properties
const int freq = 30000;
const int pwmChannel = 0;
const int resolution = 8;
int dutyCycle = 200;
void setup() {
// sets the pins as outputs:
pinMode(motor1Pin1, OUTPUT);
pinMode(motor1Pin2, OUTPUT);
pinMode(enable1Pin, OUTPUT);
// configure LED PWM functionalitites
ledcSetup(pwmChannel, freq, resolution);
// attach the channel to the GPIO to be controlled
ledcAttachPin(enable1Pin, pwmChannel);
Serial.begin(115200);
// testing
Serial.print("Testing DC Motor...");
}
void loop() {
// Move the DC motor forward at maximum speed
Serial.println("Moving Forward");
digitalWrite(motor1Pin1, LOW);
digitalWrite(motor1Pin2, HIGH);
delay(2000);
// Stop the DC motor
Serial.println("Motor stopped");
digitalWrite(motor1Pin1, LOW);
digitalWrite(motor1Pin2, LOW);
delay(1000);
// Move DC motor backwards at maximum speed
Serial.println("Moving Backwards");
digitalWrite(motor1Pin1, HIGH);
digitalWrite(motor1Pin2, LOW);
delay(2000);
// Stop the DC motor
Serial.println("Motor stopped");
digitalWrite(motor1Pin1, LOW);
digitalWrite(motor1Pin2, LOW);
delay(1000);
// Move DC motor forward with increasing speed
digitalWrite(motor1Pin1, HIGH);
digitalWrite(motor1Pin2, LOW);
while (dutyCycle <= 255){
ledcWrite(pwmChannel, dutyCycle);
Serial.print("Forward with duty cycle: ");
Serial.println(dutyCycle);
dutyCycle = dutyCycle + 5;
delay(500);
}
dutyCycle = 200;
}

View File

@ -1,56 +0,0 @@
/***
*
* 100RPM 12VDC Worm Gear Motor w/ encoder
* SKU - JGY-370
* DC12V100RPM - SKU-GS00127-05
*
* Gear ratio: 40:1
*
* RedMotor power + (exchange can control rotating and reversing)
* BlackCoding power- negative (3.3-5V) polarity cannot be wrong
* YellowSignal feedback
* GreenSignal feedback
* BlueCoding power + positive(3.3-5V)polarity cannot be wrong
* WhiteMotor power - (exchange can control rotating and
*
***/
#include <util/atomic.h> // For the ATOMIC_BLOCK macro
#define ENCA 2 // YELLOW
#define ENCB 3 // WHITE
#define MOTORA 10
#define MOTORB 11
volatile int posi = 0; // specify posi as volatile
void setup() {
Serial.begin(9600);
pinMode(ENCA, INPUT);
pinMode(ENCB, INPUT);
attachInterrupt(digitalPinToInterrupt(ENCA), readEncoder,RISING);
}
void loop() {
// Read the position in an atomic block to avoid a potential
// misread if the interrupt coincides with this code running
// see: https://www.arduino.cc/reference/en/language/variables/variable-scope-qualifiers/volatile/
int pos = 0;
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
pos = posi;
}
Serial.println(pos);
}
void readEncoder(){
int b = digitalRead(ENCB);
if(b > 0){
posi++;
}
else{
posi--;
}
}