Arduino is an open-source electronics platform based on easy-to-use hardware and software. Arduino boards are able to read inputs - light on a sensor, a finger on a button, or a Twitter message - and turn it into an output - activating a motor, turning on an LED, publishing something online. - https://www.arduino.cc/en/guide/introduction
It is easy to get started with these 5-minute tutorials from Robotshop.
In Arduino programming, digital and analog inputs and outputs refer to the ways in which the Arduino interacts with the external world, such as sensors, actuators, and other devices.
If you understand these, you should be able to interface with all components. The focus is to understand how digital and analog input and output works.
Think of analog like a smooth, continuous stream, and digital like stepping stones. Analog signals, such as music on a vinyl record or the volume knob on a radio, can be any value within a range. It's like a smooth volume control that can be set to any level.
On the other hand, digital signals, like the numbers on your phone screen, are more like steps – they can only be certain values, like 1 or 0. Imagine turning up the volume on your phone – it goes up in steps, not smoothly. Analog is like a smooth slide, and digital is like climbing stairs.
Understanding digital inputs and outputs lays the foundation for numerous practical applications. From creating interactive projects with buttons and switches to controlling digital devices like LEDs or relays, these concepts are integral to Arduino programming.
In the upcoming tutorials, we'll explore more advanced topics, combining digital inputs and outputs to build interactive and responsive Arduino projects.
Digital inputs are the eyes and ears of your Arduino. They are sensors that detect binary signals – either HIGH (5V) or LOW (0V). These inputs are essential for capturing information from buttons, switches, or any device providing a simple on-off response.
Digital outputs, on the other hand, are the hands and voice of your Arduino. They can send binary signals to control external devices, typically turning them on or off. Digital outputs are crucial for tasks like lighting LEDs, triggering relays, or driving digital actuators.
Basic introduction to digital inputs and outputs
Here is a link to a Doc, you can use for Evidence Collection
Task 1: Flashing LED
Build a circuit with an LED connected to an Arduino and write a program that makes the LED repeatedly turn on and off. Your code should clearly control the timing of the flashes using delays. To complete this task, you must show that the LED is flashing correctly and use a multimeter to measure the voltage in the circuit.
Completion evidence:
Screenshot of the circuit
Screenshot of the code
Voltage measurement recorded
Task file (.ino file or Tinkercad link)
Task 2: Read the state of a button switch
Build a circuit with a push button and write a program that reads whether the button is pressed or not pressed. Your program must display the button state in the Serial Monitor so it can be clearly seen changing as the button is used. To complete this task, the circuit and code must both work correctly and the output must be readable.
Completion evidence:
Screenshot of the circuit
Screenshot of the code
Screenshot of the Serial Monitor showing the button state changing
Task file (.ino file or Tinkercad link)
Task 3: Knight Rider sequence
Build a circuit with 5 LEDs and write a program that creates a moving light pattern across the LEDs and back again. (Knight Rider) You should use an array in your code to store the LED pin numbers rather than writing separate repeated code for each LED. To complete this task, the sequence must run in order and show that you can control multiple outputs efficiently.
Completion evidence:
Screenshot of the circuit
Screenshot of the code showing use of an array
Screenshot or short clip of the LEDs running in sequence
Task file (.ino file or Tinkercad link)
Make sure you use appropriate colour code: Red is positive and black is negative or ground. Choose other colours for the rest.
There are two important concepts when using the Arduino with the analog world. Because the Arduino is a digital device it is about high and low only (two states, 5V or 0V). To work with Analog interfaces we need to find ways to modify the circuit or program to do that for us. It is important for the Arduino to interact with analog devices as many inputs (for example sensors ) and outputs (for example motors) needs analog signal to do what we want them to do. These two concepts are pulse width modulation (PWM) and analog to digital converter (ADC).
Microcontrollers, the brains of many electronic devices, speak the language of digital. They understand 1s and 0s. But the real world often speaks in analog – temperatures, light levels, and sounds are continuous.
Analog Output - PWM
Analog output in Arduino is like making a dimmer switch for your lights. Imagine if you could only turn the lights on or off - that's like digital. But with analog output, it's like having a magical switch that lets you make the lights brighter or dimmer gradually.
Arduino achieves this by using a trick called Pulse Width Modulation (PWM). Instead of just turning the lights on or off, it quickly switches them on and off really fast. Unlike true analog signals, which can have an infinite number of values within a range, PWM is a way to simulate an analog output using digital signals.
So how does it work?
By adjusting how long the lights are on compared to off, you can control how bright they appear, kind of like magic! Because of the speed the output is changing from 5V to 0V, the output will “look” like one voltage. It is all about average voltage.
In robotics, PWM is widely used for controlling the movement of servo motors and for driving DC motors with variable speeds. This allows for precise control of robot limbs, wheels, or other moving parts.
PWM is commonly employed for adjusting the brightness of LEDs. By varying the duty cycle, you can make the LED appear dimmer or brighter without changing the overall power consumption.
The PWM output pins are 8-bit pins. This means that the range in decimal is 0 to 255( 2^8).
Task 4: LED Brightness Control
Connect an LED to a PWM-enabled pin on your Arduino(The pins with ~ in the front). Add a multimeter so we can measure the output voltage.
Write a program to gradually increase and decrease the LED brightness using PWM.
Add Docstring
Variable Declarations
As this is digital output, pinMode must be declared "pinMode(pin, OUTPUT)"
Use analogWrite to write a PWM value (0 to 255)
Observe how changing the duty cycle affects the perceived brightness.
What is special about the relationship between the voltage and the binary number output? For this create a table with the PWM value and output voltage. Measure voltage with a multimeter for the various PWM output values.
Add a FOR loop so that the LED goes brighter and fade continuously.
Task 5: Servo Motor Positioning
Connect a servo motor to your Arduino and write a program that moves it to different positions. The video will first show you how to move the servo manually by controlling the signal yourself, and then show you how to control it using the Servo library. To complete this task, you should demonstrate that the servo moves to different angles and responds correctly to the values sent from the Arduino.
Completion evidence:
Screenshot of the circuit
Screenshot of the code
Screenshot or short clip showing the servo at different positions
Task file (.ino file or Tinkercad link)
Task 6: RGB LED Colour Mixing
Build a circuit where an LED’s brightness is controlled using PWM. You should make this task using the skills from the previous videos, applying what you have already learned about wiring components, writing code, reading inputs, and controlling outputs. Your program should change the brightness level either automatically or by using an input such as a potentiometer. To complete this task, the LED must show visible changes in brightness and the code must use PWM rather than only turning the LED fully on or off.
Completion evidence:
Screenshot of the circuit
Screenshot of the code
Screenshot or short clip showing the LED brightness changing
Task file (.ino file or Tinkercad link)
Connect a servo motor to your Arduino and write a program that gets the servo to move. The video will first take you through manual servo control so you can see how the signal affects the servo position, and then show you how to control it using the Servo library. To complete this task, your program should move the servo to different positions and show that it responds correctly to the values sent from the Arduino.
Completion evidence:
Screenshot of the circuit
Screenshot of the code
Screenshot or short clip showing the servo moving
Task file (.ino file or Tinkercad link)
Difficult to get started? Work through this tutorial will help with analog inputs (This isn't what you need for the assessment but the theory behind it)
Using a temperature sensor, create a thermometer that displays the current temperature in the serial monitor.
Challenge: Display temperature on a LCD display.
Arduino's Plug and Make Kit Offers an Easy Introduction to the Internet of Things
The 25 Best Jetson Nano Projects in 2024. The Jetson Nano is a great way to get started with AI. Check out these clever Jetson Nano projects that make the most of its capabilities!
The ever-growing Arduino community is made up of everyone from hobbyists and students to designers and engineers all across the world.
The leading magazine for 3D printing, with compelling content on additive manufacturing, 3D scanning, CAD, laser cutting & engraving, CNC, SBCs, and more.
Best websites to learn more advanced Arduino applications
SparkFun is an online retail store that sells the bits and pieces to make your electronics projects possible. With lots of tutorials as well.