0% found this document useful (0 votes)
9 views18 pages

Arduino Projects with Tinkercad Simulator

The document is a report on Arduino, detailing its functionality, components, and programming principles, particularly using the Arduino Uno board. It covers various projects simulated in the Tinkercad software, including circuits for blinking LEDs, gas detection, and light-dependent lighting. The report serves as a practical guide for mastering Arduino programming and circuit design.

Translated by

ScribdTranslations
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views18 pages

Arduino Projects with Tinkercad Simulator

The document is a report on Arduino, detailing its functionality, components, and programming principles, particularly using the Arduino Uno board. It covers various projects simulated in the Tinkercad software, including circuits for blinking LEDs, gas detection, and light-dependent lighting. The report serves as a practical guide for mastering Arduino programming and circuit design.

Translated by

ScribdTranslations
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

UNIVERSITY OF GAFSA

FACULTY OF SCIENCES OF GAFSA

Report

TP INFORMATIQUE: Arduino

Prepared by:
Radhwen DALY HAMDOUNI
Framed by:
Sami HIDOURI

Class: 1erMaster's year Mechatronics Group 3

Academic year 2020–2021

1
Summary
But ...

[Link] is Arduino?...........................................................................................................................................3
A. Description from the Arduino Uno board ................................................................................................................3
B. Principle operation

C. Structure of a program, languages used ...................................................................................................6


II. UNDER THE TINKERCAD SIMULATOR: ..................................................................................................................10

[Link] circuit of a Turn signal light.................................................................................................................10


2. The circuit of 4 flashing LEDs :....................................................................................................................11

3. Detector of gas :......................................................................................................................................12


4. Lighting with photocell : ................................................................................................................14
5. Detector Gas with LCD display: ........................................................................................................17

2
BUT :
In this practical work, we will master the Tinkercad simulator and undertake programming and creation.
circuit diagrams.

The Arduino simulator is available at this address:[Link]

It allows the creation of the layout diagrams for the components on the experimental boards, all
like Fritzing, but also the creation of schematics and electronic circuits.

I. What is Arduino:

Arduino is the brand of an open source prototyping platform that allows users to create
interactive electronic objects made from materially free electronic boards on which is located
a microcontroller (of Atmel AVR architecture begins with the Atmega328p, and of ARM architecture
start the Cortex-M3 for the ArduinoDue).

The schematics of these electronic cards are published under a free license. However, some components,
like the microcontroller for example, are not under free license.

The microcontroller can be programmed to analyze and produce electrical signals in such a way that
perform very diverse tasks such as home automation (controlling household devices lighting,
heating...), the control of a robot, embedded computing, etc.

A. Description of the Arduino Uno board

There are many models of Arduino boards, the most popular of which is probably the Uno.

The image below gives you an overview of the organization of the map (dimensions: 65x52mm) in its
versionOne.

3
It uses an ATMEGA328P microcontroller powered at 5V.

There are 14 digital inputs/outputs, 6 of which are usable in PWM (Pulse Width Modulation).
pulse width modulator.

There are 6 analog inputs. The microcontroller has anADC with 10 bits of resolution.

On the board, there is a circuit that allows for easy management of the USB that can power the board.

It is an open-source electronic board, mainly consisting of:

a microcontroller manufactured by Atmel,


a USB port
input/output connectors (more or less numerous depending on the models).

Open hardware, by analogy to open software, allows sharing of plans to enable replication.
improve, understand a hardware device.

