Arduino Projects with Tinkercad Simulator
Arduino Projects with Tinkercad Simulator
Report
TP INFORMATIQUE: Arduino
Prepared by:
Radhwen DALY HAMDOUNI
Framed by:
Sami HIDOURI
1
Summary
But ...
[Link] is Arduino?...........................................................................................................................................3
A. Description from the Arduino Uno board ................................................................................................................3
B. Principle operation
2
BUT :
In this practical work, we will master the Tinkercad simulator and undertake programming and creation.
circuit diagrams.
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.
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.
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.
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.
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.
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.
void main() {
setup();
while(true)
loop();
}
Come on, enough talking, let's move on to our program, the great classic.
void setup() {
pinMode(led, OUTPUT); // Sets pin 13 as an output pin
}
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.
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 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.
8
Buzzer.
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.
The greater the illumination, the greater the voltage across the photoresistor will be.
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:
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
void setup() {
[Link](9600);
pinMode(analogOutPin, OUTPUT);
setPinMode(analogInPin, INPUT);
void loop() {
The following command reads the 'analog' value from the photoresistor.
sensorValue = analogRead(analogInPin);
15
outputValue = (outputValue - 255)*-1;
analogWrite(analogOutPin, outputValue);
[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