0% found this document useful (0 votes)
19 views5 pages

PreLab1 Spr2024

The document provides an introduction to the Arduino Mega microcontroller board and the Pixy camera that will be used in the EN.530.421 Mechatronics Spring 2024 PreLab 1. It discusses the history and hardware design of the Arduino, including the ATmega2560P microprocessor, pins, and programming. It also introduces the Pixy camera, its object and color recognition capabilities, and the PixyMon software used to teach it colors and objects. Students are asked to investigate Pixy's specifications and ensure the necessary software is installed before the lab session.
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)
19 views5 pages

PreLab1 Spr2024

The document provides an introduction to the Arduino Mega microcontroller board and the Pixy camera that will be used in the EN.530.421 Mechatronics Spring 2024 PreLab 1. It discusses the history and hardware design of the Arduino, including the ATmega2560P microprocessor, pins, and programming. It also introduces the Pixy camera, its object and color recognition capabilities, and the PixyMon software used to teach it colors and objects. Students are asked to investigate Pixy's specifications and ensure the necessary software is installed before the lab session.
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
You are on page 1/ 5

EN.530.

421 Mechatronics Spring 2024


PreLab 1: Arduino Basics and Pixy Camera

Introduction to Arduino

A brief history
The idea of Arduino was originated from a class project in the Interactive Design Institute (IDII)
in Ivrea, Italy. A student called Hernando Barragan tried to create a user-friendly IDE and a new
hardware prototyping platform to help students building circuits. A team led by Massimo Banzi,
Hernando’s teacher, worked further on this idea, and made it into a low-cost, open-source
microcontroller board. After the first board’s birth in 2005, it has become powerful hardware in
both the innovative DIY community and scientific research. At this point Arduino boards have
evolved into a big family, famous members include: Uno, Nano, Mega, Due, etc. [1]

Hardware design
Arduino Mega has ATmega2560P microprocessor as its core component, and the board
integrates a lot of other electronic components to enable fast prototyping. These electronic
components include regulators, resistors, LED, capacitors, diodes, etc. On an Arduino Mega
board, there are also a USB connection, an external power jack and an ICSP header. You can
refer to the following diagram to see how electronic components are arranged on the board. [2]
(Note: The following image is shown for an Arduino Uno, but we will be using an Arduino
Mega in all of our labs and the final project. You can identify the same components on the
Mega as well!)

Pins
Arduino Mega has 76 pins for connection. These pins are divided into three main categories:
analog input pins (16); digital I/O pins (54); power pins (6), etc. These pins play important roles
in your mechatronics system, and you need to be clear about how they function.

Let’s start from digital input/output pins. There are 54 digital pins on Mega, and 14 of them
could be used as PWM (Google ‘PWM’ if you are unfamiliar). These pins can be configured by
users to become either input pins or output pins. On the input mode, digital pins can receive
digital signals from external devices, for example a photodiode, and change their states (high or
low) accordingly. While on the output mode, they can source or sink up to 40 mA to other device
or circuits. It should be noted that the majority of analog pins (which will be introduced soon)
can also use used as digital pins.

There are 16 analog input pins. Analog input pins receive analog signals from external devices.
For example, if you want to control a LED’s brightness by adjusting a potentiometer, you need to
read voltage on the potentiometer from an analog pin and process this signal to control the
voltage applied on LED. The analog signal will be processed by an onboard six channel analog-
to- digital (A/D) converter, the returning integers are in the range of 0 and 1023 (10 bits).

Programming
Arduino could be programed through the ICSP (In Circuit Serial Programming) pin array or USB
port (which we will use). With ICSP you can program the ATmega2560P microprocessor with C
language, while through USB port you need to program the board using Arduino IDE. Arduino
language is based on C/C++, if you have experience with either language you will find it easy to
understand.

Download IDE
You can download Arduino IDE from this url: https://www.arduino.cc/en/Main/Software
Select the version that suits your laptop operating system (Windows/OSX/Linux). Wyman 157
computers have IDE installed.

Setting up Arduino IDE

1. Select the entry in the Tools > Board menu that corresponds to your Arduino. In this lab
please select Mega, if you use other Arduino boards, select accordingly.

2. For windows users, select the serial port (this is likely, but not necessarily, to be COM2).
For Mac users, you should select the port named like this: /dev/cu.usbmodemxxxxxx
(Arduino/Genuino Uno)
3. After writing your code, first compile the script by clicking the “check” button, error
message will be shown in the status bar at the bottom of IDE if there is any bug in your
code. When the code is ready, upload it to the board by clicking the "arrow" button. If the
upload is successful, message "Done uploading." will appear in the status bar.

Coding with Arduino IDE


The basic coding procedure for the Arduino is fairly straightforward.

1. Open a new sketch in the Arduino IDE application. “file -> new”
2. Fill in the setup() function. The setup() function is called when Arduino starts working. It
is used to initialize variables, pin modes, libraries, etc. The setup function will only run
once.
3. Fill in the loop() function. The loop() function keeps running until you unplug power, or
press the Reset button.
4. This is a toy example, to make sure your Mega is working properly. Open in the IDE:
File- >Examples->01.Basics->Blink, upload this sketch to Mega and you will see the
onboard LED light blinking. Examples in IDE are useful reference if you are rookie in
Arduino programming, please play around in free time.
5. Go to the official Arduino website for more documentation:
https://www.arduino.cc/en/Reference/HomePage

Pixy camera

The Pixy camera was developed by Carnegie Mellon University and is now an open-source
camera module. It has a built-in algorithms for color and object recognition. It can track a ping-
pong ball, or recognize a color code. It could be interfaced to Arduino after manual
configuration.

You need to configure (teach) it to recognize one or more colors using Pixy’s application
‘PixyMon’ before it can do the task by itself. Please refer to the following link to download this
software, and have a basic knowledge about how to teach Pixy.

https://docs.pixycam.com (we are using Pixy2)

Also, please download Pixy API to Arduino.

https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:hooking_up_pixy_to_a_microcontroller_-
28like_an_arduino-29

Problem

Pixy:

Investigate the specifications of Pixy

1. What are the Pixy’s frame rate, power input, power consumption, and field of view?
(4pts)

Software CheckList

Make sure you have this software on laptop before lab session.
1. Arduino IDE
2. PixyMon
3. Pixy’s Arduino API

Reference
[1] (courtesy: http://www.circuitstoday.com/story-and-history-of-development-of-arduino)
(image courtesy: https://www.etechnophiles.com/arduino-mega-pinout-pin-diagram-schematic-
and-specifications-in-detail/)
[2] (courtesy: https://www.allaboutcircuits.com/technical-articles/understanding-arduino-uno-
hardware-design/) - need to change
[3] (courtesy: https://www.digikey.com/product-detail/en/711/1528-1150-ND)

[4] (courtesy: https://www.pololu.com/product/1570) (used in Prelab 2)

[5] Additional Documentation on Arduino Mega:


https://docs.arduino.cc/resources/datasheets/A000067-datasheet.pdf

You might also like