Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <IRremote.h>
- #include<MsTimer2.h>
- #define Ssymbol 4
- #define digit1 5
- #define digit2 6
- #define RECV_PIN 7
- #define RELAY 8
- #define buzzer 13
- #define clock A4
- #define data A5
- IRrecv irrecv(RECV_PIN);
- decode_results results;
- unsigned long key_value = 0;
- int count = 0;
- byte zero = B00010010;
- byte one = B11011110;
- byte two = B00010101;
- byte three = B10010100;
- byte four = B11011000;
- byte five = B10110000;
- byte six = B00110000;
- byte seven = B11010110;
- byte eight = B00010000;
- byte nine = B11010000;
- byte clrs = B11111111;
- byte night = B00000001;
- byte timer = B11111110;
- byte Digit[] = {B00010010, B11011110, B00010101, B10010100, B11011000, B10110000, B00110000, B11010110, B00010000, B11010000};
- byte symbol[] = {B00000001, B11111110};
- int i, j;
- int DELAY = 5;
- int unit, tens;
- void setup() {
- Serial.begin(9600);
- irrecv.enableIRIn();
- irrecv.blink13(false);
- pinMode(clock, OUTPUT);
- pinMode(data , OUTPUT);
- pinMode(digit1, OUTPUT);
- pinMode(digit2, OUTPUT);
- pinMode(RELAY, OUTPUT);
- pinMode(buzzer, OUTPUT);
- MsTimer2::set(5, setDigit_);
- MsTimer2::start();
- }
- void loop() {
- if (irrecv.decode(&results)) {
- if (results.value == 0XFFFFFFFF)
- results.value = key_value;
- if (results.value == 0x8800347) {
- Serial.println("Button 1");
- beep();
- unit = 8;
- tens = 8;
- }
- if (results.value == 0x88C0051) {
- Serial.println("Button 2");
- beep();
- unit = 0;
- tens = 0;
- }
- if (results.value == 0x88C000C) {
- Serial.println("Button 3");
- beep();
- digitalWrite(RELAY, HIGH);
- unit = 6;
- tens = 6;
- }
- key_value = results.value;
- irrecv.resume();
- }
- }
- int setDigit_() {
- // int unit, tens;
- // unit = D % 10;
- // tens = D / 10;
- Serial.println("SET DIGIT");
- digitalWrite(digit2, LOW);
- shiftOut(data, clock, LSBFIRST, Digit[tens]);
- digitalWrite(digit1, HIGH);
- delay(DELAY);
- digitalWrite(digit1, LOW);
- shiftOut(data, clock, LSBFIRST, Digit[unit]);
- digitalWrite(digit2, HIGH);
- delay(DELAY);
- }
- int beep() {
- digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
- delay(100); // wait for a second
- digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
- delay(100);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement