Arduino_MCP3x6x_Library icon indicating copy to clipboard operation
Arduino_MCP3x6x_Library copied to clipboard

mcp 3462 with Arduino Zero definition-question not issue!

Open morghanhartmann opened this issue 2 months ago • 6 comments

Not really an issue, more of a question so apologies...

I'm attempting to read from channel 0 in mux mode but having issues even entering the setup and loop sections. I'm assuming it's something to do with my mcp definition since I've tested the println function and it seems to work. I'm using an Arduino Zero which is SAMD21. I added a lot of print statements to try and figure out where the program is/isn't making it to. If I go by these statements, the setup and loop aren't being read. Assuming that I've done something really dumb since I'm quite new to this.

MCP3462 mcp(10); //the problem?

void setup() { Serial.begin(115200); while (!Serial) ; Serial.println(FILE); if (!mcp.begin()) { Serial.println("failed to initialize MCP"); while (1) ; } }

// the loop routine runs over and over again forever: void loop() { // read the input on default analog channel: int32_t adcdata = mcp.analogRead(MCP_CH0);

// Convert the analog reading double voltage = adcdata * mcp.getReference() / mcp.getMaxValue(); Serial.println("converted voltage");

// print out the value you read: Serial.println("voltage: "); Serial.print(voltage, 10); Serial.println("printed voltage");

// pause program for one second delay(1000); }

morghanhartmann avatar Apr 18 '24 13:04 morghanhartmann