Friday, 5 May 2023

Arduino tutorial



 Machine to program the way you wanted to do

Four Ds of robots

Dirty – they live in the drainage system. Its called snake robots.


 


Luxury

Education

Entertainment



 What make them smart

Sensors

AI

Micro controls

Brain inside the watch

NI and ML programs are there in the phone

Light  works on switch on/off . smart light – sensor – on when there is someone in the house. Motion control smart lights.

There is audrino microcontrols

For doing it

We can use the led to do it

Main voltage we can connect

Relay =

 

 

Audriono only 5 volts

We use at home  240 volts

Using relay we can Multiply it to 240 volts signal .

Relay we give small signal and house voltage then it can work for the outside house



 

 Day one  finish here

 




autonomous robot

 

Fire sensor,

Smoke sensor

Robot to think

Body part to action

Foundation of any robot

They have to understand this 3 concept

 GOD gives this organ to us and we are god to robots and we can use this


 







40 to 60 sensors are there 


Development board

Digital

Anolog

 

Power

Usb

Introduce lights

2 main things

How to use the board

Programming basic


there is a logic and sequence


Empty brain without program

Making it intelligent to use program

 



Long = positive

Short = negative

Physical, mental and learn ur science  and maths

Concepts

Electrons  flow is current

Electrons flows there is push needed , push is given by voltage which is the potential

Current need to flow its needs a push which need a voltage

To glow the light we need a current, when there is flow of electrons only then it will on, but this needs a potential difference.

We always need a positive and negative terminals

Positive, negative, neutral. Potential difference, only then the electric flows in circuit

Led = uni direction device

If its not working it means that they haven’t

 

GND = low potential

Negative connect to  gnd

GND is automatically set to low

Prev release

Download 1.8.13

 

void setup() {

// put your setup code here, to run once:

//input and output device  declare

//what pin it is used - 13 pin we have connected a device. this device is a output device, so u have to give signal. input device, ardinuo will take the signal.

//temp sensor, input device, which pin it should get the input

//led = we can give only on/off. led is a output device.

// commandable device, it can get the cammand and execute

//cmd device = output device

//sensors are input device

//motors, leds = output device, actutators are o/p device

//light sensor = input device

//dont need to mention ground

 

pinMode(13,OUTPUT);

 

 

 

}

 

void loop() {

  // put your main code here, to run repeatedly:

  //all execution will be written here.

  //2 mode - digital, analog both can used for  any device

  //digital = contains 2 state, high state = on, low state = off

  digitalWrite(13,HIGH);

  //analog contains main operations

 

}

 

Input range Analog signal

0-1023

Output range analog singal = 0,255

0-      On

255 – off state




Project 1:

LED Blink

void setup() {

// put your setup code here, to run once:

//input and output device  declare

//what pin it is used - 13 pin we have connected a device. this device is a output device, so u have to give signal. input device, ardinuo will take the signal.

//temp sensor, input device, which pin it should get the input

//led = we can give only on/off. led is a output device.

// commandable device, it can get the cammand and execute

//cmd device = output device

//sensors are input device

//motors, leds = output device, actutators are o/p device

//light sensor = input device

//dont need to mention ground

 

pinMode(13,OUTPUT);

 

 

 

}

 

void loop() {

  // put your main code here, to run repeatedly:

  //all execution will be written here.

  //2 mode - digital, analog both can used for  any device

  //digital = contains 2 state, high state = on, low state = off

  digitalWrite(13,HIGH);

  delay(1000);//1000ms for 1 sec

  digitalWrite(13,LOW);

  delay(1000);//1000ms for 1 sec

  //analog contains main operations

 

}

Project 2:

Blinking challenges

LED speed control

How to make it blink fast

 

Project 3:

Multiple Device

Traffic control

Red,green,orange led

 

Jumper wires

Men end

Female end

Male to male

Female to female

Male to female

Avoid 0 and 1 pins it is used for serial communication

 

Project 4:

2 leds

Alternative leds

1 led

2 leds

Alternative leds blinking

Simultaneously blinking on both leds

Final project

Happy Birthday

Wave pin works for both digital and analog. PWM pulse width modulation



SET negative pins to grn

void setup() {

  // put your setup code here, to run once:

  pinMode(11,OUTPUT);

  pinMode(10,OUTPUT);

}

 

void loop() {

  // put your main code here, to run repeatedly:

  analogWrite(11,250);

  analogWrite(10,250);

  delay(1500);

   analogWrite(11,50);

  analogWrite(10,50);

    delay(1500);

 

}

 

Make  digital pin to ground

void setup() {

  // put your setup code here, to run once:

  pinMode(11,OUTPUT);

  pinMode(10,OUTPUT);

  pinMode(13,OUTPUT);

  pinMode(8,OUTPUT);

}

 

