06-01-2016, 21:51
Zastanawiam się dlaczego, przecież 7segementowy jest o wiele mniejszy i ładniej wygląda.
LCD z przejściówką na I2C czy bez?
Po prostu usuwasz co nie potrzebne z tego wyświetlacza 7 segment, dodajesz biblioteki od LCD inicjujesz go w setupie, i wyświetlasz numer na wyświetlaczu.
Pozdrawiam
LCD z przejściówką na I2C czy bez?
Po prostu usuwasz co nie potrzebne z tego wyświetlacza 7 segment, dodajesz biblioteki od LCD inicjujesz go w setupie, i wyświetlasz numer na wyświetlaczu.
Kod:
#include <Servo.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
Servo myservo; // create servo object to control a servo
#define ServoM 12 //Connected to the servo motor.
#define Bright 11 //servo library disable PWM on pins 9 and 10.
#define Exit 9 //Pin connected to the EXIT button.
#define In 8 //Pin connected to the IN button.
#define BarLow 177 //Low position of the barrier.
#define BarUp 95 //Up position of the barrier.
#define CAPACITY 8 //Capacity of the parking lot.
#define INTEN 80 //Display intensity %
int Available = 9;
void setup(){
myservo.attach(ServoM);
lcd.begin();
lcd.backlight(); // attaches the servo.
pinMode(Exit, INPUT); // set "EXIT" button pin to input
pinMode(In, INPUT); // set "IN" button pin to input
digitalWrite(Exit, HIGH); // Connect Pull-Up resistor.
digitalWrite(In, HIGH); // Connect Pull-Up resistor.
myservo.write(BarLow); //Barrier in the low position
// delay(1000);
}
//================================================================
void loop(){
Display;
if(digitalRead(In)==0)
{
if(Available != 0){
Available--;
myservo.write(BarUp);
delay(3000);
myservo.write(BarLow);
}
}
if(digitalRead(Exit)==0)
{
if(Available != CAPACITY){
Available++;
myservo.write(BarUp);
delay(3000);
myservo.write(BarLow);
}
}
}
/*-------------------------------------------------------------------
Put the segments according to the number.
--------------------------------------------------------------------*/
void Display(){
lcd.setCursor(0,0);
lcd.print(Available);
}