NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

//WHITE - D4
//BLACK - D2
//BROWN - 5V
//BLUE - GND
#include <IRremote.h>

#define TK19_PIN 11
#define LeftSaveLed 8
#define LeftWarningLed 3
#define GoingLeft 9
#define GoingRight 5
#define RightWarningLed 6
#define RightSaveLed 7

#define left 0xFF10EF
#define right 0xFF5AA5
#define ok 0xFF38C
#define leftControl 0xFFA25D
#define rightControl 0xFFE21D
#define controlReset 0xFF629D

int leftSave = 0;
int rightSave = 0;
int rotaryData = 0;
int buttonState = 0;
int encoderPin1 = 2;
int encoderPin2 = 4;

volatile int lastEncoded = 0;
volatile long encoderValue = 0;

long lastencoderValue = 0;

IRrecv irrecv(TK19_PIN);
decode_results results;

void setup() {
Serial.begin (115200);
pinMode(encoderPin1, INPUT_PULLUP);
pinMode(encoderPin2, INPUT_PULLUP);
attachInterrupt(0, updateEncoder, FALLING);

irrecv.enableIRIn();
//#################################
pinMode(LeftSaveLed, OUTPUT);
pinMode(LeftWarningLed, OUTPUT);
pinMode(GoingLeft, OUTPUT);
pinMode(GoingRight, OUTPUT);
pinMode(RightWarningLed, OUTPUT);
pinMode(RightSaveLed, OUTPUT);
}

void buttonHafiza(decode_results pressed){
if(results.value == left){
buttonState = -1;
}
else if(results.value == right){
buttonState = 1;
}
}

void updateEncoder()
{
noInterrupts();
if(digitalRead(encoderPin2))
encoderValue++;
else
encoderValue--;
interrupts();
}

void loop(){
Serial.println(encoderValue);
delay(100);
if (irrecv.decode(&results)) {
buttonHafiza(results);
//----------------------- Control Blogu----------------------------
if(results.value == leftControl){
leftSave = rotaryData;
digitalWrite(LeftSaveLed,1);
}
else if(results.value == rightControl){
rightSave = rotaryData;
digitalWrite(RightSaveLed,1);
}
else if(results.value == controlReset ){
leftSave = 0;
rightSave = 0;
digitalWrite(LeftSaveLed,0);
digitalWrite(RightSaveLed,0);
}
//----------------------- Control End ------------------------------
irrecv.resume();
}
if(leftSave == 0 && rightSave == 0){ // Sola ve Sage Henuz kayıt yapılmadı istediği kadar gidebilir.
if(buttonState == -1){
digitalWrite(GoingLeft,1);
digitalWrite(GoingRight,0);
digitalWrite(RightWarningLed,0);
digitalWrite(LeftWarningLed,0);
updateEncoder();
}
else if(buttonState == 1){
digitalWrite(GoingLeft,0);
digitalWrite(GoingRight,1);
digitalWrite(RightWarningLed,0);
digitalWrite(LeftWarningLed,0);
updateEncoder();
}
}
else if(leftSave == 0 && rightSave != 0){ // Sola istediği kadar gidebilir Sag limite kadar.
if(buttonState == -1){
digitalWrite(GoingLeft,1);
digitalWrite(GoingRight,0);
digitalWrite(RightWarningLed,0);
digitalWrite(LeftWarningLed,0);
updateEncoder();
}
if(rotaryData < rightSave){
if(buttonState == 1){
digitalWrite(GoingLeft,0);
digitalWrite(GoingRight,1);
digitalWrite(RightWarningLed,0);
digitalWrite(LeftWarningLed,0);
updateEncoder();
}
}
else if(rotaryData == rightSave){
digitalWrite(GoingLeft,0);
digitalWrite(GoingRight,0);
digitalWrite(RightWarningLed,1);
digitalWrite(LeftWarningLed,0);
}
}
else if(leftSave != 0 && rightSave == 0){ // Sol limite kadar gidebilir Sag istediği kadar.
if(buttonState == 1){
digitalWrite(GoingLeft,0);
digitalWrite(GoingRight,1);
digitalWrite(RightWarningLed,0);
digitalWrite(LeftWarningLed,0);
updateEncoder();
}
if(rotaryData > leftSave){
if(buttonState == -1){
digitalWrite(GoingLeft,1);
digitalWrite(GoingRight,0);
digitalWrite(RightWarningLed,0);
digitalWrite(LeftWarningLed,0);
updateEncoder();
}
}
else if(rotaryData == leftSave){
digitalWrite(GoingLeft,0);
digitalWrite(GoingRight,0);
digitalWrite(RightWarningLed,0);
digitalWrite(LeftWarningLed,1);
}
}
else if(leftSave != 0 && rightSave != 0){ // Sol ve Sag limite kadar gidebilir.
if(rotaryData > leftSave){
if(buttonState == -1){
digitalWrite(GoingLeft,1);
digitalWrite(GoingRight,0);
digitalWrite(RightWarningLed,0);
digitalWrite(LeftWarningLed,0);
updateEncoder();
}
}
else if(rotaryData == leftSave){
digitalWrite(GoingLeft,0);
digitalWrite(GoingRight,0);
digitalWrite(RightWarningLed,0);
digitalWrite(LeftWarningLed,1);
}
if(rotaryData < rightSave){
if(buttonState == 1){
digitalWrite(GoingLeft,0);
digitalWrite(GoingRight,1);
digitalWrite(RightWarningLed,0);
digitalWrite(LeftWarningLed,0);
updateEncoder();
}
}
else if(rotaryData == rightSave){
digitalWrite(GoingLeft,0);
digitalWrite(GoingRight,0);
digitalWrite(RightWarningLed,1);
digitalWrite(LeftWarningLed,0);
}
}
Serial.println(rotaryData);
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.