Skip to main content

Posts

Showing posts from August, 2020

How To Make HC-05 Bluetooth Controlled Car With Arduino UNO|Topped With Fun(With Code And Diagram)

Circuit Diagram:- Code:- #include <AFMotor.h> //initialising motors pin AF_DCMotor motor1(1, MOTOR12_1KHZ);  AF_DCMotor motor2(2, MOTOR12_1KHZ);  AF_DCMotor motor3(3, MOTOR34_1KHZ); AF_DCMotor motor4(4, MOTOR34_1KHZ); char command;  void setup()  {          Serial.begin(9600);  //Set the baud rate to your Bluetooth module. } void loop(){   if(Serial.available() > 0){      command = Serial.read();      Stop(); //initialize with motors stoped     //Change pin mode only if new command is different from previous.        //Serial.println(command);     switch(command){     case 'F':         forward();       break;     case 'B':          back();       break;     case 'L':         left();       break;   ...

Obstacle Avoiding Car With L298N Motor Driver(With Code And Circuit)|Autonomous Car|Topped With Fun

  Circuit Diagram:- Code:- //Topped With Fun #include <Servo.h>              //Library To Include Servo motor #include <NewPing.h>        //Library To Include Ultrasonic Sensor Do  Install This Library //To Control L298N Driver Pins const int LeftMotorForward = 7; const int LeftMotorBackward = 6; const int RightMotorForward = 4; const int RightMotorBackward = 5; //sensor pins #define trig_pin A1    //Analog Input 1 #define echo_pin A2  //Analog Input 2 #define maximum_distance 200 boolean goesForward = false; int distance = 100; NewPing sonar(trig_pin, echo_pin, maximum_distance); //sensor function Servo servo_motor;   //Defining Name For Servo Motor void setup(){   pinMode(RightMotorForward, OUTPUT);   pinMode(LeftMotorForward, OUTPUT);   pinMode(LeftMotorBackward, OUTPUT);   pinMode(RightMotorBackward, OUTPUT);      servo_motor.attach(12);  ...

Basic LDR Project With Arduino UNO(With Code And Diagram)|Topped With Fun|Basic Arduino UNO Project

  Circuit Diagram: Code:- //set pin numbers const int ledPin = 13; const int buzzerPin = 12; const int ldrPin = A5; void setup () {   Serial.begin(9600);   pinMode(ledPin, OUTPUT);   pinMode(buzzerPin, OUTPUT);   pinMode(ldrPin, INPUT); } void loop() {   int ldrStatus = analogRead(ldrPin);  //read the state of the LDR value   if (ldrStatus >= 400) {     tone(buzzerPin, 100);     digitalWrite(ledPin, HIGH);     delay(100);     noTone(buzzerPin);     digitalWrite(ledPin, LOW);     delay(100);     Serial.println("----------- ALARM ACTIVATED -----------");    }   else {     noTone(buzzerPin);     digitalWrite(ledPin, LOW);     Serial.println("ALARM DEACTIVATED");   } }

How To Control LED With IR Remote And Arduino UNO|Topped With Fun|Basic Arduino UNO Project With LED

    Circuit Diagram: IR Decoder:- #include <IRremote.h> int IRpin = 2; IRrecv irrecv(IRpin); decode_results results; void setup() { Serial.begin(9600); irrecv.enableIRIn(); // Start the receiver } void loop() { if (irrecv.decode(&results)) { Serial.println(results.value, DEC); // Print the Serial ‘results.value’ irrecv.resume(); // Receive the next value } } IR Conroller:- #include <IRremote.h>              //Includes IR Library int RECV_PIN = 2;                   //IR Receiver Pin IRrecv irrecv(RECV_PIN); decode_results results; #define BUTTON_1 0x1            //Paste Code Of 1st Button #define BUTTON_2 0x2           //Paste Code Of 2nd Button #define BUTTON_3 0x3          //Paste Code Of 3rd Button #define BUTTON_0 0x33       //Paste Code Of 4th Button #define BUTTON_OK 0x...

How To Make Automatic Light Controller | PIR Motion Sensor |How To Use Motion Sensor|Topped With Fun

