Skip to content
  • P
    Projects
  • G
    Groups
  • S
    Snippets
  • Help

dmpada / eriala-2024

  • This project
    • Loading...
  • Sign in
Go to a project
  • Project
  • Repository
  • Issues 0
  • Merge Requests 0
  • Pipelines
  • Wiki
  • Snippets
  • Members
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Files
  • Commits
  • Branches
  • Tags
  • Contributors
  • Graph
  • Compare
  • Charts
Switch branch/tag
  • eriala-2024
  • lab3
  • lab3_demo_thermistor
  • lab3_demo_thermistor.ino
Find file
BlameHistoryPermalink
  • Risto Heinsar's avatar
    Added wk3 demo codes · b6aaa60b
    Risto Heinsar committed 7 months ago
    b6aaa60b
lab3_demo_thermistor.ino 587 Bytes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
#define THERMISTOR_PIN                A0

/* Arduino ADC on 10-bitine - st 2^10 = 1024 */
#define ADC_RESOLUTION               1024

/* Kasuta enda Arduino võrdluspinget */
#define REF_VOLTAGE                  9.00 

const uint16_t tickDelay = 500;

void setup() 
{
  Serial.begin(9600);
  pinMode(THERMISTOR_PIN, INPUT);
}

void loop() 
{
  uint16_t tempSensor = analogRead(THERMISTOR_PIN);
  float tempInC = ((tempSensor / (float)ADC_RESOLUTION) * REF_VOLTAGE - 0.5) * 100;
  
  Serial.print("Temperatuur: ");
  Serial.print(tempInC);
  Serial.println("°C");
  
  delay(tickDelay);
}