pp
This commit is contained in:
@@ -7,20 +7,16 @@
|
||||
|
||||
OpenTB6612FNG::OpenTB6612FNG(int TP) {
|
||||
|
||||
pinMode(PWMA, OUTPUT);
|
||||
pinMode(AIN1, OUTPUT);
|
||||
pinMode(AIN2, OUTPUT);
|
||||
pinMode(STBY, OUTPUT);
|
||||
pinMode(PWMA, OUTPUT);
|
||||
pinMode(BIN1, OUTPUT);
|
||||
pinMode(BIN2, OUTPUT);
|
||||
pinMode(PWMB, OUTPUT);
|
||||
ledcSetup(ledChannel, freq, resolution);
|
||||
ledcSetup(ledChannel2, freq, resolution);
|
||||
|
||||
// attach the channel to the GPIO to be controlled
|
||||
ledcAttachPin(PWMA, ledChannel);
|
||||
ledcAttachPin(PWMB, ledChannel2);
|
||||
|
||||
analogWriteFreq(20000);
|
||||
analogWriteRange(255);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void OpenTB6612FNG::MotorIz(int value) {
|
||||
@@ -39,7 +35,7 @@ void OpenTB6612FNG::MotorIz(int value) {
|
||||
*/
|
||||
// Setea Velocidad
|
||||
|
||||
ledcWrite(ledChannel, value);
|
||||
analogWrite(MOTOR_IZQ, value);
|
||||
}
|
||||
|
||||
void OpenTB6612FNG::MotorDe(int value) {
|
||||
@@ -58,15 +54,12 @@ void OpenTB6612FNG::MotorDe(int value) {
|
||||
*/
|
||||
// Setea Velocidad
|
||||
|
||||
ledcWrite(ledChannel2, value);
|
||||
analogWrite(MOTOR_DER, value);
|
||||
}
|
||||
|
||||
void OpenTB6612FNG::Motores(int left, int righ) {
|
||||
MotorIz(left);
|
||||
MotorDe(righ);
|
||||
digitalWrite(STBY, LOW);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void OpenTB6612FNG::Forward()
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
#ifndef OpenTB6612FNG_h
|
||||
#define OpenTB6612FNG_h
|
||||
#include <Arduino.h>
|
||||
#define PWMA 36
|
||||
#define AIN1 39
|
||||
#define AIN2 34
|
||||
#define STBY 35
|
||||
#define BIN1 32
|
||||
#define BIN2 33
|
||||
#define PWMB 25
|
||||
|
||||
const int freq = 5000;
|
||||
const int ledChannel = 0;
|
||||
const int ledChannel2 = 1;
|
||||
const int resolution = 8;
|
||||
#include "Arduino.h"
|
||||
#define PWMA D1
|
||||
#define AIN1 D2
|
||||
#define AIN2 D3
|
||||
#define BIN1 D4
|
||||
#define BIN2 D5
|
||||
#define PWMB D6
|
||||
#define MOTOR_IZQ PWMB
|
||||
#define MOTOR_DER PWMA
|
||||
|
||||
|
||||
class OpenTB6612FNG{
|
||||
|
||||
Reference in New Issue
Block a user