Download our official Android App in PlayStore. Click Here
You can get the all the required files (like Circuit Diagram, Arduino.ino file, Libraries Used, and others) for the project in ZIP format and much more...
In this Project, we will see about how to interface IR Receiver TSOP 1838 with Arduino.
Circuit Diagram:
Arduino Code:
simple_led_control_code.ino
//This Code is Developed by Sdev//Follow Us Here : https://youtube.com/sdevelectronics#include<IRremote.h>intRECV_PIN=11;IRrecvirrecv(RECV_PIN);decode_resultsresults;voidsetup(){Serial.begin(9600);Serial.println("Enabling IRin");irrecv.enableIRIn();// Start the receiverSerial.println("Enabled IRin");pinMode(3,OUTPUT);}voidloop(){if(irrecv.decode(&results)){Serial.println(results.value,HEX);if(results.value==0x80BF21DE){//ondigitalWrite(3,HIGH);}if(results.value==0x80BF916E){//OFFdigitalWrite(3,LOW);}irrecv.resume();// Receive the next value}delay(100);}
rgb_led_control_code.ino
//This Code is Developed by Sdev//Follow Us Here : https://youtube.com/sdevelectronics#include<IRremote.h>#defineRED9#defineGREEN10#defineBLUE11intRECV_PIN=8;IRrecvirrecv(RECV_PIN);decode_resultsresults;voidsetup(){Serial.begin(9600);Serial.println("Enabling IRin");irrecv.enableIRIn();Serial.println("Enabled IRin");pinMode(3,OUTPUT);}voidloop(){if(irrecv.decode(&results)){Serial.println(results.value,HEX);if(results.value==0x80BF916E){//REDanalogWrite(RED,255);analogWrite(GREEN,0);analogWrite(BLUE,0);}if(results.value==0x80BF21DE){//GREENanalogWrite(RED,0);analogWrite(GREEN,255);analogWrite(BLUE,0);}if(results.value==0x80BF9B64){//YELLOWanalogWrite(RED,128);analogWrite(GREEN,128);analogWrite(BLUE,0);}if(results.value==0x80BF6996){//BLUEanalogWrite(RED,0);analogWrite(GREEN,0);analogWrite(BLUE,255);}if(results.value==0x80BF3BC4){//OFFanalogWrite(RED,0);analogWrite(GREEN,0);analogWrite(BLUE,0);}irrecv.resume();// Receive the next value}delay(100);}
Download our official Android App in PlayStore. Click Here
You can get the all the required files (like Circuit Diagram, Arduino.ino file, Libraries Used, and others) for the project in ZIP format and much more...
In this Project, we will see about how to interface Ultrasonic Sensor with Arduino .
Circuit Diagram:
Arduino Code:
ultrasonic_simple_code.ino
//This Code is Developed by Sdev//Follow Us Here : https://youtube.com/sdevelectronics#defineechoPin13#definetrigPin12longduration,distance;voidsetup(){Serial.begin(9600);pinMode(trigPin,OUTPUT);pinMode(echoPin,INPUT);}voidloop(){digitalWrite(trigPin,LOW);delayMicroseconds(2);digitalWrite(trigPin,HIGH);delayMicroseconds(10);duration=pulseIn(echoPin,HIGH);distance=duration/58.2;Serial.println(distance);delay(100);}
ultrasonic_condition_code.ino
//This Code is Developed by Sdev//Follow Us Here : https://youtube.com/sdevelectronics#defineechoPin13#definetrigPin12#definered8#definegreen7longduration,distance;voidsetup(){Serial.begin(9600);pinMode(trigPin,OUTPUT);pinMode(red,OUTPUT);pinMode(green,OUTPUT);pinMode(echoPin,INPUT);}voidloop(){digitalWrite(trigPin,LOW);delayMicroseconds(2);digitalWrite(trigPin,HIGH);delayMicroseconds(10);duration=pulseIn(echoPin,HIGH);distance=duration/58.2;Serial.println(distance);if(distance<10){digitalWrite(red,HIGH);digitalWrite(green,LOW);}else{digitalWrite(red,LOW);digitalWrite(green,HIGH);}delay(100);}
Download our official Android App in PlayStore. Click Here
You can get the all the required files (like Circuit Diagram, Arduino.ino file, Libraries Used, and others) for the project in ZIP format and much more...
In this Project, we will see about how to make Calculator with Arduino & TFT Touch Display.
Circuit Diagram:
Just Install TFT Touch Display Shield to Arduino
Arduino Code:
tft_calculator_code.ino
#include<Adafruit_GFX.h>#include<MCUFRIEND_kbv.h>MCUFRIEND_kbvtft;#include<TouchScreen.h>constintXP=7,XM=A1,YP=A2,YM=6;//ID=0x7789#defineBLACK0x0000#defineRED0xF800#defineCYAN0x07FF#definePINK0xF81F#defineYELLOW0xFFE0#defineWHITE0xFFFF#defineMINPRESSURE10#defineMAXPRESSURE1000#defineTS_MINX199#defineTS_MINY947#defineTS_MAXX913#defineTS_MAXY191TouchScreents=TouchScreen(XP,YP,XM,YM,300);//300 is the sensitivityStringsymbol[4][4]={{"7","8","9","/"},{"4","5","6","*"},{"1","2","3","-"},{"C","0","=","+"}};intX,Y;longNum1,Num2,Number;charaction;booleanresult=false;voidsetup(){Serial.begin(9600);//Use serial monitor for debuggingtft.reset();tft.begin(0x7789);//Change ID, it varies with other TFT Displaystft.setRotation(0);// Portraittft.fillScreen(BLACK);IntroScreen();delay(3000);draw_BoxNButtons();}voidloop(){TSPointp=waitTouch();Y=p.y;X=p.x;DetectButtons();if(result==true)CalculateResult();DisplayResult();delay(300);}TSPointwaitTouch(){TSPointp;do{p=ts.getPoint();pinMode(XM,OUTPUT);pinMode(YP,OUTPUT);}while((p.z<MINPRESSURE)||(p.z>MAXPRESSURE));p.x=map(p.x,TS_MINX,TS_MAXX,0,240);p.y=map(p.y,TS_MINY,TS_MAXY,0,320);;returnp;}voidDetectButtons(){if(X<60&&X>0){//Detecting Buttons on Column 1if(Y>260&&Y<320){//If cancel Button is pressedSerial.println("Button Cancel");Number=Num1=Num2=0;result=false;}if(Y>200&&Y<260){//If Button 1 is pressedSerial.println("Button 1");if(Number==0)Number=1;elseNumber=(Number*10)+1;//Pressed twice}if(Y>140&&Y<200){//If Button 4 is pressedSerial.println("Button 4");if(Number==0)Number=4;elseNumber=(Number*10)+4;//Pressed twice}if(Y>80&&Y<140){//If Button 7 is pressedSerial.println("Button 7");if(Number==0)Number=7;elseNumber=(Number*10)+7;//Pressed twice}}if(X<120&&X>60){//Detecting Buttons on Column 2if(Y>260&&Y<320){Serial.println("Button 0");//Button 0 is Pressedif(Number==0)Number=0;elseNumber=(Number*10)+0;//Pressed twice}if(Y>200&&Y<260){Serial.println("Button 2");if(Number==0)Number=2;elseNumber=(Number*10)+2;//Pressed twice}if(Y>140&&Y<200){Serial.println("Button 5");if(Number==0)Number=5;elseNumber=(Number*10)+5;//Pressed twic}if(Y>80&&Y<140){Serial.println("Button 8");if(Number==0)Number=8;elseNumber=(Number*10)+8;//Pressed twic}}if(X<180&&X>120){//Detecting Buttons on Column 3if(Y>260&&Y<320){Serial.println("Button Equal");Num2=Number;result=true;}if(Y>200&&Y<260){Serial.println("Button 3");if(Number==0)Number=3;elseNumber=(Number*10)+3;//Pressed twice}if(Y>140&&Y<200){Serial.println("Button 6");if(Number==0)Number=6;elseNumber=(Number*10)+6;//Pressed twice}if(Y>80&&Y<140){Serial.println("Button 9");if(Number==0)Number=9;elseNumber=(Number*10)+9;//Pressed twice}}if(X<240&&X>180){//Detecting Buttons on Column 3Num1=Number;Number=0;tft.setCursor(200,20);tft.setTextColor(CYAN);if(Y>260&&Y<320){Serial.println("Addition");action=1;tft.println('+');}if(Y>200&&Y<260){Serial.println("Subtraction");action=2;tft.println('-');}if(Y>140&&Y<200){Serial.println("Multiplication");action=3;tft.println('*');}if(Y>80&&Y<140){Serial.println("Division");action=4;tft.println('/');}delay(300);}}voidCalculateResult(){if(action==1)Number=Num1+Num2;if(action==2)Number=Num1-Num2;if(action==3)Number=Num1*Num2;if(action==4)Number=Num1/Num2;}voidDisplayResult(){tft.fillRect(0,0,240,80,RED);//clear result boxtft.setCursor(10,20);tft.setTextSize(4);tft.setTextColor(WHITE);tft.println(Number);//update new value}voidIntroScreen(){tft.setCursor(55,90);tft.setTextSize(3);tft.setTextColor(YELLOW);tft.println("ARDUINO");tft.setCursor(30,130);tft.println("CALCULATOR");tft.setCursor(60,190);tft.setTextSize(2);tft.setTextColor(WHITE);tft.println("modified by");tft.setCursor(40,220);tft.setTextSize(4);tft.setTextColor(CYAN);tft.println("STAYSAY");}voiddraw_BoxNButtons(){//Draw the Result Boxtft.fillRect(0,0,240,80,RED);//Draw First Columntft.fillRect(0,260,60,60,CYAN);//ctft.fillRect(0,200,60,60,WHITE);//1tft.fillRect(0,140,60,60,WHITE);//4tft.fillRect(0,80,60,60,WHITE);//7//Draw Third Columntft.fillRect(120,260,60,60,PINK);//=tft.fillRect(120,200,60,60,WHITE);//3tft.fillRect(120,140,60,60,WHITE);//6tft.fillRect(120,80,60,60,WHITE);//9//Draw Secound & Fourth Columnfor(intb=260;b>=80;b-=60){tft.fillRect(180,b,60,60,YELLOW);//4th columntft.fillRect(60,b,60,60,WHITE);//2nd column}//Draw Horizontal Linesfor(inth=80;h<=320;h+=60)tft.drawFastHLine(0,h,240,BLACK);//Draw Vertical Linesfor(intv=0;v<=240;v+=60)tft.drawFastVLine(v,80,240,BLACK);//Display keypad lablesfor(intj=0;j<4;j++){for(inti=0;i<4;i++){tft.setCursor(22+(60*i),100+(60*j));tft.setTextSize(3);tft.setTextColor(BLACK);tft.println(symbol[j][i]);}}}
Download our official Android App in PlayStore. Click Here
You can get the all the required files (like Circuit Diagram, Arduino.ino file, Libraries Used, and others) for the project in ZIP format and much more...