Issues writing project on visual studio code and platformio

I have copied a working sketch across from arduino ide to visual studio code and it is throwing an error I can't seem to get around.

Using the Adafruit_MCP4728 library I stored the Channels as a const char array to be able to iterate through them in a for loop.

const char dacCh[4] {MCP4728_CHANNEL_A, MCP4728_CHANNEL_B, MCP4728_CHANNEL_C, MCP4728_CHANNEL_D};

This would be called here

void updateDAC() {
  for (int i = 0; i < windowNum; i++) {
    mcp.setChannelValue(dacCh[i], windows [i].dac, MCP4728_VREF_INTERNAL, MCP4728_GAIN_2X);

  }
}

in which windows[i].dac was an int variable taken from a struct.

However, I now get the error message:

argument of type "char" is incompatible with parameter of type "MCP4728_channel_t"

I have tried changing it to string but this doesn't work either?

I think MCP4728_channel_t is an enum. Try changing not to string but to MCP4728_channel_t

Awesome thank you. That worked, now it is throwing up one more error though:

[{
	"resource": "/Users/dave/Documents/PlatformIO/Projects/Power Supply/Users/dave/.platformio/packages/framework-arduino-avr/cores/arduino/Arduino.h",
	"owner": "cpp",
	"severity": 8,
	"message": "cannot convert 'volatile uint8_t* {aka volatile unsigned char*}' to 'RwReg* {aka volatile long unsigned int*}' in assignment",
	"startLineNumber": 182,
	"startColumn": 97,
	"endLineNumber": 182,
	"endColumn": 97
}]

the line it is referring to is this one

#define portOutputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_output_PGM + (P))) )

Was a problem with the configuration

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.