4
Arduino is also an IDE (let's say rather a code editor) that allows you to upload programs to the
card through a USB port.

We can also power an Arduino without USB with a 9V battery connector.

Type de fiche:2.1x5.5mm prise male DC vers 9V, Matériel (externe):plastique, Couleur: Noir, Rouge,
Cable length: 12cm.

5
So we canfeedonearduino without usbwith a12V power supply
This power supply allows you to power any project requiring 12V at a maximum of 1A.

B. Operating principle

The principle, quickly mentioned in the very first sentence, is to use the pins (i.e. the connectors
numbered that can be seen in the photo) to read or write information.

The information is very low level, since it is a signal of either 5 V or 0 V.

A bit, that's all. Just enough to make an LED blink (spoiler: that's what we're going to do right now).

We will see later that communication protocols are available to avoid hitting each other.
writing the bits one by one on a pin.

But you will have understood, overall, we are going to be dealing with low-level programming.

C. Structure of a program, programming languages used

we are going to write our first program!

The goal?

Make an LED blink on the board. Well, you have to start small to really grasp the structure of a
program in this environment.

The main program consists of two functions (this will always be the case), whose signatures are as follows
simple:

void setup()
void loop()

6
osetup() is called only once, at the time of powering on the board.
oloop() is called, as its name suggests, in a loop.

It is launched aftersetup(), and spins at full speed infinitely (as long as the card is powered, in any case).

The programming language used is optionally C, but for its relative simplicity compared to pure C.

So to go back to our basic program, we have something like this:

void main() {
setup();

while(true)
loop();
}

In practice, we will only implement the two [Link]()andloop().

Themain()is generated by the compiler.

Come on, enough talking, let's move on to our program, the great classic.

int led = 13;

void setup() {
pinMode(led, OUTPUT); // Sets pin 13 as an output pin
}

// the loop routine runs over and over again forever:


void loop() {
digitalWrite(led, HIGH); Turn on the LED
delay(1000); Wait a second
digitalWrite(led, LOW); Turns off the LED
delay(1000); // Waits for a second
}

In this program, we use 3 functions from the standard library:

pinMode(pinNumber, mode): defines the operating mode of a pin. Roughly, either INPUT or
OUTPUT ;
digitalWrite(pinNumber, value): if the pin is set to OUTPUT, this instruction allows writing 1 or 0.
If we measure with a voltmeter the voltage between the pin and ground, we will have +5 V or 0 V. HIGH and
LOW are predefined constants, but 1 or 0 would also work;
delay(ms) : this instruction blocks the execution of the program (of the whole program) for a
duration given in milliseconds.

Pin 13 is very useful because it is connected to a built-in LED on the board.

So, as soon as we activate or deactivate the 13, a small orange LED lights up or goes out.

In the previous section, we already saw what Arduino is, its programming language, how to...
create a simple program.

In the following part, we will simulate several programs using the Tinkercad software.

7
The material for this work:

Arduino Uno circuit.

Arduino UNO is the best board to use with electronics and codecs.

If this is your first experience with the platform, UNO is the most powerful board with
which you can start working on.

UNO is the most used and documented board for the entire Arduino family.

Led.

The LED is an optoelectronic component. This simply means that it is a component


electronic device capable of emitting light when an electric current passes through it. A
The light-emitting diode only allows electric current to pass in one direction - from the anode.
towards the cathode (the forward direction, like a classic diode, the reverse being the blocking direction) plus
it produces incoherent monochromatic or polychromatic radiation from the
conversion of electrical energy when a current passes through it.

8
Buzzer.

The buzzer is a component essentially consisting of a diaphragm reacting to the effect


piezoelectric. Piezoelectricity is the property that certain minerals have to deform.
when they are subjected to an electric field. This phenomenon is reversible; if we deform this
mineral, it produces electrical energy.

In the Arduino universe, the buzzer is primarily used to emit sound.

Gas Sensor.

The MQ-2 is a sensor that allows detection of gas or smoke at concentrations of 300.
ppm to 10000 ppm. After calibration, the MQ-2 can detect different gases such as LPG (liquefied petroleum gas), the i-
butane, propane, methane, alcohol, hydrogen as well as fumes. It is designed for use
interior at room temperature.

Light sensor.

9
A light sensor (or photoresistor) is an electronic component whose resistivity varies
according to the level of brightness.

We use Lux as the unit of measurement for luminous flux.

The greater the illumination, the greater the voltage across the photoresistor will be.

II. UNDER THE SIMULATORTINKERCARD:

1. The circuit of a blinking LED:

Program:

10
2. The circuit of 4 flashing LEDs:

The four LEDs are lit and turn on successively one after the other and then repeat the cycle.

Program:

11
3. Gas detector:

1hecase : the sensor does not detect smoke.

2themecase: the sensor detects smoke.

12
Program:

13
4. Lighting with light-dependent resistor:

1erIf the sensor detects light, the LED does not turn on.

2themecase: the sensor did not detect the light, LED on.

14
Program:

// Initialization of constants:

const int analogInPin = A0; // The pin number to which the photoresistor is connected

const int analogOutPin = 8; // Number of the pin to which the piezoelectric buzzer is connected

int sensorValue = 0; Value read on the photoresistor

int outputValue = 0; Value sent to the buzzer

void setup() {

Initialize the communication with the computer,

// to display the sensorValue and outputValue

on the computer screen.

[Link](9600);

Indicates that the analogOutPin is an output:

pinMode(analogOutPin, OUTPUT);

// Indicates that the analogInPin pin is an input:

setPinMode(analogInPin, INPUT);

void loop() {

The following command reads the 'analog' value from the photoresistor.

(an integer value between 0 and 1023)

// et stocke le résultat dans sensorValue :

sensorValue = analogRead(analogInPin);

The read value (between 0 and 1023)

must be interpreted and translated into frequency

(ranging from 50 Hz to 30,000 Hz).

// The following command changes sensorValue to

a range from 50 Hz to 30,000 Hz

// and stores the result in outputValue :

outputValue = map(sensorValue, 0, 1023, 0, 255);

15
outputValue = (outputValue - 255)*-1;

The following command sends this news

value on the buzzer

analogWrite(analogOutPin, outputValue);

// The following commands display the values in

the computer's serial monitor

[Link]("sensor = ");

[Link](sensorValue);

output =

[Link](outputValue);

16
5. Gas Detector with LCD Display

1erIf there is no gas, the program will display SAFE on the LCD screen with the light on.
LED vert.

2themeif there is gas, the program displays ALERT on the LCD screen and the buzzer sounds with
the lighting of the red LED.

17
Program:

18

You might also like