Arduino Introduction 2022
Arduino Introduction 2022
ESIB – USJ
Rayan Mina
Arduino Introduction 1
Arduino MEGA 2560 Board
PWM Signal outputs
Plug your USB cable to
upload your Sketch to
the Arduino board
MEGA
Processor
Reset Button
5V regulator
➢ delayMicroseconds (value)
❑ Pauses the program for the amount of time (in microseconds) specified as parameter, maximum 16383
❑ value: the number of 𝜇𝑠 to pause, unsigned int
❑ Returns Nothing
➢ micros ()
❑ Calculates and returns the duration in 𝜇𝑠 since the Arduino began running the current program. This
number goes back to 0, after 70 minutes. On 16 MHz boards (Mega), the function’s resolution of 4𝜇𝑠
➢ millis ()
❑ Calculates and returns the duration in 𝑚𝑠 since the Arduino began running the current program. This
number will go back to zero, after 50 days, unsigned long
❑ Used for communication between the Arduino board and a computer or other devices
❑ All Arduino boards have at least one serial port called Serial
✓ It can communicate on digital pins 0 (RX) and 1 (TX)
✓ Or with the computer via USB
❑ To use the Arduino IDE built-in serial monitor → Click the serial monitor button in the tools menu
➢ Serial.begin (value)
❑ Sets the data rate in bps for serial data transmission. For communicating with the computer, use one of
these rates: 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, or 115200
➢ Serial.end ()
❑ An optional 2nd parameter specifies the format to use: BIN (binary), DEC (decimal), HEX (hexadecimal)
✓ Serial.print(78, BIN) gives 1001110
✓ Serial.print(78, DEC) gives 78
✓ Serial.print(78, HEX) gives 4E
❑ For floating point numbers, this parameter specifies the number of decimal places to use
✓ Serial.println(1.23456, 0) gives 1
✓ Serial.println(1.23456, 4) gives 1.2346