Site icon Renzo Mischianti

‘class PCF8574’ has no member named ‘analogWrite’ problem

Hello everybody, I am trying to connect (communicate) NodeMCU and PCF8574 Extender. No matter what I change in my code, always getting same error: 'class PCF8574' has no member named 'analogWrite' Last part (analogWrite) change when I change code order, but problem with a class is constant. Here is complete code:


// Mower
#define BLYNK_PRINT Serial
#include 
#include 
#include "PCF8574.h"

PCF8574 pcf8574(0x20);

//#define motor1IN1 D2 //4
#define motor1IN1 P1

#define motor1IN2 D5 //14
#define motor2IN1 D6 //12
#define motor2IN2 D8 //15
#define EN1 D0 //16

//#define EN2 D1 //5
#define EN2 P0

//#define ENL D11 //9
//#define ENR D12 //10
//#define mowerPWML D3 //0
//#define mowerPWMR D4 //2

char auth[] = "token"; //Blynk Authentication Token
char ssid[] = "wifi name"; //WIFI Name
char pass[] = "wifi pass"; //WIFI Password

char command[8];
int pinValue;
int power;
int mowerPower;

void setup() {
	Serial.begin(9600);
	Blynk.begin(auth, ssid, pass);
	analogWriteFreq(16000);
	pinMode(EN1, OUTPUT);
	pcf8574.pinMode(EN2, OUTPUT);
	pcf8574.pinMode(motor1IN1, OUTPUT);
	pinMode(motor1IN2, OUTPUT);
	pinMode(motor2IN1, OUTPUT);
	pinMode(motor2IN2, OUTPUT);
// pinMode(ENL, OUTPUT);
// pinMode(ENR, OUTPUT);
// pinMode(mowerPWML, OUTPUT);
// pinMode(mowerPWMR, OUTPUT);
	pcf8574.begin();
}

void moveControl(char command[], int value, int power = 0) {
	if (value != 0) {
		if (strcmp(command, "forward") == 0) {
			digitalWrite(EN1, HIGH);
			pcf8574.digitalWrite(EN2, HIGH);
			pcf8574.digitalWrite(motor1IN1, LOW);
			analogWrite(motor1IN2, power);
			digitalWrite(motor2IN1, LOW);
			analogWrite(motor2IN2, power);
		} else if (strcmp(command, "back") == 0) {
			digitalWrite(EN1, HIGH);
			pcf8574.digitalWrite(EN2, HIGH);
			pcf8574.analogWrite(motor1IN1, power);
			digitalWrite(motor1IN2, LOW);
			analogWrite(motor2IN1, power);
			digitalWrite(motor2IN2, LOW);
		} else if (strcmp(command, "left") == 0) {
			digitalWrite(EN1, HIGH);
			pcf8574.digitalWrite(EN2, HIGH);
			pcf8574.analogWrite(motor1IN1, power);
			digitalWrite(motor1IN2, LOW);
			digitalWrite(motor2IN1, LOW);
			analogWrite(motor2IN2, power);
		} else if (strcmp(command, "right") == 0) {
			digitalWrite(EN1, HIGH);
			pcf8574.digitalWrite(EN2, HIGH);
			pcf8574.digitalWrite(motor1IN1, LOW);
			analogWrite(motor1IN2, power);
			analogWrite(motor2IN1, power);
			digitalWrite(motor2IN2, LOW);
		} else {
			digitalWrite(EN1, LOW);
			pcf8574.digitalWrite(EN2, LOW);
		}
	} else {
		digitalWrite(EN1, LOW);
		pcf8574.digitalWrite(EN2, LOW);
	}
}

void controlMower(int mowerPower) {
// if(mowerPower != 0) {
// digitalWrite(ENL, HIGH);
// digitalWrite(ENR, HIGH);
// digitalWrite(mowerPWML, LOW);
// analogWrite(mowerPWMR, mowerPower);
// }
// else {
// digitalWrite(ENL, LOW);
// digitalWrite(ENR, LOW);
// }
}

void loop() {
	Blynk.run();
}

BLYNK_WRITE(V2)
{
	int pinValue = param.asInt();
	char command[] = "forward";
	moveControl(command, pinValue, power);
}
BLYNK_WRITE(V3)
{
	int pinValue = param.asInt();
	char command[] = "back";
	moveControl(command, pinValue, power);
}
BLYNK_WRITE(V4)
{
	int pinValue = param.asInt();
	char command[] = "left";
	moveControl(command, pinValue, power);
}
BLYNK_WRITE(V5)
{
	int pinValue = param.asInt();
	char command[] = "right";
	moveControl(command, pinValue, power);
}
BLYNK_WRITE(V6)
{
	power = param.asInt();
}
BLYNK_WRITE(V7)
{
	mowerPower = param.asInt();
	controlMower (mowerPower);
}




Thanks in advance, I am here for any further info.
Exit mobile version