'movementstatus' does not name a type

Arduino:1.6.9 (Windows 10), Scheda:"Arduino/Genuino Uno"

sketch_may30a:42: error: 'movementstatus' does not name a type

   movementstatus=digitalRead(movement);

   ^

sketch_may30a:43: error: expected unqualified-id before 'if'

   if(movementstatus==HIGH)

   ^

sketch_may30a:66: error: 'lcd' does not name a type

 lcd.setCursor(0, 0);   //Start position of the cursor on the LCD (0,0 = first //character in the first row).

 ^

sketch_may30a:67: error: 'lcd' does not name a type

 lcd.print("Temp.=");  // Write the text “www.funduino.de”

 ^

sketch_may30a:68: error: 'lcd' does not name a type

 lcd.setCursor(6, 0);  //Start position of the cursor on the LCD (0,0 = first //character in the second row).

 ^

sketch_may30a:69: error: 'lcd' does not name a type

 lcd.print(temperatureC);  // Write the text “good luck!!!”.

 ^

sketch_may30a:70: error: 'lcd' does not name a type

 lcd.setCursor(10, 0);  //Start position of the cursor on the LCD (0,0 = first //character in the second row).

 ^

sketch_may30a:71: error: 'lcd' does not name a type

 lcd.print(" C");  // Write the text “good luck!!!”.

 ^

sketch_may30a:72: error: 'lcd' does not name a type

 lcd.setCursor(0, 1);   //Start position of the cursor on the LCD (0,0 = first //character in the first row).

 ^

sketch_may30a:73: error: 'lcd' does not name a type

 lcd.print("Allarme attivo");  // Write the text “www.funduino.de”

 ^

sketch_may30a:74: error: expected constructor, destructor, or type conversion before '(' token

 delay (2000);

       ^

sketch_may30a:75: error: expected declaration before '}' token

 }

 ^

exit status 1
'movementstatus' does not name a type

Questo report potrebbe essere più ricco di informazioni con l'opzione
"Mostra un output dettagliato durante la compilazione"
abilitata in File -> Impostazioni

questo è il codice che volevo usare, ma alla riga dove dice "movementstatus=digitalRead(movement);" mi da errore... AIUTO

…e tu pensi che noi abbiamo una sfera di cristallo dove possiamo vedere il tuo codice e capire l’errore ? :astonished:

Metti tutto il codice (… mi raccomando, racchiuso tra i tag CODE che, in fase di edit, ti inserisce il bottone </> … primo a sinistra) e vediamo di capire …

Guglielmo

ok scusa :smiley:

