![]() Serial.println(s1) // see the value in serial monitor in Arduino IDEĪs the code in the setup section, we define the pin along with the type to which the sensor is connected also we initialize the pin and type for the led and buzzer. Int s1=analogRead(A0) //ANALOG PIN FOR SENSOR ir sensor with arduino analog value // IR Sensor with Arduino Serial.println(val) // see the value in serial monitor in Arduino IDE Val = digitalRead(2) // IR sensor output pin connected PinMode(2,INPUT) // IR sensor output pin connected put this code in the ide of arduino from this line ( FOR digital output) ![]() IR Sensor with Arduino Code:- // IR Sensor with Arduino Connect -live of the buzzer to GND on a breadboard, and +tive to 5V on a breadboard. ![]() Enhance this version by adding a buzzer to it also like in the above diagram. Moreover, we can also use it in analog mode by that simply connecting the A0 pin of the sensor to pin A0 of the microcontroller. Now connect LED to the breadboard + to digital pin 13 of Arduino and – to and in series with 220-ohm resistor.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |