Czy ktoś może mi pomóc?
Oto komunikat:
In file included from LED_TEMP_PIEZO_pde.pde:15;
..\arduino-1.0.5\libraries\PCF8583/PCF8583.h:70: error: 'byte' has not been declared
..\arduino-1.0.5\libraries\PCF8583/PCF8583.h:71: error: 'byte' does not name type
Linie 70 i 71 tego pliku to:
int bcd_to_byte(byte bcd);
byte int_to_bcd(int in);
To listing tego pliku LED_TEMP_PIEZO_pde.pde
Kod: Zaznacz cały
/*
Przykład obsługi komponentów jakie zawiera moduł z wyświetlaczem LED dla Arduino UNO.
Program zawiera przykład konfiguracji i obsługi:
- wyświetlacza LED
- zegara RTC
- 2 przycisków
- brzęczyka PIEZO
- czujnika temperatury DS18B20
- czujnika światła
*/
#include "TimerOne.h"  //biblioteka obslugi timera
#include <Wire.h> //biblioteka i2c
#include <PCF8583.h>  //biblioteka RTC
#include <OneWire.h> //biblioteka 1Wire
OneWire  ds(A3);        // konfiguracja linii 1Wire
byte present = 0;      //definicje zmiennych uzywanych w programie
byte data[12];
byte addr[8];
int wart_analog;  
int HighByte, LowByte, SignBit, temp, Fract, TReading, Tc_100;
PCF8583 p (0xA0);       //konfiguracja adresu ukladu RTC
const int Buzzer =  13;   //przypisanie aliasow linia portow
const int DP =  12; 
const int SW1 =  A1; 
const int SW2 =  A2;
const int sens_sw =  A0; 
int groundPins[8] = {0, 1, 2, 3, 4, 5, 6, 7};   //linie portow wierszy LED
int digitPins[4] = { 8, 9, 10, 11}; //linie portow kolumn LED
int wys=0;
int digit[4]; //tablica znakow dla wyswietlacza LED
int kr[4];   //tablica przechowujaca zak kropki
byte temp_sec;
byte wsk_sek=1;
int number[13][7] = {    //tablica znakow dla LED
  {0,0,0,0,0,0,1}, //zero
  {1,0,0,1,1,1,1}, //jeden
  {0,0,1,0,0,1,0}, //dwa
  {0,0,0,0,1,1,0}, //trzy
  {1,0,0,1,1,0,0}, //cztery
  {0,1,0,0,1,0,0}, //piec
  {0,1,0,0,0,0,0}, //szesc
  {0,0,0,1,1,1,1}, //siedem
  {0,0,0,0,0,0,0}, //osiem
  {0,0,0,0,1,0,0}, //dziewiec
  {1,1,1,1,1,1,1}, //wylaczenie LED 
  {0,0,1,1,1,0,0}, //znak stopnia
  {0,1,1,0,0,0,1}  //znak C
};
void setup()        //procedura konfiguracyjna
{ 
  Timer1.initialize(100);      //inicjalizacja timer 1
  Timer1.attachInterrupt(int_wys);   //uruchomienie przerwania od timer 1 w procedurze int_wys
  for(int i=0; i < 8; i++)      //konfiguracja linii jako wyjscia obslugujacych wiersze LED
  {
    pinMode(groundPins[i], OUTPUT);
    digitalWrite(groundPins[i], HIGH);
  } 
  pinMode(Buzzer, OUTPUT);     //konfiguracja PIEZO
  digitalWrite(Buzzer, HIGH);
  pinMode(DP, OUTPUT);        //konfiguracja dwukropka wyswietlacza LED
  digitalWrite(DP, HIGH);
  for(int i=0; i < 4; i++)   //konfiguracja kolumn wyswietlacza LED
  {
    pinMode(digitPins[i], OUTPUT);
    digitalWrite(digitPins[i], HIGH);
  } 
  p.hour = 14;  //wartosci poczatkowe dla ukladu RTC
  p.minute = 30;
  p.second = 0;
  p.year = 2011;
  p.month = 4;
  p.day = 1;
  p.set_time();
  pinMode(SW1, INPUT);        //konfiguracja linii do ktorych sa dolaczono przyciski jako wejscia
  pinMode(SW2, INPUT);
  digitalWrite(SW1, HIGH);   //dolaczenie do linii do ktorych sa dolaczone przyciski rezystorow podciagajacych co wymusi na nich domyslnie stan wysoki
  digitalWrite(SW2, HIGH);
  analogReference(DEFAULT);   //konfiguracja przetwornika A/C
} 
void int_wys() {      //funkcja przerwania w ktorej obslugiwany jest wyswietlacz LED
  for(int i=0; i < 4; i++)    //petla for wykonywana dla kazdego z wyswietlaczy
  {
    digitalWrite(digitPins[i], HIGH);  //wylaczenie wyswietlacza
  }   
  for(int g=0; g < 7; g++)     //zapisanie do wyswietlacza znaku zapisanego w tablicy digit
  {
    digitalWrite(groundPins[g], number[digit[wys]][g]);
  };
  digitalWrite(groundPins[7], !(kr[wys]));  //zapisanie stanu kropki
  digitalWrite(digitPins[wys], LOW);    //wlaczenie obslugiwanego wyswietlacza
  wys++;       //zwiekszenie wartosci o 1 zmiennej wys
  if (wys>4) wys=0;     //jesli obslugiwany czwarty wyswietlacz to przejscie do obslugi pierwszego wyswietlacza
};
void loop()     //petla glowna programu
{
  digitalWrite(DP, LOW);   //wlaczenie calego wyswietlacza LED 
  kr[0]=HIGH;
  kr[1]=HIGH;
  kr[2]=HIGH;
  kr[3]=HIGH;
  for(int k=0; k < 10; k++)   //wyswietlenie na LED znakow od 0 do 9
  {
    digit[0] = k;
    digit[1] = k;
    digit[2] = k;
    digit[3] = k;
    delay(200);          //opoznienie 200ms
  };
  digitalWrite(DP, HIGH);  //instrukcje wylaczajace wszystkie elementy wyswietlacza LED
  kr[0]=LOW;
  kr[1]=LOW;
  kr[2]=LOW;
  kr[3]=LOW;
  digit[0] = 10;
  digit[1] = 10;
  digit[2] = 10;
  digit[3] = 10;
  delay(2000);
  while(1)      //petla programu
  {
    p.get_time();  //pobranie z RTC danych o czasie i dacie
    digit[3]=  p.minute%10;     //wyswietlenie minut
    digit[2] = p.minute / 10;
    digit[1]=  p.hour%10;     //wyswietlenie godzin
    digit[0] = p.hour / 10;
    if (temp_sec!=p.second)    //instrukcje migania dwukropka wyswietlacza co 1 sekunde
    {
      temp_sec=p.second;   //zapisanie wartosci sekund
      if (wsk_sek==1)   //jesli zmienna ma wartosc 1 to 
        digitalWrite(DP, HIGH);  //wylaczenie dwukropka
      else          //w przeciwnym razie
        digitalWrite(DP, LOW);  //wlaczenie dwukropka
      wsk_sek = !wsk_sek;  //zmianna stanu zmiennej
    } 
    if (digitalRead(SW1) == LOW) {         //Sprawdzenie czy nacisniety przycisk S1
      digit[0] = 10;  //instrukcje wylaczajace wyswietlacz LED
      digit[1] = 10;
      digit[2] = 10;
      digit[3] = 10;
      digitalWrite(DP, HIGH);   
      while(digitalRead(SW1) == LOW)   //jesli przycisk nadal przycisniety to
      {
        getTemp();              //pobranie wartosci temperatury 
        digit[1]=  temp%10;     //wyswietlenie wartosci temperatury
        digit[0] = temp / 10;
        digit[2] = 11;          //wyswietlenie znaku stopnia
        digit[3] = 12;          //wyswietlenie znaku C
        delay(500);            //opoznienie 500 ms
      }
    }
    if (digitalRead(SW2) == LOW) {         //Sprawdzenie czy nacisniety przycisk S2
      digit[0] = 10;            //instrukcje wylaczajace LED
      digit[1] = 10;
      digit[2] = 10;
      digit[3] = 10;
      digitalWrite(DP, HIGH);
      while(digitalRead(SW2) == LOW)  //jesli przycisk S2 nadal nacisniety to
      {
        digit[3]=  p.day%10; //wyswietlenie dnia miesiaca
        digit[2] = p.day / 10;
        digit[1]=  p.month%10; //wyswietlenie miesiaca
        digit[0] = p.month / 10;
        kr[1]=HIGH;          //wlaczenie kropki drugiego wyswietlacza
        delay(500);     //opoznienie 500 ms
      }
      kr[1]=LOW;   //wylaczenie kropki    
    }
    if ((wart_analog = analogRead(A0))<80)  //jesli wartosc odczytana z czujnika swiatla jest ponizej wartosci 80 to
      digitalWrite(Buzzer, LOW);   //wlaczenie brzeczyka
    else  //w przeciwnym razie 
      digitalWrite(Buzzer, HIGH);   //wylaczenie brzeczyka
  }  
} 
void getTemp() {    //procedura odczytu temperatury z czujnika 1Wire DS18B20
  int foo, bar, i;   //definicje zmiennych
  ds.reset();  //zerowanie ukladu 1Wire
  ds.write(0xCC,1);   //komendy startujace pomier temperatury
  ds.write(0x44,1);
  ds.reset();   //instrukcje odczytu temperatury
  ds.write(0xCC,1);
  ds.write(0xBE);
  for ( i = 0; i < 9; i++) {
    data[i] = ds.read();
  }
  LowByte = data[0];  //instrukcje obliczajace temperature ktorej wynik jest zapisywany
  HighByte = data[1];  //do zmiennej temp
  TReading = (HighByte << 8) + LowByte;
  SignBit = TReading & 0x8000;  //obliczenie znaku temperatury
  if (SignBit) {
    TReading = -TReading;
  }
  Tc_100 = (6 * TReading) + TReading / 4;    
  temp = Tc_100 / 100;          
  Fract = Tc_100 % 100;
  if (Fract > 49) {
    if (SignBit) {
      --temp;
    } 
    else {
      ++temp;
    }
  }
} To listing pliku PCF8583.h
Kod: Zaznacz cały
/*
  Implements a simple interface to the time function of the PCF8583 RTC chip
  Works around the device's limited year storage by keeping the year in the
  first two bytes of user accessible storage
  Assumes device is attached in the standard location - Analog pins 4 and 5
  Device address is the 8 bit address (as in the device datasheet - normally A0)
  Copyright (c) 2009, Erik DeBill
  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.
  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.
  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/
/*
   Usage:
      PCF8583 pcf(0xA0);
      pcf.get_time();
      Serial.print("year: ");
      Serial.println(pcf.year);
      pcf.hour = 14;
      pcf.minute = 30
      pcf.second = 0
      pcf.year = 2009
      pcf.month = 9
      pcf.day = 12
      pcf.set_time();
*/
#ifndef PCF8583_H
#define PCF8583_H
#include <WProgram.h>
#include <../Wire/Wire.h>
class PCF8583 {
    int address;
  public:
    int second;
    int minute;
    int hour;
    int day;
    int month;
    int year;
    int year_base;
    PCF8583(int device_address);
    void get_time();
    void set_time();
    int bcd_to_byte(byte bcd);
    byte int_to_bcd(int in);
};
#endif  //PCF8583_H
A to listing pliku PCF8583.cpp
Kod: Zaznacz cały
/*
  Implements a simple interface to the time function of the PCF8583 RTC chip
  Works around the device's limited year storage by keeping the year in the
  first two bytes of user accessible storage
  Assumes device is attached in the standard location - Analog pins 4 and 5
  Device address is the 8 bit address (as in the device datasheet - normally A0)
  Copyright (c) 2009, Erik DeBill
  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.
  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.
  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/
#include <WProgram.h>
#include <../Wire/Wire.h>
#include "PCF8583.h"
// provide device address as a full 8 bit address (like the datasheet)
PCF8583::PCF8583(int device_address) {
  address = device_address >> 1;  // convert to 7 bit so Wire doesn't choke
  Wire.begin();
}
void PCF8583::get_time(){
  Wire.beginTransmission(address);
  Wire.send(0xC0);   // stop counting, don't mask
  Wire.endTransmission();
  Wire.beginTransmission(address);
  Wire.send(0x02);
  Wire.endTransmission();
  Wire.requestFrom(address, 5);
  second = bcd_to_byte(Wire.receive());
  minute = bcd_to_byte(Wire.receive());
  hour   = bcd_to_byte(Wire.receive());
  byte incoming = Wire.receive(); // year/date counter
  day    = bcd_to_byte(incoming & 0x3f);
  year   = (int)((incoming >> 6) & 0x03);      // it will only hold 4 years...
  month  = bcd_to_byte(Wire.receive() & 0x1f);  // 0 out the weekdays part
  //  but that's not all - we need to find out what the base year is
  //  so we can add the 2 bits we got above and find the real year
  Wire.beginTransmission(address);
  Wire.send(0x10);
  Wire.endTransmission();
  Wire.requestFrom(address, 2);
  year_base = 0;
  year_base = Wire.receive();
  year_base = year_base << 8;
  year_base = year_base | Wire.receive();
  year = year + year_base;
}
void PCF8583::set_time(){
  Wire.beginTransmission(address);
  Wire.send(0xC0);   // stop counting, don't mask
  Wire.endTransmission();
  Wire.beginTransmission(address);
  Wire.send(0x02);
  Wire.send(int_to_bcd(second));
  Wire.send(int_to_bcd(minute));
  Wire.send(int_to_bcd(hour));
  Wire.send(((byte)(year % 4) << 6) | int_to_bcd(day));
  Wire.send(int_to_bcd(month));
  Wire.endTransmission();
  Wire.beginTransmission(address);
  Wire.send(0x10);
  year_base = year - year % 4;
  Wire.send(year_base >> 8);
  Wire.send(year_base & 0x00ff);
  Wire.endTransmission();
}
int PCF8583::bcd_to_byte(byte bcd){
  return ((bcd >> 4) * 10) + (bcd & 0x0f);
}
byte PCF8583::int_to_bcd(int in){
  return ((in / 10) << 4) + (in % 10);
}

