Atmega ICSP header and Digital Pin assignments

Hi all,
I’m using an Arduino Uno as an embedded controller. As usual, the project has grown, now I need additional digital pins to read two Oilmex Mod-TC thermocouple modules (uses the MAX 6675 chip).
The code seems to be assigning the MAX6675 CLK CS and DO to digital pins 4, 5, and 6 respectively.
But I only have 4 unused digital pins.
I’m sure (not positive) that that the ICSP header signals MISO = DO and SCK = CLK so shouldn’t I be able to fan out the ICSP header pins MISO and SCK signals to the two tc modules and then use only two pins for the CS?
If so how do I go about it? I’ve attached the library in case it is a way to assign the pins (I’m just guessing). Finally, I tried just moving the DO wire (assigned to pin 4?) to the MISO, but it don’t work

// this example is public domain. enjoy!
// www.ladyada.net/learn/sensors/thermocouple

#include "max6675.h"

int thermoDO = 4;
int thermoCS = 5;
int thermoCLK = 6;

MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
int vccPin = 3;
int gndPin = 2;
  
void setup() {
  Serial.begin(9600);
  // use Arduino pins 
  pinMode(vccPin, OUTPUT); digitalWrite(vccPin, HIGH);
  pinMode(gndPin, OUTPUT); digitalWrite(gndPin, LOW);
  
  Serial.println("MAX6675 test");
  // wait for MAX chip to stabilize
  delay(500);
}

void loop() {
  // basic readout test, just print the current temp
  
   Serial.print("C = "); 
   Serial.println(thermocouple.readCelsius());
   Serial.print("F = ");
   Serial.println(thermocouple.readFahrenheit());
 
   delay(1000);

MAX6675-library-master.zip (3.94 KB)

Unless you are using SPI in theory those pins are available for anything.

But I only have 4 unused digital pins.

The SPI header on the Uno is directly connected to pins D11/D12/D13 which are the SPI pins. The header does not give you "extra" pins. (The other three are +5V/Gnd/Reset).

It looks like the device only needs 3 pins apart from power and Gnd, so aren't 4 pins plenty?

I hope to accommodate 2 TC modules so it would take 6 pins. My thought was to fan out the MISO and clk to the modules and then use only 2 digital pins for CS (SS). I think CS has to toggle to read the serial. But I don't know how to code that. I'm new to both C and Arduino. Although I have had programming experience a while ago with VB.Net. I'm still learning how to use Libraries and classes. I've been studying these in the Arduino site. I have some spare AI pins so I can use those as output using pinMode
But again, I am not sure how to change the pins assigned in the example (in my original post).
Still trying
Gene

I count only 4 pins (as suggested by Nick Gammon) ...

EDIT:

You may need a pullup resistor on MISO (i.e. 2.2K - 10K).

You may need to insert a small delay after CSn goes high to allow 1 SCK cycle for SOn to go tristate (high impedance) before the next device is enabled.

Hey!
That's right why didn't I see that? Now I'm going to try to code this I'll post the results.
Thanks Lloyd
Gene

dlloyd:
I count only 4 pins (as suggested by Nick Gammon) ...

I was about to say that, but dlloyd's graphic was icing on the cake. :slight_smile:

I have been looking around to find an example of coding more than one instance of a constructor.
(in other words - creating more than one object of a class?) (not even sure how to state the problem!)

So I want to read 2 TCs the example given with the library works great. but when I try to read 2 not so good. this is one try...

// this example is public domain. enjoy!
// www.ladyada.net/learn/sensors/thermocouple

#include "max6675.h"

int thermoDO = 4;
int thermoCS = 5;
int thermo2CS = 6;
int thermoCLK = 7;

MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
MAX6675 thermocouple2(thermoCLK, thermo2CS, thermoDO);
  
void setup() {
  Serial.begin(9600);

  
  Serial.println("MAX6675 test");
  // wait for MAX chip to stabilize
  delay(500);
}

void loop() {
  // basic readout test, just print the current temp
  
   Serial.print("C1 = "); 
   Serial.println(thermocouple.readCelsius());
 Serial.print("C2 = "); 
   Serial.println(thermocouple2.readCelsius());
 
   delay(1000);
}

there is a lot more to my application - this just focuses on 2 TC modules.

I don't get how to use the constructor so I can share 2 of the 3 pins required for each TC modules

Thanks to Nick and dlloyd

Just for closure This Issue was a hardware wiring issue the header has inconsistent configuration (somehow?) My original code ran two modules using only 4 pins. dlloyd's graphic was great
Regards
Gene