Monday, 10 July 2017

Line follower using Arduino





int a = 4, b = 7, c = 8, d = 5, e = 6, f = 10, g = 11;
int s1, s2, s3;
void setup ()
{
  Serial.begin(9600);
  pinMode (a, INPUT);
  pinMode (b, INPUT);
  pinMode (c, INPUT);
  pinMode(d, OUTPUT);
  pinMode(e, OUTPUT);
  pinMode(f, OUTPUT);
  pinMode(g, OUTPUT);
}
void front()
{
  analogWrite(d, 110);
  analogWrite(e, 0);
  analogWrite(f, 110);
  analogWrite(g, 0);
}
void stp()
{
  analogWrite(d, 0);
  analogWrite(e, 0);
  analogWrite(f, 0);
  analogWrite(g, 0);
}
void right()
{
  analogWrite(d, 190);
  analogWrite(e, 0);
  analogWrite(f, 0);
  analogWrite(g, 0);
}
void left()
{
  analogWrite(d, 0);
  analogWrite(e, 0);
  analogWrite(f, 190);
  analogWrite(g, 0);
}
void loop()
{
  s1 = digitalRead(a);
  s2 = digitalRead(b);
  s3 = digitalRead(c);
  Serial.print(s1);
  Serial.print("   ");
  Serial.print(s2);
  Serial.print("   ");
  Serial.print(s3);
  Serial.println("   ");

  if ((s1 == LOW) && (s2 == HIGH) && (s3 == HIGH))
  {
    front();
  }
  if ((s1 == HIGH) && (s2 == LOW) && (s3 == HIGH))
  {
    right();
  }
  if ((s1 == LOW) && (s2 == LOW) && (s3 == HIGH))
  {
    right();
  }
  if ((s1 == HIGH) && (s2 == HIGH) && (s3 == LOW))
  {
    left();
  }
  if ((s1 == LOW) && (s2 == HIGH) && (s3 == LOW))
  {
    left();
  }
  if ((s1 == HIGH) && (s2 == HIGH) && (s3 == HIGH))
  {
    stp();
  }
  if ((s1 == LOW) && (s2 == LOW) && (s3 == LOW))
  {
    stp();
  }

}

Wednesday, 28 June 2017

light effect codes based on the previous light effect project





//try this arduino code
void setup()
{
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
}
void ring()
{
  digitalWrite(6,HIGH);
  digitalWrite(10,HIGH);
  digitalWrite(4,HIGH);
  digitalWrite(2,HIGH);
  digitalWrite(8,HIGH);
  delay(200);

  digitalWrite(10,LOW);
  digitalWrite(4,LOW);
  digitalWrite(2,LOW);
  digitalWrite(8,LOW);
  delay(200);
 
  digitalWrite(6,HIGH);
  digitalWrite(5,HIGH);
  digitalWrite(3,HIGH);
  digitalWrite(7,HIGH);
  digitalWrite(9,HIGH);
  delay(200);

  digitalWrite(5,LOW);
  digitalWrite(3,LOW);
  digitalWrite(7,LOW);
  digitalWrite(9,LOW);
  delay(200);

  digitalWrite(6,LOW);
 
}
void arr()
{
  digitalWrite(2, HIGH);
  delay(200);
  digitalWrite(3, HIGH);
  delay(200);
  digitalWrite(4, HIGH);
  delay(200);
  digitalWrite(5, HIGH);
  delay(200);
  digitalWrite(6, HIGH);
  delay(200);
  digitalWrite(7, HIGH);
  delay(200);
  digitalWrite(8, HIGH);
  delay(200);
  digitalWrite(9, HIGH);
  delay(200);
  digitalWrite(10, HIGH);
  delay(200);
  digitalWrite(10, LOW);
  delay(200);
  digitalWrite(9, LOW);
  delay(200);
  digitalWrite(8, LOW);
  delay(200);
  digitalWrite(7, LOW);
  delay(200);
  digitalWrite(6, LOW);
  delay(200);
  digitalWrite(5, LOW);
  delay(200);
  digitalWrite(4, LOW);
  delay(200);
  digitalWrite(3, LOW);
  delay(200);
  digitalWrite(2, LOW);
  delay(200);
}
void rot()
{
  digitalWrite(6, HIGH);
  delay(250);
  digitalWrite(8, HIGH);
  delay(200);
  digitalWrite(8, LOW);
  delay(150);
 
  digitalWrite(7, HIGH);
  delay(200);
  digitalWrite(7, LOW);
  delay(150);

  digitalWrite(2, HIGH);
  delay(200);
  digitalWrite(2, LOW);
  delay(150);
 
  digitalWrite(3, HIGH);
  delay(200);
  digitalWrite(3, LOW);
  delay(150);

  digitalWrite(4, HIGH);
  delay(200);
  digitalWrite(4, LOW);
  delay(150);

  digitalWrite(5, HIGH);
  delay(200);
  digitalWrite(5, LOW);
  delay(150);

  digitalWrite(10, HIGH);
  delay(300);
  digitalWrite(10, LOW);
  delay(150);

  digitalWrite(9, HIGH);
  delay(300);
  digitalWrite(9, LOW);
  delay(150);

  digitalWrite(5,LOW);
 
}

