Posts

 https://drive.google.com/drive/folders/1bwqc8yVLyAsiLjVYNsDJAdCsaqxihFxf https://drive.google.com/drive/folders/1bwqc8yVLyAsiLjVYNsDJAdCsaqxihFxf

4 DIRECTION TRAFFIC LIGHT

Image
                                                                  CODE:- int red1 = 13; int yellow1 = 12; int green1 = 11; int red2 = 10; int yellow2 = 9; int green2 = 8; int red3 = 7; int yellow3 = 6; int green3 = 5; int red4 = 4; int yellow4 = 3; int green4 = 2; void setup() {   for(int i = 2; i<=13; i++) {     pinMode(i, OUTPUT);   } } void loop() {    direction(red1, yellow1, green1, red2, yellow2, green2, red3, yellow3, green3, red4, yellow4, green4);   direction(red2, yellow2, green2, red1, yellow1, green1, red3, yellow3, green3, red4, yellow4, green4);   direction(red3, yellow3, green3, red1, yellow1, green1, red2, yellow2, green2, red4, yellow4, green4);   direction(red4, yellow4, green4, red1, yellow1, green1, red2, yellow2, green2, red3, yellow3, green3); } void direc...

POSITIVE LOGIC AND NEGATIVE LOGIC SWITCH TINKERCAD

Image
  CODE:- void setup() {   pinMode(2, INPUT);   pinMode(8, INPUT);            } void loop() {   int x = digitalRead(2);     int y = digitalRead(8);      }

PWM TINKERCAD

Image
  CODE:- void setup() { pinMode(3,OUTPUT);   pinMode(7,OUTPUT);   Serial.begin(9600); } void loop() { for(int THREE=0,NINE=255;THREE<=255,NINE>=0;THREE++,NINE--) { analogWrite(3,THREE);       Serial.print("GREEN=");   Serial.println(THREE);     analogWrite(9,NINE);    Serial.print("RED=");   Serial.println(NINE);      delay(100); } }

ADC TINKERCAD

Image
  CODE:- // C++ code // void setup() {   pinMode(A0, INPUT);   pinMode(2,OUTPUT);   pinMode(4,OUTPUT);   pinMode(8,OUTPUT);   Serial.begin(9600); } void loop() {   int x=analogRead(A0);   if(x>=100&&x<=300){     digitalWrite(4,LOW);     digitalWrite(2,HIGH);      digitalWrite(8,LOW);   }      else if(x<=600&&x>=300){      digitalWrite(8,LOW);     digitalWrite(2,LOW);     digitalWrite(4,HIGH);             }         else if(x>=600&&x>=800){      digitalWrite(2,LOW);     digitalWrite(4,LOW);     digitalWrite(8,HIGH);   }           Serial.println(x); }

COMBINATION OF TEMPERATURE ,PIR AND ULTRASONIC SENSORS

Image
  CODE:- int sensorPin = A0; //int sensor = 2;              // the pin that the sensor is atteched to int val = 0; #define echoPin 8 // attach pin D2 Arduino to pin Echo of HC-SR04 #define trigPin 3 //attach pin D3 Arduino to pin Trig of HC-SR04 // defines variables long duration; // variable for the duration of sound wave travel int distance; void setup(){   pinMode(sensorPin,INPUT);//temp   pinMode (2,INPUT);//pir   pinMode(trigPin, OUTPUT); // Sets the trigPin as an OUTPUT   pinMode(echoPin, INPUT);    pinMode(4, OUTPUT);   pinMode(5, OUTPUT);   pinMode(6, OUTPUT);   Serial.begin(9600);  } void loop() {        int adcData = analogRead(sensorPin);   float voltage = (adcData)*(5.0/1024)*1000; float temperatureC = (voltage - 500)/10 ;  //converting from 10 mv per degree with 500 mV offset      //to degrees ((voltage - 500mV)/10) Serial.print("adcDat...

KEYPAD WITHOUT LIBRARY

Image
  int c1 = 7, c2 = 6, c3 = 5, c4 = 4; int r1 = 13, r2 = 12,r3 = 11, r4 = 10;  void setup(){   pinMode(c1, INPUT_PULLUP);    pinMode(c2, INPUT_PULLUP);    pinMode(c3, INPUT_PULLUP);    pinMode(c4, INPUT_PULLUP);       pinMode(r1, OUTPUT);    pinMode(r2, OUTPUT);   pinMode(r3, OUTPUT);    pinMode(r4, OUTPUT);      digitalWrite(r1, HIGH);   digitalWrite(r2, HIGH);   digitalWrite(r3, HIGH);   digitalWrite(r4, HIGH);      Serial.begin(38400); } void loop() {   row1();   row2();   row3();   row4();   //Serial.println(" Press any Key to see the value:"); } void row1() {   digitalWrite(r1, LOW);   digitalWrite(r2, HIGH);   digitalWrite(r3, HIGH);   digitalWrite(r4, HIGH);   if(digitalRead(c1)== LOW){//pin 5     Serial.println("1");     delay(600);}   else if(digitalRead(c2)== LOW){//pin 4 ...