Code:- //the time we give the sensor to calibrate (10-60 secs according to the datasheet) int calibrationTime = 30;         //the time when the sensor outputs a low impulse long unsigned int lowIn;          //the amount of milliseconds the sensor has to be low  //before we assume all motion has stopped long unsigned int pause = 1000;   boolean lockLow = true; boolean takeLowTime;   int pirPin = 3;    //the digital pin connected to the PIR sensor's output int ledPin = 13; ///////////////////////////// //SETUP void setup(){   Serial.begin(9600);   pinMode(pirPin, INPUT);   pinMode(ledPin, OUTPUT);   digitalWrite(pirPin, LOW);   //give the sensor some time to calibrate   Serial.print("calibrating sensor ");     for(int i = 0; i < calibrationTime; i++){       Serial.print(".");       delay(1000);       }     Se...

How To Use LCD Display With Arduino UNO|Basic Programming With Arduino Uno And LCD|Topped With Fun

    Code:- / include the library code: #include <LiquidCrystal.h> // initialize the library by associating any needed LCD interface pin // with the arduino pin number it is connected to const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; LiquidCrystal lcd(rs, en, d4, d5, d6, d7); void setup() {   // set up the LCD's number of columns and rows:   lcd.begin(16, 2);   // Print a message to the LCD.   lcd.print("hello, world!"); } void loop() {   // Turn off the blinking cursor:   lcd.noBlink();   delay(3000);   // Turn on the blinking cursor:   lcd.blink();   delay(3000); }

How To Make Radar System Using Arduino UNO|Ultrasonic Sensor Project|Topped With Fun|Radar System

  Code:   // Includes the Servo library #include <Servo.h> // Defines Tirg and Echo pins of the Ultrasonic Sensor const int trigPin = 10; const int echoPin = 11; // Variables for the duration and the distance long duration; int distance; Servo myServo; // Creates a servo object for controlling the servo motor void setup() {   pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output   pinMode(echoPin, INPUT); // Sets the echoPin as an Input   Serial.begin(9600);   myServo.attach(12); // Defines on which pin is the servo motor attached } void loop() {   // rotates the servo motor from 15 to 165 degrees   for(int i=15;i<=165;i++){     myServo.write(i);   delay(30);   distance = calculateDistance();// Calls a function for calculating the distance measured by the Ultrasonic sensor for each degree      Serial.print(i); // Sends the current degree into the Serial Port   Serial.print(","); // Sends a...

Distance Indicator|Basic Arduino Uno Project|Basic Ultrasonic Sensor Projects|Topped With Fun

    Circuit Diagram:   Code: #include <Servo.h> #include <NewPing.h> const int ServoPin = 10; const int TriggerPin = 6; const int EchoPin = 7; // 100 = maxDistance NewPing sonar (TriggerPin, EchoPin, 100); Servo servo; void setup() {   Serial.begin(9600);   servo.attach(ServoPin); } void loop() {   int cm = sonar.ping_cm();   Serial.println(cm);   int angle = map(cm, 2, 15, 15, 100);   servo.write(angle);   delay(50); }

Basic Arduino Uno Project With Ultrasonic|Topped With Fun|Ultrasonic Project With Arduino Uno

Circuit Diagram: Code:   #include <NewPing.h> const int trig = 11; const int echo = 12; const int LED1 = 2; const int LED2 = 3; const int LED3 = 4; const int LED4 = 5; const int LED5 = 6; const int LED6 = 7; const int LED7 = 8; int duration = 0; int distance = 0; void setup() {   pinMode(trig , OUTPUT);   pinMode(echo , INPUT);     pinMode(LED1 , OUTPUT);   pinMode(LED2 , OUTPUT);   pinMode(LED3 , OUTPUT);   pinMode(LED4 , OUTPUT);   pinMode(LED5 , OUTPUT);   pinMode(LED6 , OUTPUT);   pinMode(LED7 , OUTPUT);     Serial.begin(9600); } void loop() {   digitalWrite(trig , HIGH);   delayMicroseconds(1000);   digitalWrite(trig , LOW);   duration = pulseIn(echo , HIGH);   distance = (duration/2) / 28.5 ;   Serial.println(distance);     if ( distance <= 6 )  //Adjust The Distance Here   {     digitalWrite(LED1, HIGH);   }   else   {     ...