void race()
{
 
  digitalWrite(8, HIGH);
  digitalWrite(7, HIGH);
  digitalWrite(2, HIGH);
  delay(300);
  digitalWrite(9, HIGH);
  digitalWrite(6, HIGH);
  digitalWrite(3, HIGH);
  delay(300);
  digitalWrite(10, HIGH);
  digitalWrite(5, HIGH);
  digitalWrite(4, HIGH);
  delay(300);
  digitalWrite(8, LOW);
  digitalWrite(7, LOW);
  digitalWrite(2, LOW);
  delay(300);
  digitalWrite(9, LOW);
  digitalWrite(6, LOW);
  digitalWrite(3, LOW);
  delay(300);
  digitalWrite(10, LOW);
  digitalWrite(5, LOW);
  digitalWrite(4, LOW);
  delay(300);
}
void dia()
{
  digitalWrite(4,HIGH);
  delay(90);
  digitalWrite(5,HIGH);
  digitalWrite(3,HIGH);
  delay(90);
  digitalWrite(10,HIGH);
  digitalWrite(6,HIGH);
  digitalWrite(2,HIGH);
  delay(90);
  digitalWrite(9,HIGH);
  digitalWrite(7,HIGH);
  delay(90);
  digitalWrite(8,HIGH);
  delay(150);
 
  digitalWrite(4,LOW);
  delay(90);
  digitalWrite(5,LOW);
  digitalWrite(3,LOW);
  delay(90);
  digitalWrite(10,LOW);
  digitalWrite(6,LOW);
  digitalWrite(2,LOW);
  delay(90);
  digitalWrite(9,LOW);
  digitalWrite(7,LOW);
  delay(90);
  digitalWrite(8,LOW);
  delay(150);
 
 
 
 
}
void loop()
{
  ring();
  ring();
  ring();
  arr();
  arr();
  arr();
  rot();
  rot();
  rot();
  race();
  race();
  race();
  dia();
  dia();
  dia();
  delay(500);
}

Light effects on a light bulb with Arduino

This post is about DIY light effect with Arduino



This is the DIY project we are gonna make
COMPONENTS
  • Arduino and Parts for Arduino
  • 9 light bulbs with low power consumption(i used low power LED)
  • some wires
the circuit is not complex, just the parallel connection,


the circuit will be much easy if we use a diode,
I will upload another post on that.







  • Connect the pins as shown in the circuit diagram 
  • use an external power supply for Arduino (since the USB is not enough for 9 bulbs)


//this is the Arduino code 
//the code is simple and it is easy to understand

void setup()// the setup function runs once when you press reset or power the board
{
   // initialize digital pins as an output.
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
}
void one()//since the code is huge seperate functions are used which is later called in loop function
{
  digitalWrite(4,HIGH);
  delay(90);
  digitalWrite(5,HIGH);
  digitalWrite(3,HIGH);
  delay(90);
  digitalWrite(10,HIGH);
  digitalWrite(6,HIGH);
  digitalWrite(2,HIGH);
  delay(90);
  digitalWrite(9,HIGH);
  digitalWrite(7,HIGH);
  delay(90);
  digitalWrite(8,HIGH);
  delay(150);
  
  digitalWrite(4,LOW);
  delay(90);
  digitalWrite(5,LOW);
  digitalWrite(3,LOW);
  delay(90);
  digitalWrite(10,LOW);
  digitalWrite(6,LOW);
  digitalWrite(2,LOW);
  delay(90);
  digitalWrite(9,LOW);
  digitalWrite(7,LOW);
  delay(90);
  digitalWrite(8,LOW);
  delay(150);
}
void six()//since the code is huge seperate functions are used which is later called in loop function
{
  digitalWrite(8, HIGH);
  digitalWrite(7, HIGH);
  digitalWrite(2, HIGH);
  delay(90);
  digitalWrite(9, HIGH);
  digitalWrite(6, HIGH);
  digitalWrite(3, HIGH);
  delay(90);
  digitalWrite(10, HIGH);
  digitalWrite(5, HIGH);
  digitalWrite(4, HIGH);
  delay(90);
  digitalWrite(8, LOW);
  digitalWrite(7, LOW);
  digitalWrite(2, LOW);
  delay(90);
  digitalWrite(9, LOW);
  digitalWrite(6, LOW);
  digitalWrite(3, LOW);
  delay(90);
  digitalWrite(10, LOW);
  digitalWrite(5, LOW);
  digitalWrite(4, LOW);
  delay(150);
}
void two()
{
  digitalWrite(10, HIGH);
  digitalWrite(5, HIGH);
  digitalWrite(4, HIGH);
  delay(90);
  digitalWrite(9, HIGH);
  digitalWrite(6, HIGH);
  digitalWrite(3, HIGH);
  delay(90);
  digitalWrite(8, HIGH);
  digitalWrite(7, HIGH);
  digitalWrite(2, HIGH);
  delay(90);
  digitalWrite(10, LOW);
  digitalWrite(5, LOW);
  digitalWrite(4, LOW);
  delay(90);
  digitalWrite(9, LOW);
  digitalWrite(6, LOW);
  digitalWrite(3, LOW);
  delay(90);
  digitalWrite(8, LOW);
  digitalWrite(7, LOW);
  digitalWrite(2, LOW);
  delay(150);
}
void three()//since the code is huge seperate functions are used which is later called in loop function
{
  digitalWrite(10,HIGH);
  delay(90);
  digitalWrite(5,HIGH);
  digitalWrite(9,HIGH);
  delay(90);
  digitalWrite(4,HIGH);
  digitalWrite(6,HIGH);
  digitalWrite(8,HIGH);
  delay(90);
  digitalWrite(3,HIGH);
  digitalWrite(7,HIGH);
  delay(90);
  digitalWrite(2,HIGH);
  delay(150);
  
  digitalWrite(10,LOW);
  delay(90);
  digitalWrite(5,LOW);
  digitalWrite(9,LOW);
  delay(90);
  digitalWrite(4,LOW);
  digitalWrite(6,LOW);
  digitalWrite(8,LOW);
  delay(90);
  digitalWrite(3,LOW);
  digitalWrite(7,LOW);
  delay(90);
  digitalWrite(2,LOW);
  delay(150);
}
void four()//since the code is huge seperate functions are used which is later called in loop function
{
  digitalWrite(10, HIGH);
  digitalWrite(9, HIGH);
  digitalWrite(8, HIGH);
  delay(90);
  digitalWrite(5, HIGH);
  digitalWrite(6, HIGH);
  digitalWrite(7, HIGH);
  delay(90);
  digitalWrite(4, HIGH);
  digitalWrite(3, HIGH);
  digitalWrite(2, HIGH);
  delay(90);
  digitalWrite(10, LOW);
  digitalWrite(9, LOW);
  digitalWrite(8, LOW);
  delay(90);
  digitalWrite(5, LOW);
  digitalWrite(6, LOW);
  digitalWrite(7, LOW);
  delay(90);
  digitalWrite(4, LOW);
  digitalWrite(3, LOW);
  digitalWrite(2, LOW);
  delay(150);
}
void five()//since the code is huge seperate functions are used which is later called in loop function
{
  digitalWrite(8,HIGH);
  delay(90);
  digitalWrite(7,HIGH);
  digitalWrite(9,HIGH);
  delay(90);
  digitalWrite(10,HIGH);
  digitalWrite(6,HIGH);
  digitalWrite(2,HIGH);
  delay(90);
  digitalWrite(3,HIGH);
  digitalWrite(5,HIGH);
  delay(90);
  digitalWrite(4,HIGH);
  delay(150);
   
  digitalWrite(8,LOW);
  delay(90);
  digitalWrite(7,LOW);
  digitalWrite(9,LOW);
  delay(90);
  digitalWrite(10,LOW);
  digitalWrite(6,LOW);
  digitalWrite(2,LOW);
  delay(90);
  digitalWrite(3,LOW);
  digitalWrite(5,LOW);
  delay(90);
  digitalWrite(4,LOW);
  delay(150);
}
void seven()//since the code is huge seperate functions are used which is later called in loop function
{
  digitalWrite(2,HIGH);
  delay(90);
  digitalWrite(7,HIGH);
  digitalWrite(3,HIGH);
  delay(90);
  digitalWrite(8,HIGH);
  digitalWrite(6,HIGH);
  digitalWrite(4,HIGH);
  delay(90);
  digitalWrite(9,HIGH);
  digitalWrite(5,HIGH);
  delay(90);
  digitalWrite(10,HIGH);
  delay(150);
  
  digitalWrite(2,LOW);
  delay(90);
  digitalWrite(7,LOW);
  digitalWrite(3,LOW);
  delay(90);
  digitalWrite(4,LOW);
  digitalWrite(6,LOW);
  digitalWrite(8,LOW);
  delay(90);
  digitalWrite(9,LOW);
  digitalWrite(5,LOW);
  delay(90);
  digitalWrite(10,LOW);
  delay(150);
}
void eight()//since the code is huge seperate functions are used which is later called in loop function
{
  digitalWrite(4,HIGH);
  digitalWrite(3, HIGH);
  digitalWrite(2, HIGH);
  delay(90);
  digitalWrite(5, HIGH);
  digitalWrite(6, HIGH);
  digitalWrite(7, HIGH);
  delay(90);
  digitalWrite(8, HIGH);
  digitalWrite(9, HIGH);
  digitalWrite(10, HIGH);
  delay(90);
  digitalWrite(4, LOW);
  digitalWrite(3, LOW);
  digitalWrite(2, LOW);
  delay(90);
  digitalWrite(5, LOW);
  digitalWrite(6, LOW);
  digitalWrite(7, LOW);
  delay(90);
  digitalWrite(8, LOW);
  digitalWrite(9, LOW);
  digitalWrite(10, LOW);
  delay(150);
}