void loop() {

  // put your main code here, to run repeatedly:

  analogWrite(11,250);

  analogWrite(10,250);

  analogWrite(13,0);

  analogWrite(8,0);

 

  delay(1500);

 

  analogWrite(11,50);

  analogWrite(10,50);

  analogWrite(8,0);

  analogWrite(13,0);

 

  delay(1500);

 

}

 

Combined digital and analog

void setup() {

  // put your setup code here, to run once:

  pinMode(11,OUTPUT);

  pinMode(10,OUTPUT);

  pinMode(13,OUTPUT);

  pinMode(8,OUTPUT);

}

 

void loop() {

  // put your main code here, to run repeatedly:

  digitalWrite(11,HIGH);

  analogWrite(10,250);

  analogWrite(13,LOW);

  analogWrite(8,0);

 

  delay(1500);

 

  analogWrite(11,HIGH);

  analogWrite(10,50);

  analogWrite(8,0);

  analogWrite(13,LOW);

 

  delay(1500);

 

}

 

RGB = 16m colors


 

https://www.w3schools.com/colors/colors_picker.asp

 



 

rgb(102, 204, 255)

 

two modes


common cathode – long leg - grn

common anode – long leg to 5v

 

void setup() {

  // put your setup code here, to run once:

  pinMode(11,OUTPUT);//red

  pinMode(10,OUTPUT);//Green

  pinMode(9,OUTPUT);//blue

 

 

}

 

void loop() {

  // put your main code here, to run repeatedly:

  // rgb(0, 204, 0) from html color picker - green

  analogWrite(11,0);

  analogWrite(10,204);

  analogWrite(9,0);

 

  delay(1500);

    // rgb(51, 102, 204)  from html color picker - blue

  analogWrite(11,51);

  analogWrite(10,102);

  analogWrite(9,204);

 

  delay(1500);

 

}

 

Sensor



Turn on or turn off -> digital

Ac temperature reduce – analog

 

DIGITAL INPUTS & ANALOG INPUTS


 infra red sensor it detects objects

it generates ir rays. It transmits the rays and it reflects back

0 and 1

0 -> didn’t receive the rays

1-> bounce back to the sensor

 

There is a screw we can adjust to get the distance of the object

Sometimes it will not sense

Interface

Vcc  - positive power – 5volts

Grn - -ve power

//embedded c

 

//bulgar alarm

//car reverse camera

//remote car and put a reverse camera

void setup() {

  // put your setup code here, to run once:

  //ir sensor , gnd connect to arduino grd, vcc to 5v, output to 9 digital

  pinMode(9,INPUT); //sensor out put should always be in 9

  //buzzer

  //small leg to grd, long leg to 11 

  pinMode(11,OUTPUT);//buzzer output

 

  Serial.begin(9600); //serail monitor it starts, it used for outpu the logs in the monitor.for all sensor we need to use it

 

}

 

void loop() {

  // put your main code here, to run repeatedly:

  //variable declaration

  int irSensor = 0; // fresh begining

  irSensor = digitalRead(9); //extract the value

  Serial.println("Sensor value:"); // to differntiate the the above sennor

  Serial.println(irSensor); // values need to be passed.

  //sometimes the 0 will be make the buzzer sound or else 1 will make the bazzer sound

  if(irSensor == LOW)

  {

    digitalWrite(11,HIGH);

    

  }

  else

  {

    digitalWrite(11,LOW);

  }

}

 

//to get the power always use 9v batter

 

 

Sensor -> ultra sonic - > 2 eyes sensor

Object detection

Ultra sonic ways is used to detects the objects

Bats uses ultra sonic ways

One eye is transamittor

Receiveor receives the ways

 1 & 0 is the output

 

Digital mode receives 0 an  1 mode

 

 

Bread board

Rows and column first and last row is called rows, when we give 5v to a row the whole row Is 5v

Columns is in the middle part and when we give 5v to column the entire column will get 5v

+ - positive

-ve Is ground

 

Motors

Two Types

1.       DC

a.       Continues spin. Example fan, juice, ginder,

b.      Clock wise and other one is anti clock wise

c.       ++ - anti clock

d.      -- -> clock

e.       Test the spin using just motor and fan with 9v battery

f.        Cars mortors – go reverse  change motor polarity

g.       Obstacle avoid car – if there is a obstacle then it reverse and then turn different directions

h.      How to do it automatically? There is a switching device to change from direct to reverse direction

i.        3 to 6 v or it make need 9 v

2.       Server

a.       Goes to a particular angle

3.       Stepper

a.       clock

it takes electric input and gives mechanical output

 

Arduino can give for small devices (on/off) program signal – its weak signal

It cannot give power to motor

So for that we need a bridge circuit or motor driver

This is used between motor and Arduino

Motor driver – gets the Arduino weak signal and change it to super power and amplify to motor (change weak to strong signal)

