Wednesday 19 February 2014


ARDUINO AND ANALOG READING OF SENSORS








Monitoring the light intensity of your room and displaying it on your pc screen using a light sensor and arduino



Requirements
Arduino
led
LDR
2 resistors 330 ohm any value will work
connecting wires/ jumpers


breadboard or project board



The procedure is very simple as follows
insert the  LED to the bread board connect a 330 ohm resistor to the anode of the led (+ve) terminal then connect the resistor to pin 11 of the arduino (any pin with pwm will work)
place the LDR or photoresistor into the breadboard connect one of its terminal to +5v of the arduino
connect the other terminal to the second reistor and finally connect to the ground of the arduino use the ones in the analog side
at the point where the ldr connects to the resistor put a jumper wire and connect the junction to analog pin ero of the arduinoA0
finally connect the cathode of led to the grd of arduino
The code is also simple





int led = 11; // thi is where the led is connected to pin 11 of arduino
int photocellpin=0; //photocell or LDR is an analog sensor and is connected to analog pin 0 ie A0
int photocellReading;//
int ledbrigtness;



void setup() {                
pinMode(led, OUTPUT);
Serial.begin(9600);  // here serial communication with the laptop is established for monitoring //with the screen
}



void loop(void) {
  
photocellReading=analogRead(photocellpin); // and the sensor bieng analog is read with this  //methord and its value assigned to the photo cell reading
Serial.print("Analog reading= " );
Serial.println(photocellReading);
if(photocellReading<=700){
 digitalWrite(11,HIGH);
}
else{
digitalWrite(11,LOW);
}
delay(1000);


 
}




For guys like Odawa who are interested in sensors here is a small introduction to proximity sensors  
 Please try and modify your project with that succes card speaker and come and show us happy learning
Enjoy and the presentation will be done by Rose wawire and her friend your feedback is highly appreciated

No comments:

Post a Comment