Principles of
Mechatronics Lab
Introduction to Arduino using TINKERCAD©
Eng. Reem Akasha
Objectives
• Become familiar with the usage of AutoDesk
TINKERCAD©
• Get introduced to Arduino Uno series
• Turn an LED ON/OFF
• Work with variables in Arduino Code
• Control the number of times the LED is turned ON/OFF
• Adding Text Output
Recall: What is Arduino?
Inputs Microcontroller Outputs
Recall: Arduino Hardware
General Purpose Input/Output Pins
Classic Family: UNO Rev 3 GPIO
Operate at 5V, and can provide/receive 20mA
20 pins
14 Digital Pins: 6 Analog Pins:
- ON/OFF (Push button) - Operate within range of values
- Input/Output (Temp sensor)
>> pinMode() - Inputs labeled as A0 up to A5
>> digitalWrite() - 10 bits of resolution
>> digitalRead() >> analogRead()
>> analogReference()
TinkerCAD
Task 1: Circuit 1: Turn ON/OFF an
LED using Arduino
NOTE: positive anode + (bent wire) should be on the
resistor side and the negative cathode - (straight wire)
should be leading towards the – on the board.
Arduino Program Structure
void setup()
- Called once
- Used to initialize the pin modes
and start the serial
communication
Note: it has to be included even
if there are no statements
void loop()
- Execute the set of statements
enclosed in the curly brackets
repeatedly.
- Used to read inputs, trigger
outputs, check conditions
Task 1: Turn ON/OFF an LED using
Arduino
Note: time is measured in millisecond
Task 2: Variables in Arduino Code
4 places where variables can be declared:
• Before void setup():
• In the void setup():
• Above void loop():
• In the void loop():
• int = integer numbers (positive and negative)
• double or float = decimal numbers (positive and negative)
• char = character (one letter / symbol / digit)
• string = 286 consecutive characters
Task 3: Control the Number of
Times the LED is turned ON/OFF
Task 3: Control the Number of
Times the LED is turned ON/OFF
Task 4: Adding Text Output