#include "LedControl.h"
#include "CuteBuzzerSounds.h"
LedControl lc = LedControl(7, 6, 5, 1);
const int pin1 = 8; // Pin cyfrowy 2
const int pin2 = 9; // Pin cyfrowy 3
const int pin3 = 10; // Pin cyfrowy 4
const int pin4 = 11; // Pin cyfrowy 5
const int pin5 = 12; // Pin cyfrowy 6
int i=0;
int a=10;
int b=15;
int c=20;
int d=50;
int e=100;
#define BUZZER_PIN 3
void setup() {
// put your setup code here, to run once:
lc.shutdown(0,false);
lc.setIntensity(0, 2);
lc.clearDisplay(0);
cute.init(BUZZER_PIN);
Serial.begin(9600);
pinMode(pin1, INPUT_PULLUP);
pinMode(pin2, INPUT_PULLUP);
pinMode(pin3, INPUT_PULLUP);
pinMode(pin4, INPUT_PULLUP);
pinMode(pin5, INPUT_PULLUP);
}
void printNumber3 (long number){
byte digits [8] = {0, 0, 0, 0, 0, 0, 0, 0,};
for (int i; i<8;i++) {
digits [i] = number % 10;
number = number /10;
}
bool firstNonZeroFound = false;
for (int i=7; i>=0; i--){
if (digits[i] !=0) {
firstNonZeroFound = true;
}
if (firstNonZeroFound) {
lc.setDigit(0,i,digits[i], false);
}
}
}
void loop(){
lc.clearDisplay(0);
printNumber3(i);
if (digitalRead(pin1) == LOW || digitalRead(pin2) == LOW || digitalRead(pin3) == LOW || digitalRead(pin4) == LOW || digitalRead(pin5) == LOW || i>0 ) {
int sensorVal3 = digitalRead(pin3);
//print out the value of the pushbutton
Serial.println(sensorVal3);
if (sensorVal3 == HIGH) {
}
else{
i=i+c;
printNumber3(c);
cute.play(S_MODE1);
delay(200);
}
int sensorVal4 = digitalRead(pin4);
//print out the value of the pushbutton
Serial.println(sensorVal4);
if (sensorVal4 == HIGH) {
}
else{
i=i+d;
printNumber3(d);
cute.play(S_MODE2);
delay(200);
}
int sensorVal5 = digitalRead(pin5);
//print out the value of the pushbutton
Serial.println(sensorVal5);
if (sensorVal5 == HIGH) {
}
else{
i=i+e;
printNumber3(e);
cute.play(S_MODE3);
delay(200);
}
int sensorVal1 = digitalRead(pin1);
//print out the value of the pushbutton
Serial.println(sensorVal1);
if (sensorVal1 == HIGH) {
}
else{
i=i+a;
cute.play(S_CONNECTION);
delay(50);
}
int sensorVal2 = digitalRead(pin2);
//print out the value of the pushbutton
Serial.println(sensorVal2);
if (sensorVal2 == HIGH) {
}
else{
i=i+b;
cute.play(S_DISCONNECTION);
delay(50);
}
}
else {
lc.setRow(0,7,B00011101);
lc.setRow(0,6,B00000000);
lc.setRow(0,5,B01111110);
lc.setRow(0,4,B01100111);
lc.setRow(0,3,B01001111);
lc.setRow(0,2,B01110110);
lc.setRow(0,1,B00000000);
lc.setRow(0,0,B01100011);
delay(10);
}
}