4in1 Arduino Tutorial 1
4in1 Arduino Tutorial 1
ELECTRONICS-PROGRAMMING-ROBOTICS
▪ Week 1 – Electronics
▪ Week 2 – Programming
▪ Week 3 – Arduino
▪ Week 4 – Robotics
Introduction to Arduino
➢ Boolean - A Boolean holds one of two values, true or false. Each Boolean variable occupies one byte of memory.
Example
● Void setup () {
● pinMode (pin , mode);
● }
● pin − the number of the pin whose mode you wish to set
● mode − INPUT, OUTPUT, or INPUT_PULLUP.
BRUTE FORCE bruteforcehub@gmail.com +263718384192
Arduino Function Libraries
2. digitalWrite() Function - is used to write a HIGH or a LOW
value to a digital pin. If the pin has been configured as an
OUTPUT with pinMode(), its voltage will be set to the corresponding
value: 5V (or 3.3V on 3.3V boards) for HIGH, 0V (ground) for LOW.
If the pin is configured as an INPUT, digitalWrite() will enable
(HIGH) or disable (LOW)
the internal pullup on the input pin.
➢ If you do not set the pinMode() to OUTPUT, and connect an
LED to a pin, when calling digitalWrite(HIGH), the LED may
appear dim.
pin: the Arduino pin to write to. Allowed data types: int.
value: the duty cycle: between 0 (always off) and 255 (always
on). Allowed data types: int.
● I2C has the advantage that it uses only two signal connections to Arduino-
multiple devices on the two connections is fairly easy, and you get
acknowledgment that signals have been correctly received.
● The disadvantages are that the data rate is slower than SPI and data can
only be traveling in one direction at a time, lowering the data rate even more
if two-way communication is needed.
BRUTE FORCE bruteforcehub@gmail.com +263718384192
...Inter Integrated Circuits
● The two connections for the I2C bus are called SCL and SDA.
● Following are the pins for different Arduino boards −
✓ Uno, Pro Mini A4 (SDA), A5 (SCL)
✓ Mega, Due 20 (SDA), 21 (SCL)
✓ Leonardo, Yun 2 (SDA), 3 (SCL)
● We have two modes that are used to connect two Arduino boards using I2C. These are −
✓ Master Transmitter / Slave Receiver
✓ Master Receiver / Slave Transmitter
● I2C devices need a common ground to communicate. The Arduino Ground pin must be connected to ground on each
I2C device.
● The Arduino Wire library hides all the low-level functionality for I2C and enables simple commands to be used to
initialize and communicate with devices.