Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int baselineTemp = 0;
- int celsius = 0;
- int fahrenheit = 0;
- int speedMotor = 0;
- void setup()
- {
- pinMode(A0, INPUT);
- Serial.begin(9600);
- pinMode(3, OUTPUT);
- }
- void loop()
- {
- baselineTemp = 40;
- // measure temperature in Celsius
- celsius = map(((analogRead(A0) - 20) * 3.04), 0, 1023, -40, 125);
- speedMotor = map(((analogRead(A0) - 20) * 3.04), 0, 1023, 0, 255);
- fahrenheit = ((celsius * 9) / 5 + 32);
- Serial.print(celsius);
- Serial.print(" C, ");
- Serial.print(fahrenheit);
- Serial.println(" F");
- analogWrite(3, speedMotor);
- }
Advertisement
Add Comment
Please, Sign In to add comment