0% found this document useful (0 votes)
4 views

Assignment-6es & Iot

Iot

Uploaded by

sri296315
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
4 views

Assignment-6es & Iot

Iot

Uploaded by

sri296315
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 4
[EXZq controlling LED by using IR Sensor and Remote The IR sensor is a 1838B IR receiver. Whenever a button on the remote is Pressed, it will send an infrared signal to the IR sensor in the coded form. The IR sens; will then receive this signal and will give it to the Arduino. Whenever a button is pressed on the remote, it sends an infrared signal in encoded form. This signal is then received by the IR receiver and given to the Arduino. We will save the code for the buttons that we want to control the LEDs in the Arduino code. Whenever a button on the remote is pressed, the Arduino receives TECHNICAL PuBLICATIONs® - an up-thrust for knowledge yr 1s and [oT enneated system: 5-27 loT and Arduino Programming . The Arduino will com i . a code. pare this code with the codes already saved, and if any of them match, the Arduino will turn on the LED connected to that button. cuit Diagram «First, om ree to the Arduino. Connect the positives of the four LEDs to the pins 7, 6, 5, and 4, Connect the negative of the four LEDs to GND on the Arduino through the 220 ohm resistors ‘ . The positive and the shorter wires are negative, e longer wires on the LEDs are cil « Then connect the IR sensor to the Arduino. Th . . The / the Arduino are as follows : connections for the IR sensor with Connect the negative wire on the IR sensor to GND on the Arduino. . Connect the middle of the IR sensor which is the VCC to 5 V on the Arduino. . Connect the signal pin on the IR i ; cae os 1, Fi _ sensor to pin 8 on the Arduino. #define second_key 58359 #define third_key 539 #define fourth_key 25979 int receiver_pin = 8; int first_led_pin int second_led_pin int third_led_pin int fourth_led_pin int led[] = {0,0,0,0}; IRrecv receiver(receiver_pin); decode_results output; void setup() { Serial.begin(9600); receiver.enablelRIn(); pinMode(first_led_pin, OUTPUT); pinMode(second_led_pin, OUTPUT); pinMode(third_led_pin, OUTPUT): pinMode(fourth_led_pin, OUTPUT); void loop() { if (receiver.decode(&output)) tor knowledge = Embedded Systems and loT 6-20 JoT and Arduino Proaremmiy @ { unsigned int value = output.value; ‘switch(value) { caso first_key: if(led[1] yt digitalWrite(first_led_pin, LOW); led[1] = 0; } else { digitalWrite(first_led_pin, HIGH); led[1] = 1; + break; case second_key: if(led{2! yt digitalWrite(second_led_pin, LOW); led[2] = 0; }else { digitalWrite(second_led_pin, HIGH); led[2] = 1; } break; case third_key: ifled{3] == 1) { digitalWrite(third_led_pin, Low); led[3] = 0; }else { digitalWrite(third_led_pin, HIGH); led[3} = 1; } : break; : case fourth_key: : if(edi4] == 1) { digitalWrite(fourth_led_pin, LOW); led[4] = 0; } else { GigitalWrite(fourth led_pin, HIGH); ledi4] = 1, } break; } TECHNICAL PUBLICATIONS® - an up-thrust for knowledge -_ systems ond 107 5-29 IoT and Arduino Programming nna Serial.printin(value); receiver.resume(); } } pal Reading Switch + Ifyou have a switch, use the continuity (beeper) function of a digital multimeter (DMM) to understand when the leads are open and when they are connected as the button is pushed. + The Arduino will read the state of a normally-open push button switch and display the results on the PC using the serial.printin() command. You will need switch, a 10 kohm resistor and some pieces of 22 g hookup wire. , “ * Create and run this Arduino program : void setup() Serial begin(9600); 1; void loop() Serial printin(digitalRead(3)); delay(250);

You might also like