void loop()// the loop function runs over and over again forever
{
  one();//functions are called here
  two();
  three();
  four();
  five();
  six();
  seven();
  eight();
  
}
//enjoy the light effects 
//i will upload several other Arduino codes i have written for light effects.





Tuesday, 27 June 2017

Arduino

Let's start with Arduino


    COMPONENTS NEEDED

  • Any Arduino board
  • Arduino IDE software
  • USB connector for your Arduino
This is a very simple project, this project is for beginners in electronic circuits and programming

Arduino is a simple to use microcontroller board, it is easy to use and do not need much experience in programming.

let's start with a simple example 

  • buy any Arduino based boards (i recommend you to buy Arduino Uno which is very cheap and you can replace the microcontroller if anything goes wrong)
  • download Arduino IDE software from Arduino official website (make sure that Java is installed on your computer)
  • plugin you Arduino board to your computer via USB

tools>Board> and select your board type (in my case it is Arduino Uno)


the COM port will be selected by the computer if not select it.


  • Arduino board will have a LED attached to its PIN 13, we will use that LED for this project
  • The code is already available in the examples.



if you open that it will be like this.



then just upload the program to you Arduino


after uploading you will the LED blinking for 1sec


The program has two parts first is the setup and the second is the loop, setup is where you program you gpio pins in an Arduino as input or as an output, and the loop part repeats itself .



Saturday, 13 May 2017

Terminals in Indian AC Socket

Terminals in Indian AC Socket

As you all know that AC plugs have three headers

Earth is a one is which has zero potential which is actually grounded to earth (which is mainly connected to the metal frame of the appliances) which is a method to protect from current leakage in the appliances.

Neutral also has zero potential but it used along with the line wire current flows only there is a potential difference in the circuit

Line is a wire that carries current in the current (switch is usually placed in the line wire)

                                              

AC socket must be according to the above picture, you can check the socket with a cheap tester. if the tester lights then the terminal is Line Terminal,

and if the tester light is off then the terminal is Neutral Terminal.

     What happens when the terminals are swapped

Actually, the potential in line is a very high AC voltage, so the switch is always is placed in the line wire so the current flow can be stopped, some electrical appliances have their own switch in it , if terminals are interchanged in socket,the switch will be in the neutral socket, in this condition even in the switch is off, the current flows in the circuit and when you accidentally touch the appliance you will  have a severe electric shock, so it is important to check wiring.   

What is inside the bread board ?

Have you ever wondered whats is inside a breadboard




















Friday, 14 April 2017

Small introduction to Voltage Sources and loads

Voltage Sources are divided into
  • DC source - Direct Current
  • AC source - Alternating Current
As the name specifies in DC, current flow is only in one direction, but in AC it changes its direction of current flow for a particular interval of time. In electronic we don't use AC much so we can discuss DC source in detail.

AC is mainly used for transmission of  electricity,

In Indian house, we get a standard supply of  230v,50hz, sinusoidal. this an AC supply we cannot use it Electronic devices because Electronic devices use DC, AC can be converted into DC by a device called Rectifier. similarly, DC can be converted into AC by a device called invertor or an Oscillator.

DC power sources are mainly batteries and wall adapters(which convert AC into a required level of DC)

the battery has a specification of 2200mAh, 3.8v, 8.3Wh

The battery is lithium-ion battery, it delivers a maximum output of  3.8volts, and delivers a current of 2.2Amps(2200mh)

The term mAh(milli Amp hours) tells use how long does our battery work, 

Voltage delivered by the source depends on the battery output voltage but 
the current delivered by the source depends on the load resistance, 

This can be clearly explained by ohm's law 
V=IR
Voltage across a component in the circuit is equal to the product of current(I) and resistance of the component (R),

the above equation can be written as 
I=V/R

I∝1/R
This proves that when the resistance of the circuit increases the current through the circuit decreases
and the vice versa happens when the reverse takes place.

when this battery is kept in a circuit draws 2.2Amps(2200 milliamps) from the battery,
 the battery drains completely in 1 hour,
this is  mentioned as mAh,
so the life of the battery depends not only on the capacity of the battery but also the resistance of the circuit on which the battery is used,

from this, it's clear that the current specification any power source is only the maximum current which it can produce,

In the battery, it is also mentioned that 8.3Wh, which is nothing but the maximum power which can be delivered by the battery, in this case, it is (3.8volts*2.2Amps=8.3 watts)



Tuesday, 11 April 2017

Difference between Voltage and Current

Before moving on to the circuits, we can first discuss the Difference between Voltage and Current.


VOLTAGE: Voltage is the potential difference between any two points of a circuit. potential is nothing but the capacity of an electron to do a work (work is nothing but the movement of charge). voltage is defined as work done (joules) per unit charge(coulomb), it is measured in volts.

1-volt = potential difference that forces 1-ampere of current through 1-ohm resistance.


CURRENT: Current is the rate flow of electrons through a conductor or a semiconductor. It is measured in Ampere(amps). 

1-ampere = flow of one coulomb of charge per second through a conductor or a semiconductor.


For example, we take a simple circuit



In this circuit an LED is powered by a battery, the current in the circuit is always measured in series in the circuit, since the current is the rate of flow of electrons. when the current flows through the ammeter current is measured, since ammeter has very low resistance, it does not affect the circuit very much.

Resistance - It is property of materials which resist the flow of current through them,
The component which only has a property of resistance is called a resistor.

The voltage is always measured in parallel across the required component, in the above circuit, the voltage is measured across the LED. since the voltage is the potential difference between the terminals of a circuit the voltmeter is always set parallel with the components, 

The voltage cannot be measured unless there is a potential difference, if the voltmeter is set in series there will not be any potential difference so voltmeter is useless in series and also it has a very high resistance it affects the circuit, and so it is kept parallel.

in the above circuit the current flows in the clockwise direction, and so the ammeter reads the positive value.

when the current enters the ammeter in the positive terminal and leaves at the negative terminal, the current value in the meter is always positive, when it happens vice versa the current value has a negative sign.


In voltmeter, the voltmeter shows positive value when the potential at the positive terminal is higher than the potential at the negative terminal, and it shows negative value when the negative terminal has higher potential than the potential at the positive terminal.











Monday, 10 April 2017

Difference between Electrical and Electronics Engineering

First, let us discuss  the basic difference between Electrical Engineering and Electronics Engineering,
Though  Electrical and Electronics both are based on electricity, they different,

Electrical Engineering - 
  • Study of Flow of electrons through a conductor.
  • Electrical circuits are used for transmitting electricity and powering electronic devices.
  • They learn about transformers, motors, generators, electromagnetism etc.
  • Electrical circuit uses high voltages,


Electronics Engineering -

  • Study about the flow of electrons through a conductor and a semiconductor
  • They learn about electronic components like a transistor, IC etc.
  • Electronic circuits are used to control the flow of electrons in the circuit and electronic circuits are used for calculation, processing etc.
  • Electronic circuits uses almost low voltages, mostly DC 

Own IOT website and Hardware Using Node MCU (cyber thinks)

NODE MCU code -- website link  Cyberthinks google drive link  cyberthinks website files #include <ESP8266WiFi.h> #include <ArduinoJ...