Arduino

 Arduino is a small yet mighty microcontroller board that serves as the brain for countless DIY projects. It's like the conductor of an orchestra, directing various electronic components to play together harmoniously. With its user-friendly interface and vast community support, Arduino makes it easy for anyone, regardless of their skill level, to bring their ideas to life and create interactive gadgets, robots, and more.


BLUETOOTH CONTROL CAR

Introducing our Arduino Bluetooth Control Car – a fun project that lets you drive a car with your smartphone! Using Arduino and Bluetooth, you can wirelessly control the car's movements. Just send commands like "forward" or "left" from your phone, and watch your car go! It's perfect for learning about electronics and programming while having a blast.

SOURCE CODE:

#include<AFMotor.h>
#define motor 10
#define Speed 250

char value;
int ledfront=12;
int ledback=11;
int buzzer=10;

AF_DCMotor M1(1);
AF_DCMotor M2(2);
AF_DCMotor M3(3);
AF_DCMotor M4(4);
void setup()
{
   Serial.begin(9600);
  pinMode(ledfront, OUTPUT);
  pinMode(ledback, OUTPUT);
  pinMode(buzzer, OUTPUT);

  M1.setSpeed(Speed);
  M2.setSpeed(Speed);
  M3.setSpeed(Speed);
  M4.setSpeed(Speed);
}

void loop() 
{
  Bluetoothcontrol();
}

void Bluetoothcontrol()
{
  if(Serial.available()>0)
  {
    value=Serial.read();
    Serial.println(value);
  }

  if(value=='F')
  {
    forward();
  }
  else if(value=='B')
  {
    backward();
  }
   else if(value=='L')
  {
    left();
  }
   else if(value=='R')
  {
    right();
  }
   else if(value=='S')
  {
    stop();
  }
  else if(value=='W')
  {
    digitalWrite(ledfront, HIGH);
  }
  else if(value=='w')
  {
    digitalWrite(ledfront, LOW);
  }
  else if(value=='U')
  {
    digitalWrite(ledback, HIGH);
  }
  else if(value=='u')
  {
    digitalWrite(ledback, LOW);
  }
  else if(value=='V')
  {
    digitalWrite(buzzer, HIGH);  
  }
  else if(value=='v')
  {
    digitalWrite(buzzer, LOW);
  }
}
void forward()
{
  M1.run(FORWARD);
  M2.run(FORWARD);
  M3.run(FORWARD);
  M4.run(FORWARD);
}
void backward()
{
  M1.run(BACKWARD);
  M2.run(BACKWARD);
  M3.run(BACKWARD);
  M4.run(BACKWARD);
}
void right()
{
  M1.run(BACKWARD);
  M2.run(BACKWARD); 
  M3.run(FORWARD);
  M4.run(FORWARD);
}
void left()
{
  M1.run(FORWARD);
  M2.run(FORWARD);
  M3.run(BACKWARD);
  M4.run(BACKWARD);
}
void stop()
{
  M1.run(RELEASE);
  M2.run(RELEASE);
  M3.run(RELEASE);
  M4.run(RELEASE);
}

Automatic street light controller (using ldr)

"Automatic street light controller" in which the light intensity of street light control according to the intensity of the sun light.

Source code:

int ldr  = A5;

int ldr_value;

int light=3;


void setup(){

  

 pinMode(light,OUTPUT); //Bulb

 pinMode(ldr,INPUT);  // Ldr

  

}


void loop(){

  

 ldr_value = analogRead(ldr);

  

  if(ldr_value>512)

    digitalWrite(light,LOW);// if there is sunlight light is off

  else

    digitalWrite(light,HIGH); // else on

  

}




Home automation using sensors:

Arduino Home Automation System – a smart way to control household appliances with ease. By incorporating sensors like PIR, LDR, and temperature sensors, this project automatically activates devices like fans and lights based on environmental conditions.

Source code:

float x, y, z, temp;

void setup() {
  // Set pin modes
  pinMode(8, INPUT);    // PIR sensor
  pinMode(5, OUTPUT);   // Fan
  pinMode(6, OUTPUT);   // Light
  pinMode(A5, INPUT);   // LDR sensor
  pinMode(A4, INPUT);   // Temperature sensor
  Serial.begin(9600);   // Start serial communication
}

void loop() {
  // Read sensor values
  x = digitalRead(8);   // Read PIR sensor
  y = analogRead(A5);   // Read LDR sensor
  z = analogRead(A4);   // Read temperature sensor
  
  // Print sensor values to serial monitor
  Serial.println(x);
  Serial.println(y);
  Serial.println(z);
  
  // Convert temperature sensor reading to Celsius
  temp = (double)z / 1024;     // Convert to voltage
  temp = temp * 5;              // Convert to Celsius
  temp = temp - 0.5;            // Adjust offset
  temp = temp * 100;            // Convert to Celsius
  
  // Control appliances based on sensor readings
  if (x > 0) {  // If motion detected
    if (y < 550 && temp > 30) {  // If dark and temperature high
      digitalWrite(5, HIGH);     // Turn on fan
      digitalWrite(6, HIGH);     // Turn on light
    } else if (y < 550 && temp < 30) {  // If dark and temperature low
      digitalWrite(5, HIGH);     // Turn on fan
      digitalWrite(6, LOW);      // Turn off light
    } else if (y > 550 && temp > 30) {  // If light and temperature high
      digitalWrite(5, LOW);      // Turn off fan
      digitalWrite(6, HIGH);     // Turn on light
    } else if (y > 550 && temp < 30) {  // If light and temperature low
      digitalWrite(5, LOW);      // Turn off fan
      digitalWrite(6, LOW);      // Turn off light
    }
  } else {  // If no motion detected
    digitalWrite(5, LOW);   // Turn off fan
    digitalWrite(6, LOW);   // Turn off light
  }
}





Digital clock:

Build a digital clock with Arduino and an LCD screen. It starts at 12 PM and displays the time in hours, minutes, and seconds. No fancy libraries, just simple code.

Source code:

#include <LiquidCrystal.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

unsigned long previousMillis = 0;
const long interval = 1000; // Update interval (1 second)

int hours = 12; // Start hour
int minutes = 0; // Start minute
int seconds = 0; // Start second

void setup() {
  
  lcd.begin(16, 2);// Initialize LCD
}

void loop() {
  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= interval) {
    
    previousMillis = currentMillis;

    // Update time
    seconds++;
    if (seconds >= 60) {
      seconds = 0;
      minutes++;
      if (minutes >= 60) {
        minutes = 0;
        hours++;
        if (hours >= 24) {
          hours = 0; // Reset hours after 24 hours
        }
      }
    }

    // Display time on LCD
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Time: ");
    printDigits(hours);
    lcd.print(":");
    printDigits(minutes);
    lcd.print(":");
    printDigits(seconds);

    
    lcd.setCursor(0, 1);
    lcd.print("      HH:MM:SS");// "HH:MM:SS" on the second line
  }
}

void printDigits(int digits) {
  // Print leading 0 if less than 10
  if (digits < 10)
    lcd.print('0');
  lcd.print(digits);
}





Comments

Popular Posts