IC -> chip l293d

Two usages

è power amplify

è change the direction of motor (to change the bidirectionly switching the direction of motor spin

è connects 2 motors  (use both side of the ic) or can connect only one motor

è one motor we select any side, both sides are identical

è there are 16 pins

è if we connect one motor then use one side 8 pins

è ex: we give weak signal input1/output1 and then output2/ input2

è one motor got 2 terminal so we have 2 o/p and 2 i/p

Enable:

è Give 5v  to make it active on that direction

è Give -ve to GRN

VS :

è  keeps the IC alive -> to give 5v

è Give -ve to GRN

Input 1 & input 2:

è Arduino signal

Output 1 & output 2 :

è Motor

 

 

Top and bottom pin give 5v

Middle two ground

Motor gots 2 terminal


Servo Motor


#include <Servo.h>


Servo wipper;


void setup() {

  wipper.attach(10); 

  

}


void loop() {

  // put your main code here, to run repeatedly:

  wipper.write(180);

  delay(1000);

  wipper.write(0);

  delay(1000);

}

Tools

Snap4arduino

Mbot

Critile



Bread board

Rows and column first and last row is called rows, when we give 5v to a row the whole row Is 5v

Columns is in the middle part and when we give 5v to column the entire column will get 5v

+ - positive

-ve Is ground

 

Motors

Two Types

1.       DC

a.       Continues spin. Example fan, juice, ginder,

b.      Clock wise and other one is anti clock wise

c.       ++ - anti clock

d.      -- -> clock

e.       Test the spin using just motor and fan with 9v battery

f.        Cars mortors – go reverse  change motor polarity

g.       Obstacle avoid car – if there is a obstacle then it reverse and then turn different directions

h.      How to do it automatically? There is a switching device to change from direct to reverse direction

i.        3 to 6 v or it make need 9 v

2.       Server

a.       Goes to a particular angle

3.       Stepper

a.       clock

it takes electric input and gives mechanical output

 

Arduino can give for small devices (on/off) program signal – its weak signal

It cannot give power to motor

So for that we need a bridge circuit or motor driver

This is used between motor and Arduino

Motor driver – gets the Arduino weak signal and change it to super power and amplify to motor (change weak to strong signal)

IC -> chip l293d

Two usages

è power amplify

è change the direction of motor (to change the bidirectionly switching the direction of motor spin

è connects 2 motors  (use both side of the ic) or can connect only one motor

è one motor we select any side, both sides are identical

è there are 16 pins

è if we connect one motor then use one side 8 pins

è ex: we give weak signal input1/output1 and then output2/ input2

è one motor got 2 terminal so we have 2 o/p and 2 i/p

Enable:

è Give 5v  to make it active on that direction

è Give -ve to GRN

VS :

è  keeps the IC alive -> to give 5v

è Give -ve to GRN

Input 1 & input 2:

è Arduino signal

Output 1 & output 2 :

è Motor

 

 

Top and bottom pin give 5v

Middle two ground

Motor gots 2 terminal

 

 

 

Water level sensor (this only works in water)

è Liquid level detection

è Fuel indicator

è Oil indicator

è Flood indication system

è Can be used for Dam water level

è L293d

è Water motor – contains dc motor,

è Fan

è Motor when its on, the fan with rotate

è Centricpetal, centrifugal

o   Centripetal force is the force REQUIRED for circular motion. 

o   Centrifugal force is the force that makes something flee from the center.

o   Dc motor – centrifugal force

o   Pumping one place to another place

o   Water comes from reservoir to house

è Project

Check the water level ina  container

Low- on red light

Medium-orange

Green-full

If its red then turn on the water pump

And when the light is green then stop the water pump

Or use the delay of 2 secs then stop the water pump

 

Equipment

§  Red, green , orange (3) leds

§  Bump

§  L293d

§  Water sensor

 

 

https://www.elprocus.com/h-bridge-motor-control-circuit-using-l293d-ic/

 

 

 

 

 

 

5v

5v

arduino

Arduino – pin 5

motor

motor

gnd

gnd

gnd

gnd

motor

motor

arduino

Arduino – pin 6

5v

5v

 

 

 

 

 

 

 

 

Arduino

 

RGB – Cathod – long leg – 5v

RGB – pwd 11,10,9

Water sensor

Gnd

Positive

Input – A0 – Arduino

 

 

Home work

 

Soil monitor sensors

Take measurements of soil

 

Motors – servo motors

Takes input and give mechanical motors

Dc motors – spins for motors (0-360) where we need to spin

Precise movement and move to particular angle that action we need a special motors (0 to 180 degree). It used to for angle movement.

Example: toll gate open from  0 to 80 degrees then it come back to 0 degrees

What happens if use dc motor 

No comments:

Post a Comment