09-05-2016, 20:41
Mam problem przy debagowaniu wyskakuje mi błąd newping.h such file or directory. Kod poniżej
Kod:
/*Begining of Auto generated code by Atmel studio */
#include <Arduino.h>
#include <NewPing.h>
#include <LiquidCrystal.h>
#include <Servo.h>
/*End of auto generated code by Atmel studio */
//Beginning of Auto generated function prototypes by Atmel Studio
int dystans(int t);
void moverServo(int grado);
void wyswietlacz(int x, int y, String mensaje);
void siguienteMsj(String mensaje);
void wyswietlacz();
//End of Auto generated function prototypes by Atmel Studio
#define TRIGGER_PIN 14 //A0
#define ECHO_PIN 15 //A1
#define MAX_ODLEGLOSC 90
#define TRIGGER_PIN_S 16 //A2
#define ECHO_PIN_S 17 //A3
Servo servo1; // Tworzy obiekt servo
int pozycja; // Zmienna pozycja serwa
int w_miejsc = 6; //Liczba miejsc parkingowych
int max_miejsc = w_miejsc; //Liczba wolnych miejsc
const int numRows = 2;
const int numCols = 16;
NewPing sensorUE(TRIGGER_PIN, ECHO_PIN, MAX_ODLEGLOSC);
NewPing sensorUS(TRIGGER_PIN_S, ECHO_PIN_S, MAX_ODLEGLOSC);
// PINY DO WYSWIETLACZA LCD
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
Serial.begin(9600);
servo1.attach(6);
lcd.begin(numCols,numRows);
}
void loop() {
int odlegloscE=dystans(sensorUE.ping_median());
int dystansS=dystans(sensorUS.ping_median());
int stan=0;
if (odlegloscE<=14){
if (odlegloscE <=14 && w_miejsc>0){
stan=1;
moverServo(110); //Ruch serwa
if (stan==1){
wyswietlacz();
wyswietlacz(0,0," ***PARKING*** ");
wyswietlacz(0,1,"-> WJAZD -> ");
for(int i=0;i <4;i++){
wyswietlacz(0,1,"->");
wyswietlacz(13,1,"->");
delay(500);
wyswietlacz(0,1," ");
wyswietlacz(13,1," ");
delay(500);
}
moverServo(20);
stan=0;
w_miejsc--;
}
}
}else if(dystansS<=6){
if (dystansS <=6 && w_miejsc < max_miejsc ){
if (w_miejsc==max_miejsc){
wyswietlacz();
wyswietlacz(0,0," ***PARKING*** ");
wyswietlacz(0,1,"------PELNO-----");
}else{
wyswietlacz();
wyswietlacz(0,0," ***PARKING*** ");
wyswietlacz(0,1,"<- WYJAZD <- ");
stan=0;
moverServo(110); //GRADOS DE MOVIMIETO DEL SERVOMOTOR
for(int i=0;i <4;i++){
wyswietlacz(0,1,"<-");
wyswietlacz(13,1,"<-");
delay(500);
wyswietlacz(0,1," ");
wyswietlacz(13,1," ");
delay(500);
}
// delay(4000);
moverServo(20);
stan=0;
w_miejsc++;
}
}
}else{
//Parking pełny
if (w_miejsc==0){
wyswietlacz();
wyswietlacz(0,0 ," ***PARKING*** ");
wyswietlacz(0,1,"---BRAK MIEJSC---");
}else{
wyswietlacz();
wyswietlacz(0,0 ," ***PARKING*** ");
wyswietlacz(0,1,"MIEJSC: ");
siguienteMsj(String(w_miejsc));
moverServo(20);
}
}
}
int dystans(int t){
// Pomiar czasu podróży dźwięku
int tiempo = t;
int dystans=tiempo / US_ROUNDTRIP_CM;
return dystans;
}
void moverServo(int grado){
servo1.write(grado);
}
void wyswietlacz(int x, int y,String mensaje){
lcd.setCursor(x,y);
lcd.print(mensaje);
}
void siguienteMsj(String mensaje){
lcd.print(mensaje);
}
void wyswietlacz(){
lcd.clear();
}