Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Wire.h>
- #include <LiquidCrystal_I2C.h>
- LiquidCrystal_I2C lcd(0x27,16,2);
- boolean A, B;
- long P;
- float M;
- void setup() {
- //Serial.begin(115200);
- pinMode(6, INPUT); // кнопка reser
- pinMode(2, INPUT_PULLUP);
- pinMode(3, INPUT_PULLUP);
- attachInterrupt(0,blink1, CHANGE);
- attachInterrupt(1,blink, CHANGE);
- lcd.begin();
- lcd.backlight();
- }
- void loop() {
- //lcd.clear();
- if (digitalRead(6)) P=0;
- lcd.setCursor(0,0);
- lcd.print("P=");
- lcd.print(P);
- lcd.print(" "); // 13 затирающих пробелов
- M=(P/7.2)/10; // (360*4) 1440/360=7,2
- lcd.setCursor(0,1);
- lcd.print("M=");
- lcd.print(M);
- lcd.print("cm "); // 8 затирающих пробелов
- }
- void blink1(){
- A=digitalRead(2);
- B=digitalRead(3);
- if (B==A) P=P+1;
- else P=P-1;
- }
- void blink(){
- A=digitalRead(2);
- B=digitalRead(3);
- if (B!=A) P=P+1;
- else P=P-1;
- }
Advertisement
RAW Paste Data
Copied
Advertisement