Chapter 3_study and Realisation of Projects

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

UNIVERSITY OF KASDI MERBAH OUARGLA

Faculty of New Technologies in Information and Communication


Department of Electronics and Telecommunications
Master 2: -Electronics of Embedded Systems

Teacher: TAMISSA Younes Year: 2024/2025

Module: Study and Realization of Projects

Chapter 3 – Implementation of the Electronic Part


This chapter focuses on the practical implementation of the electronic components and systems designed
for the project. It covers the physical assembly, wiring, and testing of the embedded system or electronic
circuit to ensure it functions as intended.

1. Component Assembly
a. Gathering Components
Before starting the assembly, gather all required components:
 Microcontroller (e.g., ATmega328, ESP8266)
 Sensors (e.g., temperature, humidity, motion)
 Actuators (e.g., relays, motors)
 Power Supply (e.g., 5V or 12V)
 Communication Modules (Wi-Fi, Bluetooth if necessary)
 Resistors, capacitors, and other passive components
 PCB (Printed Circuit Board) or breadboard
b. Preparing the Circuit Board
 Breadboard: For prototyping, use a breadboard for easy assembly and debugging.
 PCB: For permanent designs, print or purchase a custom PCB that matches your circuit design.
c. Soldering Components
For PCB-based designs: Solder each component carefully following the schematic. Ensure proper
orientation of components such as diodes, capacitors, and ICs.
Double-check solder joints to prevent short circuits.
2. Wiring and Connections
a. Microcontroller
 Connect the microcontroller pins to the respective components:
 Digital/Analog Inputs: Sensors, buttons, and external inputs.
 Outputs: Relays, motors, displays, or other output devices.
 Power: Ensure the microcontroller has a stable power supply (5V or 3.3V depending on the model).
b. Sensor Connections: Connect the sensors (e.g., temperature, light,) to the appropriate
analog or digital input pins.
c. Actuators: Connect actuators such as relays, motors, or LEDs to the output pins.
d. Power Supply: Ensure all components share a common ground. Use voltage regulators if
needed to provide stable power to different parts of the circuit.

Page 1 of 11
3. Testing the Circuit
 Power Test: Power up the system and check for proper voltage levels across all components.
 Functional Testing: Use a multimeter or oscilloscope to check signal integrity.
Upload test code to the microcontroller to verify that sensors and actuators are functioning as expected.
 Debugging
 If the circuit doesn’t work as expected, re-check all connections and solder joints.
 Look for short circuits, loose wires, or incorrect component orientations.
4. Final Assembly
Once the circuit is tested and working, assemble all components into a protective enclosure:
 Ensure proper ventilation for heat dissipation if necessary.
 Organize the wiring neatly to prevent tangling and shorts.
5. Documentation of the Electronic Design
Document all steps of the process, including:
 Circuit diagrams and schematics.
 List of components used.
 Assembly instructions and testing procedures.
This documentation will ensure that future modifications or troubleshooting can be done efficiently.
2. Hardware Comparison

Page 2 of 11
Introducing the Arduino
Exploring the Arduino Uno Board

 Microcontroller: the ATmega328p is the Arduino brain. Everything on the Arduino board is meant to
support this microcontroller. This is where you store your programs to tell the Arduino what to do.
 Digital pins: Arduino has 14 digital pins, labeled from 0 to 13 that can act as inputs or outputs. When
set as inputs, these pins can read voltage. They can only read two states: HIGH or LOW. When set as
outputs, these pins can apply voltage. They can only apply
 5V (HIGH) or 0V (LOW).
 PWM pins: These are digital pins marked with a ~ (pins 11, 10, 9, 6, 5 and 3). PWM stands for “pulse
width modulation” and allows the digital pins output “fake” varying amounts of voltage. You’ll learn
more about PWM later.
 TX and RX pins: digital pins 0 and 1. The T stands for “transmit” and the R for “receive”. The Arduino
uses these pins to communicate with other electronics via Serial. Arduino also uses these pins to
communicate with your computer when uploading new code. Avoid using these pins for other tasks
other than serial communication, unless you’re running out of pins.
 LED attached to digital pin 13: This is useful for an easy debugging of the Arduino sketches.
 TX and RX LEDs: these leds blink when there are information being sent between the computer and
the Arduino.
 Analog pins: the analog pins are labeled from A0 to A5 and are often used to read analog sensors.
They can read different amounts of voltage between 0 and 5V. Additionally, they can also be used as
digital output/input pins like the digital pins.
 Power pins: the Arduino provides 3.3V or 5V through these pins. This is really useful since most
components require 3.3V or 5V to operate. The pins labelled as “GND” are the ground pins.

Page 3 of 11
 Reset button: when you press that button, the program that is currently being run in your Arduino
