Quantcast
Channel: Sensors - Arduino Forum
Viewing all articles
Browse latest Browse all 1068

Common CS pins on Arduino uno for SPI devices

$
0
0

I am trying build a temperature monitor using multiple MAX6675 thermocouple to digital converters. In my code shown below, I sequentially read out each thermocouple. I realise that according to SPI protocols each slave device has to get a dedicated CS (chip select) pin. However, would be fine to have a common chip select pin but a unique serial out (SO) for each device? Would it matter or lead to any errors with an arduino UNO

#include <LiquidCrystal.h>

#include <LiquidCrystal_I2C.h>
#include "max6675.h"

int csPin = 2;
int clkPin = 3;

int soPin1 = 4;
int soPin2 = 5;
int soPin3 = 6;
int soPin4 = 7;
int soPin5 = 8;
int soPin6 = 9;


MAX6675 thermo1(clkPin, csPin, soPin1);
MAX6675 thermo2(clkPin, csPin, soPin2);
MAX6675 thermo3(clkPin, csPin, soPin3);
MAX6675 thermo4(clkPin, csPin, soPin4);
MAX6675 thermo5(clkPin, csPin, soPin5);
MAX6675 thermo6(clkPin, csPin, soPin6);


// set LCD address, number of columns and rows
// if you don't know your display address, run an I2C scanner sketch
LiquidCrystal_I2C lcd(0x27, 16, 2);  

void setup(){
  // initialize LCD
  lcd.init();
  // turn on LCD backlight                      
  lcd.backlight();
 
  //Serial.println("MAX6675 test");
  // wait for MAX chip to stabilize
  delay(500);
}
void loop(){
// set cursor to first column, first row
  lcd.clear();
  // go to line #1
  lcd.setCursor(0,0);
  lcd.print('A');
  lcd.print(thermo1.readCelsius(),1);
  lcd.setCursor(0,1);
  lcd.print('B');
  lcd.print(thermo2.readCelsius(),1);
  lcd.setCursor(6,0);
  lcd.print('C');
  lcd.print(thermo3.readCelsius(),1);
  lcd.setCursor(6 ,6);
  lcd.print('D');
  lcd.print(thermo4.readCelsius(),1);
  lcd.setCursor(12 ,0);
  lcd.print('E');
  lcd.print(thermo5.readCelsius(),1);
  lcd.setCursor(12 ,12);
  lcd.print('F');
  lcd.print(thermo6.readCelsius(),1);
  delay(1000);
  // clears the display to print new message
}

4 posts - 4 participants

Read full topic


Viewing all articles
Browse latest Browse all 1068

Trending Articles