Changes between Version 8 and Version 9 of MAX6675Sketch


Ignore:
Timestamp:
May 16, 2012 4:24:56 PM (7 years ago)
Author:
maris
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • MAX6675Sketch

    v8 v9  
    4545#define SLAVE  10
    4646
    47 byte enabled = 255;
    48 
    49 void SPI_disable() {
    50   if (enabled != 255) {
    51     digitalWrite(enabled, HIGH);
    52     enabled = 255;
    53   }
    54 }
    55 
    56 void SPI_enable(byte slaveselecter) {
    57   SPI_disable();
    58   digitalWrite(slaveselecter, LOW);
    59   enabled = slaveselecter;
    60 }
    61 
    62 byte SPI_read(){
    63    return SPI.transfer(0x00);
    64 }
    65 
    6647void setup() {
    6748#ifdef GND
     
    7758
    7859  Serial.begin(9600);
    79 //  SPI_Master.begin(SLAVE);
    8060  SPI.begin();
    8161  SPI.setBitOrder(MSBFIRST);
     
    8868
    8969  delay(500);
    90   SPI_enable(SLAVE);        //  SPI_Master.enable(SLAVE);
    91   value = SPI_read() << 8;  //  value = SPI_Master.read() << 8;
    92   value |= SPI_read();      //  value |= SPI_Master.read();
    93   SPI_disable();            //  SPI_Master.disable();
     70  digitalWrite(SLAVE, LOW);        //  Enable a chip
     71  value = SPI.transfer(0x00) << 8;  //  read High byte
     72  value |= SPI.transfer(0x00);      //  read Low byte
     73  digitalWrite(SLAVE, HIGH);         //  Desavle a chip
    9474 
    9575  if ((value & 0x0004) != 0){