Sunday, 15 November 2015

Arduino tutorial 3: millis() function

If you are new for my tutorial,just check out this

Things to know about ARDUINO

ARDUINO TUTORIAL 1: Reading analog sensor

Arduino tutorial 2:basic programmings

millis()
  • It is a inbuilt function of arduino(so we need not to include any preprocessor statement to use this).
  • If you use the millis() function,it gives the number of milliseconds since the arduino started running the sketch. so it is named as millis().
  • Delay() function is also an inbuilt function as like millis().If we invoke delay() function nothing will be happen untill delay() has finished.
  • So at that time ,the response from arduino would not instantaneous.It is a drawback
  • Some critical situation you may not use delay() function in your program.Instead of that you can use millis().
  • ()-represents that it is a function.
  • This function is also used to measure frequency using arduino,to find the toggle time and most importantly for deb-ounce. 

Serial monitor
  • On top right corner of the above image is a button for Serial monitor.
  • It displays the Serial data from arduino.
  • If you want to use this ,you want to begin this in setup().
  • Serial.begin(9600) is used to begin communication to Serial monitor.9600 is the baud rate which defines the rate of speed of data transfer.
  • Serial.print("Arduino program"),this command print "Arduino program".

millis() program:

  •  In above program,Serial communication to Serial monitor is invoked in setup().
  • In loop,Reasonable delay for better visibility. you can change the delay time and you get the corresponding output change.
  • Serial.println() -It print consecutive data in new line.Instead of this if you use Serial.print() ,the new line would not be invoked.
  • just run this on your arduino and see what it will do.
millis() counter for 10 sec:

This is to count 10 sec using millis() and It is little bit complicated than what we seen before.explanation is on image itself.


   
The output of this program is :







If you have any douts,feel free to ask me in comment box.
To get more updates like my page in facebook
Learn Electronics-Facebook

Friday, 6 November 2015

Arduino tutorial 2:basic programmings


Hi guys,

This is the continuity of tutorial 1, i hope you got knowledge about analog sensors and its working.

If you haven't got my tutorial 1,Here the link:
ARDUINO TUTORIAL 1: Reading analog sensor
If you miss that, Don't worry!
Go and study then you got better idea about this one.

Arduino is an integrated development environment ( both software and hardware).So only,the software to program arduino is named as Arduino IDE and it's available in www.arduino.cc.
Just go there and download and install that.
  If you are a windows user,make sure you successfully installed driver also.
 Your Arduino IDE looks like this .


In above image you can see 2 functions or Methods.One is void setup() and other is void loop()

void setup()
{
}

void-It denotes ,this function does not return any value.
setup()-It is set your projects input and output pins. 
It is used to give a overview about your project to arduino.
It is enough now,for upcoming tutorials you get a better idea about this.

void loop()
{
}
your program must be inside this loop.then only it continuously run your program.It is a never ending loop.

Now come back to reading analog sensor.The program for reading analog sensor is given below.


This program is to read the value of analog out and print it in a serial monitor(looks in right corner of arduino IDE).
  • The analogRead(a0) gets reading of analog sensor and give it to the variable sensorValue  .
  • Serial.println(sensorValue) is to print the values in serial monitor
  • delay(1) is give the appropriate delay to took reading .the delay here is 1 milli seconds .you can change it to delay(1000)-( 1000 ms=1 sec) to get a better visibility.
  • This program is available in File>Examples >Basics>analogSerialread.
  • On the top of the IDE,there is a tick symbol . It is used to compile the program.
  • On next to that,the arrow is used to send the program to arduino.
  • Before sending the program,make sure you haven't get any error.
If you have any problem for troubleshooting,make sure about your COM ports.
verify the program twice,and make sure for no error.

If you have any doubt,ask me in comment box

Follow me on facebook to get more updates:
Learn Electronics- Facebook



 

Friday, 30 October 2015

ARDUINO TUTORIAL 1: Reading analog sensor


ARDUINO TUTORIAL 1: READING ANALOG SENSOR

ANALOG SENSOR:
Analog sensor

There are different types analog sensors are here. The basic types of sensors are:
  •     variable current output
  •     variable voltage output
In industry,they use current analog sensors ,its is the rating of (4-20)mA.
But here,we gonna see about the voltage analog sensor and how to interface with arduino.
Basically,the voltage analog sensor varies its output range from 0v to 5v.
0v means no detection in the analog sensor , 5v means high detection in the sensor and the intermediate values are proportional to the detection.

Example: LDR(light dependent resistor) is an analog sensor,its output is  proportional to light and its resistance is indirectly proportional to light.
   If  more light falls on the sensor,its resistance goes 0ohm,then it gives the high output(as per we given) and vice versa.

ARDUINO ADC:

  • Arduino have 6 analog input pins on the left bottom of that.
  • The first analog pin is A0,second is A1 and so on.
  • It has a inbuilt 10bit ADC in analog pins.so your analog values are converted into digital by ADC.
  • Suppose,if you want measure the light intensity of the room using LDR. Presumably, a good LDR gives the varying output accordance with the light intensity of the room.Reading the analog values directly is not possible.so you can use the inbuilt ADC in arduino.
  • The accuracy of ADC is determined by the resolution.In case of arduino ,it have a 10bit ADC (i.e) 2^10=1024
  • so your analog values 0-5v is split into 1024.
  • 0v gives 0000,5v gives 1023(because 0000-1023 is 1024 values)
  • if it's 2.5v ,ADC gives 512 and so on  .
ARDUINO COMMANDS:
  •  I hope ,now you got better understanding about ADC and analog sensors.
  • Now you can integrate this into your arduino.
  • The arduino commands to read analog value is analogRead(a0).
  • Here a0 is analog pin.
so,on my next tutorial i'll explain about how to write program (on your own) for arduino .If you have any douts, ask me in comment box
To get more updates follow me on facebook
Learn Electronics- Facebook

Sunday, 4 October 2015

Know about a scientist:

-He spent his whole life on inventions -
(from age four on)
-He was the first inventor to have an invention laboratory!
-He invented the first electric light bulb.
The first one lasted 40 hours.
The second one lasted 225 hours
-He invented the movie camera-which is the reason we are
able to go to the movie theater today!!
-He invented the fluoroscope.
-He also invented the re-chargeable battery.
-He was celebrated on the fiftieth anniversary of the
invention of the light bulb.
Unless,He is thomas alwa edison.