#include <LiquidCrystal.h>   //Load the LCD library 
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);  //In this line we define which pins on //the microcontroller get connected to the LCD (Better don't change yet). 
//TMP36 Pin Variables
int movement=7;   //The word “movement” stands for the value 7. 
int movementstatus=0;
int pinButton = 13;
int piezo=8;
int stateButton;
int previous = LOW;
long time = 0;
long debounce = 200;
int sensorPin = 0; //the analog pin the TMP36's Vout (sense) pin is connected to
//the resolution is 10 mV / degree centigrade with a
//500 mV offset to allow for negative temperatures
void setup() {
  pinMode(pinButton, INPUT);
  pinMode(piezo, OUTPUT);  //The pin connected to the piezo speaker (pin 5) is //defined as an output. 
  pinMode(movement, INPUT);  //The pin connected to the moition detector (pin 7)is //defined as an input. 
lcd.begin(16, 2);   //In the setup we indicate how many signs and how many rows //we are using. In this case: 16 signs in two rows. 
//TMP36 Pin Variables
int sensorPin = 0; //the analog pin the TMP36's Vout (sense) pin is connected to
//the resolution is 10 mV / degree centigrade with a
//500 mV offset to allow for negative temperatures
}
void loop() {
  stateButton = digitalRead(pinButton);  
  if(stateButton == HIGH && previous == LOW && millis() - time > debounce) {
          lcd.setCursor(0, 1);   //Start position of the cursor on the LCD (0,0 = first //character in the first row).
    lcd.print("allarme disattivo");  // Write the text “www.funduino.de”
    if(movementstatus == HIGH){
      movementstatus = LOW; 
    } else {
       movementstatus = HIGH; 
                 lcd.setCursor(0, 1);   //Start position of the cursor on the LCD (0,0 = first //character in the first row).
    lcd.print("allarme attivo");  // Write the text “www.funduino.de”
    }
    time = millis();
  }
  digitalWrite(movement, movementstatus);
  previous == stateButton;
}
  movementstatus=digitalRead(movement);
  if(movementstatus==HIGH)
  { 
    digitalWrite(piezo,HIGH);  //..the piezo should beep
      lcd.setCursor(0, 1);   //Start position of the cursor on the LCD (0,0 = first //character in the first row).
    lcd.print("                ");  // Write the text “www.funduino.de”
    lcd.setCursor(0, 0);   //Start position of the cursor on the LCD (0,0 = first //character in the first row).
    lcd.print("MOVIMENTO RILEVA");  // Write the text “www.funduino.de”
    delay (1200);
        lcd.setCursor(0, 0);   //Start position of the cursor on the LCD (0,0 = first //character in the first row).
    lcd.print("OVIMENTO RILEVAT");  // Write the text “www.funduino.de”
        delay (1200);
        lcd.setCursor(0, 0);   //Start position of the cursor on the LCD (0,0 = first //character in the first row).
    lcd.print("VIMENTO RILEVATO");  // Write the text “www.funduino.de”
    delay (2100);
 digitalWrite(piezo,LOW);  //..the piezo should beep
        lcd.setCursor(0, 0);   //Start position of the cursor on the LCD (0,0 = first //character in the first row).
    lcd.print("                ");  // Write the text “www.funduino.de”
        lcd.setCursor(0, 1);   //Start position of the cursor on the LCD (0,0 = first //character in the first row).
    lcd.print("                ");  // Write the text “www.funduino.de”
  }
int reading = analogRead(sensorPin); 
float voltage = reading * 5.0 / 1024; 
float temperatureC = (voltage - 0.5) * 100 ;
lcd.setCursor(0, 0);   //Start position of the cursor on the LCD (0,0 = first //character in the first row).
lcd.print("Temp.=");  // Write the text “www.funduino.de”
lcd.setCursor(6, 0);  //Start position of the cursor on the LCD (0,0 = first //character in the second row).
lcd.print(temperatureC);  // Write the text “good luck!!!”.
lcd.setCursor(10, 0);  //Start position of the cursor on the LCD (0,0 = first //character in the second row).
lcd.print(" C");  // Write the text “good luck!!!”.
lcd.setCursor(0, 1);   //Start position of the cursor on the LCD (0,0 = first //character in the first row).
lcd.print("Allarme attivo");  // Write the text “www.funduino.de”
delay (2000);
}

gpb01:
…e tu pensi che noi abbiamo una sfera di cristallo dove possiamo vedere il tuo codice e capire l’errore ? :astonished:

Metti tutto il codice (… mi raccomando, racchiuso tra i tag CODE che, in fase di edit, ti inserisce il bottone </> … primo a sinistra) e vediamo di capire …

Guglielmo

Come non la avete?? ;D

Se tu usassi quella comoda funzione dell’IDE che sistema le righe del codice (Tools → Auto Format) ti accorgeresti che dalla riga indicata in poi … sei FUORI dal loop(), ovvero, hai già chiuso la graffa del loop().

  }
  digitalWrite(movement, movementstatus);
  previous == stateButton;
} // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< questa chiude il loop()
movementstatus = digitalRead(movement);
if (movementstatus == HIGH)

Riguarda il tuo codice e vedi cosa vuoi fare esattamente !

Guglielmo

Controlla il numero e e posizioni delle parentesi graffe.
In riga 42 chiudi la funzione loop() e il codice dopo é fuori da una funzione.
Ciao Uwe

ok, capito l'errore e risolto! Che sciocco che sono stato :o