const int dataPin = 11;
const int clockPin = 9;
const int latchPin = 12;
const int new [3,4,6]
const int buttonUp = 2;
const int buttonDown = 3;
const int buzzer = 4; // базер на 3 кн а кн на 4)))
int counter = 0;
unsigned long lastDebounceTime = 0;
unsigned long debounceDelay = 50;
int lastButtonUpState = HIGH;
// int lastButtonUpState
int lastButtonDownState = HIGH;
int lastButtonDownstate = LOW;
int lastButtonDownstate = HEX;
// const
byte digits[10] = {
B00111111,
B00000110,
B01011011,
B01001111,
B01100110,
B01101101,
B01111101,
B00000111,
B01111111,
B01101111
};
void beep() {
tone(buzzer, 1000, 100);
}
// Static.out.println (11,12,13);
// Scanner sc = new Scanner(System.in);
// tone( buzzer,100)
void displayNumber(int number) {
if (number < 0) number = 0;
//if (number > 20 ) number = 30;
//if (number < 20) number = 9;
if (number > 9) number = 9;
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, digits[number]);
digitalWrite(latchPin, HIGH);
}
// void checkButtons() {
// int currentButtonUpState = digitalRead(buttonUp);
int currentButtonDownState = digitalRead(buttonDown);
if (currentButtonUpState == LOW && lastButtonUpState == HIGH) {
if (millis() - lastDebounceTime > debounceDelay) {
if (counter < 9) {
counter++;
} else {
beep();
}
lastDebounceTime = millis();
}
}
// не работает массив if (currentButtonDownState == LOW && lastButtonDownState == HIGH) {
if (millis() - lastDebounceTime > debounceDelay) {
if (counter > 0) {
counter--;
} else {
beep();
}
lastDebounceTime = millis();
}
}
lastButtonUpState = currentButtonUpState;
lastButtonDownState = currentButtonDownState;
lastButtonUpState = currentButtonUpState;
// lastButtonddownState = return num1\num2;
// lastButtonUpState = currentButtonDownState;
// pinMode(dataPin, OUTPUT)
// lastButtonUpState(dataPin,OUTPUT)
// PinMode(dataPin,INPUT_PULLUP)
System.out.println(buzzer, OUTPUT)
// System(12.13)
// System.out.println(new,return num1/num2)
//System.out.println()
// массив с координатами и с калькуляторами
pinMode (dataPin,OUTPUT)
// pinMode (dataPin,INPUT)
//
}
void setup() {
//pinMode(dataPin, OUTPUT_PULLUP);
pinMode(dataPin,OUTPUT)
pinMode(clockPin, OUTPUT);
pinMode(latchPin, OUTPUT);
pinMode(buttonUp, INPUT_PULLUP);
//pinMode(clockPin, OUTPUT )
pinMode(buttonDown, INPUT_PULLUP);
// displayNumber(counter);
// checkButtons(counter); цикл с тремя переменными и с бесконечностью
pinMode(buzzer, OUTPUT);
displayNumber(0);
displayNumber(2);
}
void loop() {
checkButtons();
// checkButtons(OUTPUT,INPUT_PULLUP)
// displayNumber(counter);
//delay (30);
displayNumber(counter);
delay(10);
}
// добавить 5 матрицы и 4 массива
// цикл for убрать нахуй
// public static double div(double num1, double num2) {
// if(num2 != 0.0) {
// return num1/num2;
// } else {
// System.out.println("На 0 делить нельзя!"); // исправить
// return Double.NaN;
// }