Arduino Basic Project 5
Welcome to the Technical Praveen, In this article, we will figure out how to make a few fundamentals venture with arduino at home. on the off chance that you wanna figure out how to make it painstakingly read the full article. this is the most fascinating and famous venture these days in hardware and designing, a considerable lot of the understudies from school constantly making this marvelous 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
When the board is connected, you should open the IDE and snap on Tools > Board > Arduino Uno to choose the board.
Select Serial Port
Next, you need to tell the Arduino which port you are utilizing on your PC. To choose the port, go to Devices > Port and afterward select the port that says Arduino.
NOW THE TENTH PROJECT BEGINS
10) Photoresistor
A photoresistor changes the opposition a circuit gets dependent on the measure of light that hits the sensor. In this task, the brilliance of the Drove will increment and decline dependent on the measure of light present.
Parts Needed
- (1) Arduino Uno
- (1) USB A-to-B Cable
- (1) Breadboard – Half Size
- (1) LED 5mm
- (1) 330 Ω Resistor
- (1) 10K Ω Resistor
- (1) Photoresistor
- (6) Jumper Wires
Project Diagram
Project Code
const int sensorPin = 0;
const int ledPin = 9;
// We'll also set up some global variables for the light level:
int lightLevel;
int calibratedlightLevel; // used to store the scaled / calibrated lightLevel
int maxThreshold = 0; // used for setting the "max" light level
int minThreshold = 1023; // used for setting the "min" light level
void setup()
{
pinMode(ledPin, OUTPUT); // Set up the LED pin to be an output.
Serial.begin(9600);
}
void loop()
{
lightLevel = analogRead(sensorPin); // reads the voltage on the sensorPin
Serial.print(lightLevel);
//autoRange(); // autoRanges the min / max values you see in your room.
calibratedlightLevel = map(lightLevel, 0, 1023, 0, 255); // scale the lightLevel from 0 - 1023 range to 0 - 255 range.
// the map() function applies a linear scale / offset.
// map(inputValue, fromMin, fromMax, toMin, toMax);
Serial.print("\t"); // tab character
Serial.print(calibratedlightLevel); // println prints an CRLF at the end (creates a new line after)
analogWrite(ledPin, calibratedlightLevel); // set the led level based on the input lightLevel.
}
/******************************************************************
* void autoRange()
*
* This function sets a minThreshold and maxThreshold value for the
* light levels in your setting. Move your hand / light source / etc
* so that your light sensor sees a full range of values. This will
* "autoCalibrate" to your range of input values.
/*****************************************************************/
void autoRange()
{
if (lightLevel < minThreshold) // minThreshold was initialized to 1023 -- so, if it's less, reset the threshold level.
minThreshold = lightLevel;
if (lightLevel > maxThreshold) // maxThreshold was initialized to 0 -- so, if it's bigger, reset the threshold level.
maxThreshold = lightLevel;
// Once we have the highest and lowest values, we can stick them
// directly into the map() function.
//
// This function must run a few times to get a good range of bright and dark values in order to work.
lightLevel = map(lightLevel, minThreshold, maxThreshold, 0, 255);
lightLevel = constrain(lightLevel, 0, 255);
}
NOW THE ELEVENTH PROJECT BEGINS
11) Temperature Sensor
A temperature sensor estimates surrounding temperatures of it's general surroundings. In this task, we will show the temperature in the chronic screen of the Arduino IDE.
Parts Needed
- (1) Arduino Uno
- (1) USB A-to-B Cable
- (1) Breadboard – Half Size
- (1) Temperature Sensor – TMP36
- (5) Jumper Wires
Project Diagram
Project Code
// We'll use analog input 0 to measure the temperature sensor's
// signal pin.
const int temperaturePin = A0;
void setup()
{
Serial.begin(9600); //Initialize serial port & set baud rate to 9600 bits per second (bps)
}
void loop()
{
float voltage, degreesC, degreesF; //Declare 3 floating point variables
voltage = getVoltage(temperaturePin); //Measure the voltage at the analog pin
degreesC = (voltage - 0.5) * 100.0; // Convert the voltage to degrees Celsius
degreesF = degreesC * (9.0 / 5.0) + 32.0; //Convert degrees Celsius to Fahrenheit
//Now print to the Serial monitor. Remember the baud must be 9600 on your monitor!
// These statements will print lines of data like this:
// "voltage: 0.73 deg C: 22.75 deg F: 72.96"
Serial.print("voltage: ");
Serial.print(voltage);
Serial.print(" deg C: ");
Serial.print(degreesC);
Serial.print(" deg F: ");
Serial.println(degreesF);
delay(1000); // repeat once per second (change as you wish!)
}
float getVoltage(int pin) //Function to read and return
//floating-point value (true voltage)
//on analog pin
{
return (analogRead(pin) * 0.004882814);
// This equation converts the 0 to 1023 value that analogRead()
// returns, into a 0.0 to 5.0 value that is the true voltage
// being read at that pin.
}
// Other things to try with this code:
// Turn on an LED if the temperature is above or below a value.
// Read that threshold value from a potentiometer - now you've
// created a thermostat!
0 Comments
If you have any doubts, Please let me know