When you try to name a variable, start it with a letter followed with letter, number or underscore. Later on in the program, you can simply type the variable name rather than typing out the data over and over again in each line of code, at which point its value will be looked up and used by the IDE. You must introduce, or declare variables before you use them. Integers can store numbers from -32768 to 32767. Variables display as orange text in the sketch. In this example we’re declaring a variable named ledPin of type “int” (integer), meaning the LED is connected to digital pin 10. In the above example, “int” (integer) is the type, “ledPin” is the name and “10” is the value. This is a useful way of annotating code.Ī variable is a place to store a piece of data. Once again, the Arduino IDE will turn this text grey to show that it is is commented out. Similar to single line comments, any text between / * and * / will be ignored by the compiler. * the text between these two symbols will be commented out the compiler will ignore the text and the text will appear gray * / This allows you to write plain English descriptions of the code you or others have written and makes it easier for other people who might not be able to read code to understand. The Arduino IDE indicates this by turning the line of code grey automatically. Now your onboard LED should be blinking on and off.Īny line of code that has “//” put before it will not be compiled by the complier. If the code has no errors, click "Upload" to upload code to the micro-controller. When you've finished entering the code, click on "Verify" to check if the code can be compiled. When you finish the circuit, connect the Arduino controller and computer with the provided USB cable.ĭescription: turn LED on and off every other second. (In this example Pin 10) and the short leg connects to GND. LEDs are po-larized (will only work if placed in the circuit the correct way around). Normally red wire indicates power supply (Vcc), black wire indicates ground (GND), green wire indicates digital pins, blue wire indicates analog pins, and white is other.ĭouble check the orientation of LED leads on the circuit. It is standard practice to use wires of different colored insulation for your own reference, but using different combinations of colors wont stop the circuit working. You can now set up the circuit according to the picture below. Peel the adhesive strip off the back of the Breadboard and then stick it on to the Prototype Shield. Be gentle and be careful not to bend them. The male header pins on the bottom of the Prototype Shield should line up and slide in to the female headers on the arduino easily. White: Other To build the circut, you need to take your arduino and stack the Prototype Shield on top of it. *DFRduino is DF Robot’s signature Arduino board and functions the same as any other Arduino board. We will mention how to calculate resistance value in the latter part of this lesson. *You may need to choose a different value resistor depending on the LED you will use. Required Components: DFRduino UNO (similar as Arduino UNO R3)*3 Through this, we can have a clear idea of how a LED works and how they can be used in a circuit. LED Flashing In the first project, we will use the "Blink" sketch again but with a proper LED instead of the on-board LED. Additionally, you will start to write Arduino sketches to control a LED with your Arduino starter kit. Related Product: Beginner Kit for Arduino Let’s kickstart our Arduino adventure! In the first lesson, you will learn the basics of components such as LEDs, buttons and resistors - including pull-up and pull-down resistors.
0 Comments
Leave a Reply. |