TUTORIAL ARDUINO – PROGETTO 3 – AMOROMETRO

TUTORIAL ARDUINO – PROGETTO 3 – AMOROMETRO

IN QUESTO TUTORIAL USEREMO UN SENSORE DI TEMPERATURA PER MISURARE QUANTO E’ CALDA LA TUA PELLE. QUESTO SENSORE PRODUCE UNA TENSIONE CHE VARIA IN BASE ALLA TEMPERATURA PERCEPITA. NELLO SKETCH LEGGERAI IL VALORE DAL SENSORE E LO USERAI PER ACCENDERE E SPEGNERE I LED IN BASE A QUANTO SEI CALDO.
 
N.B. PRIMA DI PROCEDERE CONTROLLA I VALORI DAL MONITOR SERIALE DI ARDUINO DI TEMPERATURA DELLA STANZA SENZA TOCCARE IL SENSORE 
RIPORTALI SULLA STRINGA: const float baselineTemp = 28.61; RICARICA LO SKETCH SU ARDUINO E I LED S ACCENDERANNO IN BASE ALLA TUA TEMPERATURA CORPOREA. 
 
 
 
 

 

 
 
 
 
 
 
 

INGREDIENTI :

 
– 8 CAVI JUMPER;
– 3 LED;
– 3 RESISTENZA DA 220 OHM;
– 1 SENSORE DI TEMPERATURA;

SKETCH:
const int sensorPin = A0;
 
const float baselineTemp = 28.61;(valore da modificare in base alla temperatura della stanza);
 
void setup(){
  Serial.begin(9600);
  /
  for(int pinNumber = 2; pinNumber<5; pinNumber++){
    pinMode(pinNumber,OUTPUT);
    digitalWrite(pinNumber, LOW);
  }
}
 
void loop(){
  int sensorVal = analogRead(sensorPin);
 
  Serial.print(“sensor Value: “);
  Serial.print(sensorVal); 
 
 
  float voltage = (sensorVal/1024.0) * 5.0;
 
  Serial.print(“, Volts: “);
  Serial.print(voltage);
 
  Serial.print(“, degrees C: “); 
  float temperature = (voltage – .5) * 100;
  Serial.println(temperature);
 
  if(temperature < baselineTemp){
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
  } 
  else if(temperature >= baselineTemp+2 && temperature < baselineTemp+4){
    digitalWrite(2, HIGH);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
  } 
  else if(temperature >= baselineTemp+4 && temperature < baselineTemp+6){
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, LOW);
  } 
  else if(temperature >= baselineTemp+6){
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
  }
  delay(1);
}
 
BUON DIVERTIMENTO!!!!!!

2 commenti su “TUTORIAL ARDUINO – PROGETTO 3 – AMOROMETRO

  1. Arduino:1.5.8 (Windows XP), Scheda:”Digispark Pro (16 Mhz)”

    Build options changed, rebuilding all

    sketch_jan15a.ino:17:3: error: stray ‘\’ in program
    sketch_jan15a.ino:17:3: error: stray ‘\’ in program
    sketch_jan15a.ino:23:3: error: stray ‘\’ in program
    sketch_jan15a.ino:23:3: error: stray ‘\’ in program
    sketch_jan15a.ino:26:3: error: stray ‘\’ in program
    sketch_jan15a.ino:26:3: error: stray ‘\’ in program
    sketch_jan15a.ino:27:3: error: stray ‘\’ in program
    sketch_jan15a.ino:1:23: error: ‘A0’ was not declared in this scope
    sketch_jan15a.ino:3:42: error: expected ‘)’ before ‘da’
    sketch_jan15a.ino: In function ‘void setup()’:
    sketch_jan15a.ino:7:3: error: expected primary-expression before ‘/’ token
    sketch_jan15a.ino:8:3: error: expected primary-expression before ‘for’
    sketch_jan15a.ino:8:3: error: expected ‘;’ before ‘for’
    sketch_jan15a.ino:8:26: error: ‘pinNumber’ was not declared in this scope
    sketch_jan15a.ino:8:50: error: expected ‘;’ before ‘)’ token
    sketch_jan15a.ino: In function ‘void loop()’:
    sketch_jan15a.ino:17:17: error: ‘u201csensor’ was not declared in this scope
    sketch_jan15a.ino:23:17: error: ‘u201c’ was not declared in this scope
    sketch_jan15a.ino:23:29: error: found ‘:’ in nested-name-specifier, expected ‘::’
    sketch_jan15a.ino:23:24: error: ‘Volts’ has not been declared
    sketch_jan15a.ino:26:24: error: ‘degrees’ was not declared in this scope
    sketch_jan15a.ino:27:33: error: expected ‘)’ before ‘u2013’

    Qualcuno può aiutarmi?
    Grazie

    • CIAO…PROVA A RISCRIVERE IL CODICE STANDO ATTENTO A NON SALTARE ALCUNA STRINGA E CONTROLLA I COLLEGAMENTI CHE SIANO ESEGUITI CORRETTAMENTE..A PRESTO

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *


*