Visit for more Courses http://edublock.co Session 02: LED Learn Arduino Fundamentals & Build your Soccer Bot What is an LED? Sheldon and Elijah were returning home from school. Elijah noticed that Sheldon was very irritated as they stuck in the traffic jam for a long time. To divert Sheldon's mind, Elijah said, "Sheldon, have you noticed the traffic lights?" Sheldon said, "Yes, there are three lights of 3 different colors". Then Elijah said, "If you look closely, you will notice that each traffic light has a bunch of smaller lights called LED" Sheldon looked at the traffic light and said, "Oh yes! There are small lights On each traffic light. What is an LED?". Elijah said, "LED stands for Light Emitting Diode. An LED is an electronic device that emits light when current flows through it. There are a few LEDs at home, will show once get home." How to turn the on LED? After returning home, Elijah showed the LEDs to Sheldon. Curious Sheldon stared at it for a while and said, "This is tiny. How does this work?" Elijah said, "You can turn it on using an Arduino," Sheldon asked, "How?" Elijah said, "Come, I will show you," Elijah took an Arduino Uno, a breadboard, an LED, and a few jumper wires. Then Elijah gave the LED to Sheldon and said, "Look carefully. To turn the LED on, we need to know which leg of the LED is positive and which one is negative. Notice that one of the legs is longer than the other one. The longer one is positive, and the shorter one is negative." Then Elijah connected the positive part of the LED to the pin 13 of the Arduino and the negative part to the GND pin using jumper wires. Later, he joined the Arduino to the computer using a cable. Lastly, Elijah opened the Arduino IDE and opened a new sketch. He wrote the code there and uploaded it to the Arduino. Copyrights ©2019: EDUBLOCK | All Rights Reserved Visit for more Courses http://edublock.co Copyrights ©2019: EDUBLOCK | All Rights Reserved Visit for more Courses http://edublock.co Code: To turn the LED on, open the Arduino IDE software on the computer. Turning the LED on takes only a few lines of code. The first thing we need to do is open a new sketch File by clicking New. Then we have to define a variable that will hold the number of the pin that the LED is connected. In the code, we have named the variable LED_BUILTIN initialized with 13. Next, a function named setup() called. In the setup function, we need to call another function pinMode() to configure the pin connected to the LED as an output. Then another function loop() is called, and the digitalWrite function in it will turn the LED on when the voltage is high. Copyrights ©2019: EDUBLOCK | All Rights Reserved
Enter the password to open this PDF file:
-
-
-
-
-
-
-
-
-
-
-
-