Stap 6: Arduino
Dit deel was enigszins ingewikkeld. Boven is onze schema, en hieronder is onze code.
Code:
float temp; int tempPin = 9; int tempMin = 70; int tempMax = 100; int fanPin = 7; int standaardkoeler = 0; void setup {pinMode (fanPin, OUTPUT); pinMode (tempPin, INPUT); Serial.begin(9600); } void loop {temp = analogRead(tempPin); temp = (temp * 5.0 * 100.0)/1024.0; temp = (temp * (9.0/5.0)) + 32,0; Serial.println(temp); delay(1000); Als (temp < tempMin) {fanSpeed = 0; digitalWrite (fanPin, laag);} als ((temp > = tempMin) & & (temp < = tempMax)) {standaardkoeler = kaart (temp, tempMin, tempMax, 32, 255); analogWrite (fanPin, fanSpeed);}}