Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <LiquidCrystal.h> //Dołączenie biblioteki LCD
- #include <TinyGPS++.h> //biblioteka odpowiedzialna za lokalizator GPS
- #include <SoftwareSerial.h>
- /*
- Spis pinów:
- 2,3,4,5,6,7 - LCD
- 8 - przycisk
- 9 - Serwomechanizm
- 10, 11 - RX, TX
- */
- // Pulses duration: 600 - 0deg; 1450 - 90deg; 2300 - 180deg;
- LiquidCrystal lcd (2,3,4,5,6,7); //Informacja o podlaczeniu nowego wyswietlacza
- SoftwareSerial serial_connection(11, 10); //RX=pin 10, TX=pin 11
- TinyGPSPlus gps;
- void setup(){
- pinMode(8, INPUT_PULLUP);
- pinMode(9, OUTPUT);
- lcd.begin(16,2);
- lcd.setCursor(0,0);
- lcd.print("Predkosc");
- lcd.setCursor(0,1);
- lcd.print("Kat. wych");
- lcd.setCursor(10,0);
- lcd.print(gps.speed.kmph());
- lcd.setCursor(10,1);
- lcd.print("0");
- Serial.begin(9600);
- serial_connection.begin(9600);//This opens up communications to the GPS - Dowiedzieć się dlaczego nie działa!
- }
- void loop(){
- while(serial_connection.available())//While there are characters to come from the GPS
- {
- gps.encode(serial_connection.read());//This feeds the serial NMEA data into the library one char at a time
- }
- if(gps.location.isUpdated())
- {
- if(gps.speed.kmph() == 0 ){ //GPS = 0km/h -> Serwomechanizm 0"
- digitalWrite(9, HIGH);
- delayMicroseconds(600);
- digitalWrite(9, LOW);
- delay(20);
- lcd.setCursor(10,0);
- lcd.print(gps.speed.kmph());
- lcd.setCursor(10,1);
- lcd.print("0");
- }
- if(gps.speed.kmph() <= 1 && gps.speed.kmph() > 0 ){ //GPS > 90km/h -> Serwomechanizm 20"
- digitalWrite(9, HIGH);
- delayMicroseconds(700);
- digitalWrite(9, LOW);
- delay(20);
- lcd.setCursor(10,0);
- lcd.print(gps.speed.kmph());
- lcd.setCursor(10,1);
- lcd.print("10");
- }
- if(gps.speed.kmph() > 1 && gps.speed.kmph() < 2 ){ //GPS > 90km/h -> Serwomechanizm 20"
- digitalWrite(9, HIGH);
- delayMicroseconds(900);
- digitalWrite(9, LOW);
- delay(20);
- lcd.setCursor(10,0);
- lcd.print(gps.speed.kmph());
- lcd.setCursor(10,1);
- lcd.print("30");
- }
- if(gps.speed.kmph() >= 2 && gps.speed.kmph() < 30){//GPS > 120km/h -> Serwomechanizm 50"
- digitalWrite(9, HIGH);
- delayMicroseconds(1100);
- digitalWrite(9, LOW);
- delay(20);
- lcd.setCursor(10,0);
- lcd.print(gps.speed.kmph());
- lcd.setCursor(10,1);
- lcd.print("50");
- }
- if(gps.speed.kmph() > 30 && digitalRead(8) == LOW ){ //GPS > 30km/h & Wciśniecie buttona(hamulec) -> Serwomechanizm 80"
- digitalWrite(9, HIGH);
- delayMicroseconds(1400);
- digitalWrite(9, LOW);
- delay(20);
- lcd.setCursor(10,0);
- lcd.print(gps.speed.kmph());
- lcd.setCursor(10,1);
- lcd.print("80");
- }
- if(gps.speed.kmph() < 1 && digitalRead(8) == LOW ){ //GPS < 30km/h & Wciśniecie buttona(hamulec) -> Serwomechanizm 0"
- digitalWrite(9, HIGH);
- delayMicroseconds(600);
- digitalWrite(9, LOW);
- delay(20);
- lcd.setCursor(10,0);
- lcd.print(gps.speed.kmph());
- lcd.setCursor(10,1);
- lcd.print("0");
- }
- }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement