In this blog, we explored the functionalities of few of the main pinouts on the Uno board and learnt how to control LED with the help of a button. The LED should turn on everytime you click the button and turn off when you release it. Now upload the sketch onto the board and run the program. If the pin is configured as an INPUT, digitalWrite() will enable (HIGH) or disable (LOW) the internal pullup, on the input pin. If the pin has been configured as an OUTPUT with pinMode(), its voltage will be set to the corresponding value to 5V for HIGH, 0V (ground) for LOW. digitalWrite(pin, value) - Used to write a HIGH or a LOW value to a digital pin. Pin - the Arduino pin number you want to readģ. digitalRead(pin) - It reads the value from a specified digital pin, either HIGH or LOW. Pin - the Arduino pin number to set the mode ofĢ. pinMode(pin, mode)- Configures the specified pin to behave either as an input or an output.Let’s look at few of the functions used in the code in detail: In case you’re not familiar with the installation of the Arduino IDE and want to verify the process, you can check out the procedure to set it up out here.Īfter opening a new sketch, run the following code on the IDE to enable the button to control the on-board LED. Once you have made the connections, connect the board to your PC and open a new sketch. When the button is closed (pressed), it makes a connection between its two legs, connecting the pin to 5 volts, thereby reading a HIGH. When the pushbutton is open (unpressed) there is no connection between the two legs so the pin is connected to ground (through the pull-down resistor) and reads LOW. The other leg of the button connects to the 5 volt supply. That same leg of the button connects through a pull-down resistor (here 10K ohm) to ground. The third wire goes from digital pin 2 to one leg of the pushbutton. The first two, red and black, are connected to the two long vertical rows on the side of the breadboard to provide access to the 5 volt supply and ground. We will explore the control of the on-board LED on the Uno board with the help of a button.įollowing are the circuit diagram and layout for the project:Ĭonnect the three wires to the board according to the schematic. Now that we have a basic idea of the pin layout and their purposes, let’s get started with a basic program to explore their functionality. Reset - Used to reset the microcontroller. TWI: A4 or SDA pin and A5 or SCL pin - used to support TWI communication using the Wire library.ĪREF - Used with analogReference() to set a reference voltage for the analog inputs. A few pins have specialized functionality: By default they measure from ground to 5 volts. The Uno has 6 analog inputs, labeled A0 - A5, each of which provide 10 bits of resolution (i.e. When the pin is HIGH value, the LED is on, when the pin is LOW, it’s off.Īll these pins can be configured to work as input digital pins to read logic values (0 or 1) or as digital output pins to drive different modules like LEDs, relays, etc. LED: 13 -There is a built-in LED connected to digital pin 13. SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK) - These pins support SPI communication using the SPI library. PWM: 3, 5, 6, 9, 10, and 11 - Provide 8-bit PWM output with the analogWrite() function. Serial: 0 (RX) and 1 (TX) - They are used to receive (RX) and transmit (TX) TTL serial data.Įxternal Interrupts: 2 and 3 - These pins can be configured to trigger an interrupt on a low value, a rising or falling edge, or a change in value. In addition to this, some pins have specialized functions: Each of the 14 digital pins on the Uno can be used as an input or output, using pinMode(), digitalWrite(), and digitalRead() functions. The Arduino Uno board has 14 digital I/O pins. The Arduino does not have a built-in digital-to-analog converter (DAC), but it can pulse-width modulate (PWM) a digital signal to achieve some of the functions of an analog output. The ADC turns the analog voltage into a digital value. To measure the value of analog signals, the Arduino has a built-in analog-to-digital converter (ADC). An analog signal can take any number of values, while a digital signal which is limited to two values: High and Low.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |