Ticker

6/recent/ticker-posts

Arduino Basic Project 6

 Arduino Basic Project 6

Welcome to the Technical Praveen, In this article, we will figure out how to make a few essentials venture with arduino at home. in the event that you wanna figure out how to make it deliberately read the full article. this is the most intriguing and mainstream venture these days in hardware and designing, a considerable lot of the understudies from school a lot making this amazing undertaking. instructions to make circuit outline and how to compose the code. 


Beginning 


Before you can begin working with Arduino, you need to ensure you have the IDE programming introduced on your PC. This program permits you to compose, see and transfer the code to your Arduino Uno board. You can download the IDE for nothing through my site. 


When the IDE is introduced, you should associate your Arduino to your PC. To do this, plug one finish of the USB link to the Arduino Uno and afterward the opposite finish of the USB to your PC's USB port.

Select The Board

Once the board is plugged in, you will need to open the IDE and click on Tools > Board > Arduino Uno to select the board.



Select Serial Port

Next, you have to tell the Arduino which port you are using on your computer.  To select the port, go to Tools > Port and then select the port that says Arduino.


NOW THE TWELFTH PROJECT BEGINS

12) Tone Melody

The project will use a piezo buzzer/speaker to play a little melody.

Parts Needed

  • (1) Arduino Uno
  • (1) USB A-to-B Cable
  • (1) Breadboard – Half Size
  • (1) Piezo Buzzer/Speaker
  • (2) Jumper Wires

Project Diagram


Project Code

#include "pitches.h"


// notes in the melody:

int melody[] = {

  NOTE_C4, NOTE_G3, NOTE_G3, NOTE_A3, NOTE_G3, 0, NOTE_B3, NOTE_C4

};


// note durations: 4 = quarter note, 8 = eighth note, etc.:

int noteDurations[] = {

  4, 8, 8, 4, 4, 4, 4, 4

};


void setup() {

  // iterate over the notes of the melody:

  for (int thisNote = 0; thisNote < 8; thisNote++) {


    // to calculate the note duration, take one second

    // divided by the note type.

    //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.

    int noteDuration = 1000 / noteDurations[thisNote];

    tone(8, melody[thisNote], noteDuration);


    // to distinguish the notes, set a minimum time between them.

    // the note's duration + 30% seems to work well:

    int pauseBetweenNotes = noteDuration * 1.30;

    delay(pauseBetweenNotes);

    // stop the tone playing:

    noTone(8);

  }

}


void loop() {

  // no need to repeat the melody.

}

NOW THE THIRTEENTH PROJECT BEGINS

13) Servo

In this project, you will be able to sweep a servo back and forth through its full range of motion.

Parts Needed

  • (1) Arduino Uno
  • (1) USB A-to-B Cable
  • (1) Breadboard – Half Size
  • (1) Servo
  • (6) Jumper Wires

Project Diagram



Project Code

#include <Servo.h>  // servo library



Servo servo1;  // servo control object



void setup()

{


  servo1.attach(9, 900, 2100);  //Connect the servo to pin 9

//with a minimum pulse width of

//900 and a maximum pulse width of

//2100. 


}



void loop()

{

  int position;

  

  // To control a servo, you give it the angle you'd like it

  // to turn to. Servos cannot turn a full 360 degrees, but you

  // can tell it to move anywhere between 0 and 180 degrees.


  // Change position at full speed:


  servo1.write(90);    // Tell servo to go to 90 degrees


  delay(1000);         // Pause to get it time to move


  servo1.write(180);   // Tell servo to go to 180 degrees


  delay(1000);         // Pause to get it time to move


  servo1.write(0);     // Tell servo to go to 0 degrees


  delay(1000);         // Pause to get it time to move

  

 

// Tell servo to go to 180 degrees, stepping by two degrees each step

 

  for(position = 0; position < 180; position += 2)

  {

    servo1.write(position);  // Move to next position

    delay(20);               // Short pause to allow it to move

  }


  // Tell servo to go to 0 degrees, stepping by one degree each step


  for(position = 180; position >= 0; position -= 1)

  {                                

    servo1.write(position);  // Move to next position

    delay(20);               // Short pause to allow it to move

  }

}

NOW THE FOURTEENTH PROJECT BEGINS

14) Motor

Using a switching transistor, we will be able to control a DC motor.  If everything is connected correctly, you should see the motor spinning.

Parts Needed

  • (1) Arduino Uno
  • (1) USB A-to-B Cable
  • (1) Breadboard – Half Size
  • (1) DC Motor
  • (1) 330 Î© Resistor
  • (1) Diode 1N4148
  • (1) NPN Transistor
  • (6) Jumper Wires

Project Diagram


Project Code

const int motorPin = 9;  // Connect the base of the transistor to pin 9.

                         // Even though it's not directly connected to the motor,

                         // we'll call it the 'motorPin'


void setup()

{

  pinMode(motorPin, OUTPUT);  // set up the pin as an OUTPUT

  Serial.begin(9600);         // initialize Serial communications

}



void loop()

{ // This example basically replicates a blink, but with the motorPin instead.

  int onTime = 3000;  // milliseconds to turn the motor on

  int offTime = 3000; // milliseconds to turn the motor off


  analogWrite(motorPin, 255); // turn the motor on (full speed)

  delay(onTime);                // delay for onTime milliseconds

  analogWrite(motorPin, 0);  // turn the motor off

  delay(offTime);               // delay for offTime milliseconds


  // Uncomment the functions below by taking out the //. Look below for the

  // code examples or documentation.

  

  // speedUpandDown(); 

  // serialSpeed();

}


// This function accelerates the motor to full speed,

// then decelerates back down to a stop.

void speedUpandDown()

{

  int speed;

  int delayTime = 20; // milliseconds between each speed step


  // accelerate the motor

  for(speed = 0; speed <= 255; speed++)

  {

    analogWrite(motorPin,speed); // set the new speed

    delay(delayTime);            // delay between speed steps

  }

  // decelerate the motor

  for(speed = 255; speed >= 0; speed--)

  {

    analogWrite(motorPin,speed); // set the new speed

    delay(delayTime);            // delay between speed steps

  }

}



// Input a speed from 0-255 over the Serial port

void serialSpeed()

{

  int speed;


  Serial.println("Type a speed (0-255) into the box above,");

  Serial.println("then click [send] or press [return]");

  Serial.println();  // Print a blank line


  // In order to type out the above message only once,

  // we'll run the rest of this function in an infinite loop:


  while(true)  // "true" is always true, so this will loop forever.

  {

    // Check to see if incoming data is available:

    while (Serial.available() > 0)

    {

      speed = Serial.parseInt();  // parseInt() reads in the first integer value from the Serial Monitor.

      speed = constrain(speed, 0, 255); // constrains the speed between 0 and 255

                                        // because analogWrite() only works in this range.


      Serial.print("Setting speed to ");  // feedback and prints out the speed that you entered.

      Serial.println(speed);


      analogWrite(motorPin, speed);  // sets the speed of the motor.

    }

  }

}

NOW THE FIFTEENTH PROJECT BEGINS

15) LCD Screen

An LCD is a liquid crystal display that is able to display text on its screen.  In this project, you should see the words “hello,world!” displayed on the screen.  The potentiometer is used to adjust the contrast of the display.

Parts Needed

  • (1) Arduino Uno
  • (1) USB A-to-B Cable
  • (1) Breadboard – Half Size
  • (1) LCD Screen
  • (1) Potentiometer
  • (16) Jumper Wires
Project Diagram


Project Code

// Load the LiquidCrystal library, which will give us
// commands to interface to the LCD:

#include <LiquidCrystal.h>

// Initialize the library with the pins we're using.
// (Note that you can use different pins if needed.)
// See http://arduino.cc/en/Reference/LiquidCrystal
// for more information:

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()
{

lcd.begin(16, 2); //Initialize the 16x2 LCD


lcd.clear(); //Clear any old data displayed on the LCD


lcd.print("hello, world!"); // Display a message on the LCD!


}

void loop()
{

lcd.setCursor(0, 1); //Set the (invisible) cursor to column 0,
// row 1.

lcd.print(millis() / 1000); //Print the number of seconds
//since the Arduino last reset.
}

Post a Comment

0 Comments