Library Kompilierfehler _ MAX6675

Hallo,

ich möchte meinen MAX6675 verwenden und wollte diese Library nutzen.

Ich habe in der MAX6675.h und MAX6675.cpp jeweils oben den Eintrag korrigiert, laut dem Hinweis hier:

Jetzt meckert meine IDE 1.0.5-r2 aber immer noch rum. Wegen einer Variablendeklaration.

read_temp:14: error: conflicting declaration 'int SCK'
C:\Portable Apps\Arduino IDE\hardware\arduino\variants\mega/pins_arduino.h:38: error: 'SCK' has a previous declaration as 'const uint8_t SCK'

Wird der Variablenname "SCK" schon von der IDE standardmäßig verwendet und jetzt kommt es zu Konflikten?

Was muß man wo noch korrigieren? Die Library ist wohl schon etwas angestaubt.

Bitte den ganze Sketch.
Grüße Uwe

SCK ist bereits verwendet.

Wenn du einen leeren Sketch aufmachst, in dem nur die Zeile "int SCK;" steht, kommt auch der
Fehler "error: conflicting declaration 'int SCK'".

Verwende einen anderen Variablennamen und alles ist gut.

Hallo,

okay, habe SCK erstmal gegen irgendwas ausgetauscht. Kompilierung funktioniert und so funktioniert das Bsp. auch schon. Danke. Die Pins habe ich natürlich vorher für meinen Mega2560 angepaßt.

Der Sketch ist das Bsp. von Ryan.

/*
  Single_Temp.pde - Example using the MAX6675 Library.
  Created by Ryan McLaughlin <ryanjmclaughlin@gmail.com>

  This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
  http://creativecommons.org/licenses/by-sa/3.0/
*/

#include <MAX6675.h>

int LED1 = 9;             // Status LED Pin
int CS = 10;             // CS pin on MAX6675
int SO = 12;              // SO pin of MAX6675
int SCK = 13;             // SCK pin of MAX6675
int units = 2;            // Units to readout temp (0 = raw, 1 = ?C, 2 = ?F)
float temperature = 0.0;  // Temperature output variable


// Initialize the MAX6675 Library for our chip
MAX6675 temp(CS,SO,SCK,units);


// Setup Serial output and LED Pin  
// MAX6675 Library already sets pin modes for MAX6675 chip!
void setup() {
  Serial.begin(9600);
  pinMode(LED1, OUTPUT);
}

void loop() {
	// Read the temp from the MAX6675
	temperature = temp.read_temp();

	if(temperature < 0) {                   
		// If there is an error with the TC, temperature will be < 0
		Serial.print("Thermocouple Error on CS");
		Serial.println( temperature ); 
		digitalWrite(LED1, HIGH);
	} else {
		Serial.print("Current Temperature: ");
		Serial.println( temperature ); 
		digitalWrite(LED1, LOW);
	}
 
	// Wait one second before reading again
	delay(1000);	
}

Kann ich in der MAX6675.h und MAX6675.cpp statt

#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif

auch einfach nur:

#include "Arduino.h"

schreiben? Ich meine, niemand verwendet doch noch eine IDE älter Version 1.0 ?

Kannst du natürlich.

Aber das sind Compilerschalter, dein Code wird also nicht größer dadurch.

Wenn du unsicher bist, ob was funktioniert, einfach ausprobieren!

Hallo,

wenn der Code nicht wächst, dann belasse ich das so. Danke.