Reprap/Quick thermistor hack

aus Metalab, dem offenen Zentrum für meta-disziplinäre Magier und technisch-kreative Enthusiasten.
< Reprap
Version vom 19. November 2007, 21:04 Uhr von Bre (Diskussion | Beiträge)

(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Wechseln zu: Navigation, Suche

int pwm_c = 11; int thermistorpin=0; float fraction=0; int i;

void setup() { pinMode(pwm_c, OUTPUT);

       Serial.begin(9600);

}

/* my first time on the arduino, the damn thing doesnt work, the calculation is dumb simple, but I must admit, that I'm too stupid to get the error solved */

/* it should sets the motor due to the value of the thermistor, but the thermistor produces (for me: Phantasus) weird values, which produce a result of 100% */

void loop() {

   int therm;	
   therm=analogRead(thermistorpin)-238;
   Serial.println("Thermistor value:");
   Serial.println(therm, DEC);
     fraction = (therm/750)*255;
   analogWrite(pwm_c,(int)fraction);	
   Serial.println("Result");
   Serial.println(fraction,DEC);    

}