This is my first time using multiple tabs. This is what is says when i am trying to compile it... Anyone know the anwser, the error is in the second tab on all the Println's used. When i compile them seperate they are both working.....
"exit status 1 'Serial' does not name a type"
First tab (Main project tab):
#include <EEPROM.h>
// deze constante veranderen niet
const int buttonPin = 3; // waar de button op aangesloten is
// the button moet aangesloten zijn vanaf pin naar ground, pinmode is een input_pullup
// Deze variabelen veranderen
bool buttonState; // momentele status van de button
bool lastButtonState; // vorige status van de button
unsigned long buttonBecamePressedAt;
unsigned long buttonHasBeenPressedForTotal;
unsigned long buttonHasBeenPressedForThisTime;
unsigned long lastPress; // dit is de laatste state waar de arduino in was
unsigned long hours;
int AdressRoom = 50; // dit is kamer 50 op de EEPROOM
void setup()
{
// initialize serial communication:
Serial.begin(9600);
EEPROM.get(AdressRoom, hours);
Serial.println(".... Hoe lang is de button ingedrukt? ....");
Serial.print("Created: ");
Serial.print(__TIME__);
Serial.print(", ");
Serial.println(__DATE__);
Serial.println(__FILE__);
Serial.println("Last press");
buttonHasBeenPressedForTotal = (EEPROM.get(AdressRoom, lastPress)); //hier haalt hij de laatste bekende tijd op
Serial.println(buttonHasBeenPressedForTotal); // hier print hij de laatste bekende staat
// Initializa de button pin als een input with pullup active low.
// verzeker dat de button van PIN naar GROUND
pinMode(buttonPin, INPUT_PULLUP);
//initialize button states
buttonState = digitalRead(buttonPin);
lastButtonState = buttonState;
Serial.println("Setup done");
Serial.println(" ");
}
void loop()
{
// lezen van de pushbutton buttonpin:
buttonState = digitalRead(buttonPin);
// vergelijkt de buttonstaat naar de vorige staat
if (buttonState != lastButtonState) // betekend dat hij veranderd is, welke kant nog onduidelijk
{
if (buttonState == LOW) // veranderd naar ingedrukt
{
// als de momentele staat is LOW dan was de button ingedrukt
Serial.print("Newly pressed at ");
Serial.print(millis());
Serial.print(" ms");
buttonBecamePressedAt = millis();
}
else // changed to released
{
// als de huidige staat HIGH dan was de button released
Serial.print(", newly released at ");
Serial.print(millis());
Serial.println(" ms");
lastPress = buttonHasBeenPressedForTotal; //hier neemt hij de "LastPress " over, dit is de laatste bekende tijd
buttonHasBeenPressedForThisTime = millis() - buttonBecamePressedAt;
buttonHasBeenPressedForTotal = buttonHasBeenPressedForTotal + buttonHasBeenPressedForThisTime;
Serial.print(" This press: ");
Serial.print(buttonHasBeenPressedForThisTime);
Serial.print(" ms");
Serial.print(", Total: ");
Serial.print(buttonHasBeenPressedForTotal);
Serial.println(" ms");
hours = buttonHasBeenPressedForTotal / 1000;
Serial.println("Pressed total:");
Serial.println(hours);
Serial.println("Hallo");
EEPROM.put(AdressRoom, lastPress); // hier stopt hij de totale tijd button hoog was in de
}
// Delay om "stuiteren" te voorkomen, delay van 50ms is genoeg hiervoor
delay(50);
}
// Verander de huidige staat als de vorige staat, voor de volgende keer door de loop
lastButtonState = buttonState;
}
Second tab named NTPSERVER:
#include <SPI.h> // for communication with Ethernet Shield
#include <TimeLib.h> // for update/display of time
#include <Ethernet.h> // for communication with NTP Server via UDP
// variable to hold Ethernet shield MAC address
byte mac[] = { 0xA8, 0x61, 0x0A, 0xA1, 0x97, 0xDF };
// define IPAddress object that will contain the NTP server IP address
//IPAddress timeSrvr(129,6,15,28);
IPAddress timeSrvr(132,163,96,3);
//const char timeSrvr = ("time.nist.gov");
// IPAddress timeSrvr = ("pool.ntp.org");
//IPAddress timeSrvr = "pool.ntp.org";
// define Ethernet UDP object and local port 8888
EthernetUDP ethernet_UDP;
unsigned int localPort = 8888;
// variable to store previous displayed time
time_t prevDisplay = 0;
// array to hold incoming/outgoing NTP messages
// NTP time message is 48 bytes long
byte messageBuffer[48];
Serial.println("Sample Program for the Tutorial: Using An Arduino Ethernet Shield To Get Date and Time");
// get ethernet shield IP via DHCP
// [part of Ethernet Library]
while (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP"); // display error
delay(1000); // retry after 1 sec
}
// DHCP assignment successful, display ethernet shield IP to serial
// [part of Ethernet Library]
Serial.print("Ethernet Shield IP (DHCP): ");
Serial.println(Ethernet.localIP());
// start UDP
// [part of Ethernet Library]
ethernet_UDP.begin(localPort);
Serial.println("Ethernet UDP Start....");
// pass function getTime() to Time Library to update current time
// [part of Time Library]
setSyncProvider(getTime);
}
void loop()
{
if (timeStatus() != timeNotSet) { // check if the time is successfully updated
if (now() != prevDisplay) { // update the display only if time has changed
prevDisplay = now();
digitalClockDisplay(); // display the current date and time
}
}
}
void digitalClockDisplay() {
Serial.print(hour());
printDigits(minute());
printDigits(second());
Serial.print(" ");
Serial.print(day());
Serial.print(" ");
Serial.print(month());
Serial.print(" ");
Serial.print(year());
Serial.println();
ethernet_UDP.beginPacket(address, 123);
ethernet_UDP.write(messageBuffer, 48);
ethernet_UDP.endPacket();
}