restarts. You also have a Reset pin next to the power pins that acts as reset button. When you apply
a small voltage to that pin, it will reset the Arduino.
 Power ON LED: will be on since power is applied to the Arduino.
 USB jack: you need a male USB A to male USB B cable (shown in figure below) to upload programs
from your computer to your Arduino board. This cable also
powers your Arduino.

 Power jack: you can power the Arduino through the power jack.
The recommended input voltage is 7V to 12V. There are several
ways to power up your Arduino: rechargeable batteries,
disposable batteries, wall-warts and solar panel.
Arduino IDE
The Arduino IDE (Integrated Development Environment) is where you develop your programs that will tell
the Arduino what to do. You can load new programs onto the main chip, the ATmega328p, via USB using the
Arduino IDE.
When you first open the Arduino IDE, you should see something similar to the figure below:

Connecting your Arduino


Connect your Arduino UNO to your computer via USB. After connecting your Arduino with a USB cable, you
need to make sure that the Arduino IDE has selected the right board.
In our case, we’re using Arduino Uno, so we should go to Tools Board: Arduino/Genuino Uno.

Page 4 of 11
Then, you should select the serial port where your Arduino is connected to. Go to Tools Port
and select the right port.

Uploading an Arduino Sketch


To show you how to upload code to your Arduino board, we’ll show you a simple example. This is one of the
most basic examples – it consists in blinking (flashing) the on-board LED or digital pin 13 every second.
1. Open your Arduino IDE.
2. Go to File Examples 01.Basics Blink

Page 5 of 11
By default, the Arduino IDE comes pre-configured for the Arduino UNO. Click the Upload button and wait a
few seconds.

After a few seconds, you should see a Done uploading message.

This code simply blinks the on-board LED on your Arduino UNO (highlighted with red color). You should see
the little LED turn on for one second, and turn off for another second repeatedly.

Example of Traffic Lights


Introduction
In this project you’re going to build a traffic lights system:
 There are 3 LEDs with different colors (green, yellow and red) to mimic the traffic lights for the cars
 There are 2 LEDs with different colors (green and red) to mimic the traffic lights for the pedestrians
 There is a pushbutton to mimic the ones in the pedestrians (walkers) traffic lights.

Page 6 of 11
Parts Required
 Breadboard
 Arduino UNO
 3LED (1x red, 1x yellow, 1x green)
 2LED (1x red, 1x green)
 5x 220Ohm Resistor
 10kOhm Resistor
 pushbutton
 Jumper Wires

Schematics
Assemble all the parts by following the schematics below.

Page 7 of 11
Code
You don’t need any library for this code. The code is very simple.
How It Works:
 Initial State: Cars are moving (green light for cars) and pedestrians must wait (red pedestrian light).
 When Button is Pressed: After 5 seconds from the last press, the lights change:

 Cars stop (red light), and pedestrians are allowed to cross (green pedestrian light).
 After the pedestrian cross time (2 seconds), the pedestrian green light flashes, and then the
system resets to allow cars to move again.

Copy the following code to your Arduino IDE, and upload it to your Arduino board. Make sure you have the
right board and COM port selected.

Code Explanation:

1. Variable Declaration:

 redCar, yellowCar, and greenCar: Control the traffic lights for cars.
 greenPed and redPed: Control the pedestrian (walker) lights.
 button: The button that pedestrians press to request a crossing.
 crossTime: The time allowed for pedestrians to cross (2 seconds).
 changeTime: Keeps track of the last time the button was pressed to ensure a delay between presses.

Page 8 of 11
2. Setup Function:

 The setup() function initializes the pins for the traffic lights, pedestrian lights, and button.
 Initially, greenCar and redPed are ON, meaning cars can move and pedestrians have to wait.
3. Main Loop:

digitalRead(button) checks if the button is pressed. If the button is pressed and 5 seconds have passed
since the last time it was pressed, the program calls the changeLights() function to change the traffic and
pedestrian lights.

Page 9 of 11
4. Change Lights Function:

 Turn on Yellow for 2 Seconds: The car traffic light switches from green to yellow for 2 seconds.
 Turn on Red for Cars: Cars must stop as the pedestrian green light turns on.
 Pedestrian Crossing: Pedestrians have 2 seconds to cross while the greenPed light is on.
 Green Flashing Pedestrian Light: The green pedestrian light flashes for 1 second, warning that time is
running out (ending) for crossing.
 Reset: After the pedestrian crossing, the lights return to their initial state with the greenCar light and
redPed light on.

Page 10 of 11
Demonstration
When you press the button, the light for the cars changes from green to red, and the pedestrian light
changes from red to green.

After the crosstime, the pedestrian green led flashes and changes to red. The light for the cars changes from
red to green.

Page 11 of 11

You might also like