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.
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
No comments:
Post a Comment