Tomdrummer
Gebruiker
- Lid geworden
- 9 apr 2013
- Berichten
- 24
Hallo iedereen!
Ik ben momenteel bezig met een project waarbij er een melding komt op een horloge die we zelf gemaakt hebben als er een natuurramp komt, om dit alles te demonstreren op een expo maken we gebruik van bluetooth. Dit is ons arduino programma waarmee we gebruik van maken.
#include <Time.h>
#include <Wire.h>
#include <DS1307RTC.h> // a basic DS1307 library that returns time as a time_t
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int switchPin = 6;
int switchState = 0;
int prevSwitchState = 0;
int reply;
char INBYTE;
int LED = 13; // LED on pin 13
void setup() {
lcd.begin(16, 2);
Serial.begin(9600);
setSyncProvider(RTC.get); // the function to get the time from the RTC
if(timeStatus()!= timeSet)
Serial.println("Unable to sync with the RTC");
else
Serial.println("RTC has set the system time");
pinMode(10, OUTPUT);
pinMode(LED, OUTPUT);
}
void loop() {
Serial.println("Press 1 to turn Arduino pin 13 LED ON or 0 to turn it OFF:");
while (!Serial.available()); // stay here so long as COM port is empty
INBYTE = Serial.read(); // read next available byte
if( INBYTE == 'a' )
digitalWrite(LED, LOW); // if it's a 0 (zero) tun LED off
digitalClockDisplay();
delay(1000);
}
void digitalClockDisplay(){
// digital clock display of the time
Serial.print(hour());
printDigits(minute());
printDigits(second());
Serial.print(" ");
Serial.print(day());
Serial.print(" ");
Serial.print(month());
Serial.print(" ");
Serial.print(year());
Serial.println();
lcd.setCursor(2, 0); // Set LCD cursor position (column, row)
lcd.print(hour());
lcd.print(":");
lcd.print (minute());
lcd.print(":");
lcd.print(second());
lcd.print(" ");
lcd.print("");
lcd.setCursor(3, 1); // Set LCD cursor position (column,row)
lcd.print(day());
lcd.print(".");
lcd.print(month());
lcd.print(".");
lcd.print(year());
// Print text to LCD
// Delay to read text
// Clear the display
}
void printDigits(int digits){
// utility function for digital clock display: prints preceding colon and leading 0
Serial.print(":");
if(digits < 10)
Serial.print('0');
Serial.print(digits);
}
if( INBYTE == 'z' )
void printDigits(int digits){
// utility function for digital clock display: prints preceding colon and leading 0
Serial.print(":");
if(digits < 10)
Serial.print('0');
Serial.print(digits);
switchState = digitalRead(switchPin);
if (switchState != prevSwitchState) {
if (switchState == LOW) {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("! Overstroming !");
lcd.setCursor(4, 1);
switch(reply) {
case 0:
lcd.print("Ga naar");
delay(3000);
case 1:
lcd.setCursor(3, 1);
lcd.print("marktplein");
delay(3000);
case 2:
lcd.setCursor(3, 1);
lcd.print("te Veurne ");
delay(3000);
}
}
}
prevSwitchState = switchState;
}
Volgens arduino zit er deze fout in:
expected unqualified id before 'if'
Wie o wie kan mij helpen
Ik ben momenteel bezig met een project waarbij er een melding komt op een horloge die we zelf gemaakt hebben als er een natuurramp komt, om dit alles te demonstreren op een expo maken we gebruik van bluetooth. Dit is ons arduino programma waarmee we gebruik van maken.
#include <Time.h>
#include <Wire.h>
#include <DS1307RTC.h> // a basic DS1307 library that returns time as a time_t
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int switchPin = 6;
int switchState = 0;
int prevSwitchState = 0;
int reply;
char INBYTE;
int LED = 13; // LED on pin 13
void setup() {
lcd.begin(16, 2);
Serial.begin(9600);
setSyncProvider(RTC.get); // the function to get the time from the RTC
if(timeStatus()!= timeSet)
Serial.println("Unable to sync with the RTC");
else
Serial.println("RTC has set the system time");
pinMode(10, OUTPUT);
pinMode(LED, OUTPUT);
}
void loop() {
Serial.println("Press 1 to turn Arduino pin 13 LED ON or 0 to turn it OFF:");
while (!Serial.available()); // stay here so long as COM port is empty
INBYTE = Serial.read(); // read next available byte
if( INBYTE == 'a' )
digitalWrite(LED, LOW); // if it's a 0 (zero) tun LED off
digitalClockDisplay();
delay(1000);
}
void digitalClockDisplay(){
// digital clock display of the time
Serial.print(hour());
printDigits(minute());
printDigits(second());
Serial.print(" ");
Serial.print(day());
Serial.print(" ");
Serial.print(month());
Serial.print(" ");
Serial.print(year());
Serial.println();
lcd.setCursor(2, 0); // Set LCD cursor position (column, row)
lcd.print(hour());
lcd.print(":");
lcd.print (minute());
lcd.print(":");
lcd.print(second());
lcd.print(" ");
lcd.print("");
lcd.setCursor(3, 1); // Set LCD cursor position (column,row)
lcd.print(day());
lcd.print(".");
lcd.print(month());
lcd.print(".");
lcd.print(year());
// Print text to LCD
// Delay to read text
// Clear the display
}
void printDigits(int digits){
// utility function for digital clock display: prints preceding colon and leading 0
Serial.print(":");
if(digits < 10)
Serial.print('0');
Serial.print(digits);
}
if( INBYTE == 'z' )
void printDigits(int digits){
// utility function for digital clock display: prints preceding colon and leading 0
Serial.print(":");
if(digits < 10)
Serial.print('0');
Serial.print(digits);
switchState = digitalRead(switchPin);
if (switchState != prevSwitchState) {
if (switchState == LOW) {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("! Overstroming !");
lcd.setCursor(4, 1);
switch(reply) {
case 0:
lcd.print("Ga naar");
delay(3000);
case 1:
lcd.setCursor(3, 1);
lcd.print("marktplein");
delay(3000);
case 2:
lcd.setCursor(3, 1);
lcd.print("te Veurne ");
delay(3000);
}
}
}
prevSwitchState = switchState;
}
Volgens arduino zit er deze fout in:
expected unqualified id before 'if'
Wie o wie kan mij helpen
