Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // RTI_RGB = 0x40, RTI_PAL = 0x45, RTI_NTSC = 0x4C, RTI_OFF = 0x46
- // brightness levels 0x20, 0x61, 0x62, 0x23, 0x64, 0x25, 0x26, 0x67, 0x68, 0x29, 0x2A, 0x2C, 0x6B, 0x6D, 0x6E, 0x2F
- #define R_PIN 3
- #define AUTO_CLOSE_PIN 5
- #define SERIAL_SWITCH_PIN 4
- bool zpatecka_on = false;
- int x=0;
- void setup()
- {
- Serial.begin(2400);
- //nastavi pin na 1
- pinMode(R_PIN, INPUT_PULLUP);
- attachInterrupt(digitalPinToInterrupt(R_PIN), preruseni, CHANGE);
- }
- void loop()
- {
- if (zpatecka_on == true){
- zpateckaOn();
- if (digitalRead(AUTO_CLOSE_PIN) == LOW){
- x==1;
- }
- }
- else
- {
- zpateckaOff();
- }
- }
- void preruseni()
- {
- //if (zpatecka_on == false){
- if (digitalRead(R_PIN) == HIGH)
- {
- zpatecka_on = true;
- }
- else
- {
- zpatecka_on=false;
- }
- }
- void zpateckaOn()
- {
- rtiWrite(0x4C);
- rtiWrite(0x6B);
- rtiWrite(0x83);
- digitalWrite(SERIAL_SWITCH_PIN, HIGH);
- }
- void zpateckaOff()
- {
- // Kod po vyrazeni zpatecky
- if (digitalRead(AUTO_CLOSE_PIN) == HIGH)
- {
- rtiWrite(0x46);
- rtiWrite(0x6B);
- rtiWrite(0x83);
- digitalWrite(SERIAL_SWITCH_PIN, LOW);
- }
- else if (digitalRead(AUTO_CLOSE_PIN) == LOW and x==1)
- {
- rtiWrite(0x40);
- rtiWrite(0x6B);
- rtiWrite(0x83);
- digitalWrite(SERIAL_SWITCH_PIN, LOW);
- x==0;
- }
- }
- void rtiWrite(char byte) {
- Serial.print(byte);
- delay(100);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement