0% found this document useful (0 votes)
5 views3 pages

Arduino Interactive Design Basics

Teaching script for Arduino slides

Uploaded by

axiosly
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

Arduino Interactive Design Basics

Teaching script for Arduino slides

Uploaded by

axiosly
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Good afternoon, everyone, today we are talking about the interactive design with Arduino.

From last lecture, we had an initial understanding about the Arduino. And today we will go
on this content, you will: understand the Arduino workflow and programming syntax. Then,
study the Photoresistor in Arduino and how it works with Processing code. And finally,
appreciate how to design a system with Arduino.

Now we start with how Arduino work. Well, as it shown in diagram,

The first step is to write a sketch which consists of multiple functions.

Then, the compiler converts it into machine code. Machine code is a low-level programming
language consisting of 1 and 0.

Next, it goes through "bootloading." that allows new sketches to be uploaded via the USB
port.

It is stored in flash memory and then, the microcontroller executes the instructions in the
machine, resulting in LED blink. Clear?

Here's a brief introduction of Arduino syntax. Since it is similar to the other programming
languages which you learned before, we just take a quick review.

• Arduino programming has five common data types. Each type has different range of
values and memory requirements.

• And there are four common types of operators in Arduino. Assignment, Arithmetic,
Comparison, and Logical.

Next, we are going to the photoresistor. A photoresistor is a simple component that changes
its resistance based on the ambient light. We can use it to create interactive projects, such as
controlling the particles with various parameters, such as the color, size, and the rotation
speed to create an immersive experience.

Here I give the corresponding code in this sample.

We begin by declaring two variables: "pwm" and "PinMode". "pwm" represents the LED
signal to control the brightness, and "PinMode" represents the digital pin on the Arduino
board.

In the setup function, we initialize the serial with the rate.


In the loop function, we use the analogWrite function to set the output to the PinMode with the
current value of "pwm".

Next, we add a delay, and add the 'pwm' variable to increase in loop.

We then print the current value using [Link].

Finally, we have an if statement that checks whether the current value has exceeded 200.

Well, in processing code, Let's look at the "draw" function. If the data is available, we read it
with [Link](). And store in the variable "val".

Next, we set the background color to black. This will ensure the particles against a dark
background.

Then, we translate the origin to the center of the screen and make sure the particles are around
the center.

Next, we add a rotation around the y and x-axis, which is based on the frame rate and "val"
variable.

Finally, we display particles on the screen with shape. By changing of the rotation parameters,
we can create different effects in our project.

Now let’s move on to the final part, before we start to design an interactive project, there are
several design principles which should be considered.

One principle to follow is simplicity. The code should be kept simple and easy to understand.
For example, if you are designing an LED controller, you could use simple functions like
'turnOn', 'turnOff', and 'setColor' to control, instead of complex logic.

Another principle is modularity. This means that the code should be divided into independent
modules that can be easily understood and tested. For example, if you are designing a
Bluetooth application, you could separate the code into modules for communication, control,
and data readings. It makes us easier to test and debug, and also makes the code more
readable.

A third principle is abstraction. This means hiding the details of the code, and just exposing
the key functionalities to the user. For example, if you are designing a temperature sensing
system, it is better to only offer user an interface to read the temperature value for simple
interaction.

Lastly, the principle of efficiency should be considered. This means making the code run
faster and reduce resources.
By following these principles, I hope you guys could create your own design successfully.
And next seminar, we will further talk about your own project. Well, that’s all of today’s
lesson. Have a nice day!

Common questions

Powered by AI

Arduino programming uses five common data types, each with different value ranges and memory requirements, crucial for efficient program design. It also employs four types of operators: Assignment, Arithmetic, Comparison, and Logical, which are essential for performing operations on variables and controlling program flow .

Modularity poses challenges such as designing meaningful interfaces between modules and ensuring they work cohesively. However, it offers significant benefits like easier testing and debugging due to isolated modules, improved code readability, and flexibility in making changes or upgrading parts of a project without affecting the entire system .

Efficiency as a design principle involves optimizing Arduino code to run faster while using fewer resources. This is crucial for ensuring that the interactive projects remain responsive and resource-efficient, which is particularly important when the system is resource-constrained or real-time operations are needed .

Abstraction is crucial because it hides the complex details of code, exposing only the essential functionalities to users. This simplifies the interaction, making it easier for end users to operate without needing to understand the intricacies of the code. For instance, providing a simple interface to read temperature values benefits users by offering straightforward and efficient interaction with the system .

In an Arduino-controlled particle display project, the Processing code reads data to manipulate visual effects such as particle rotation. Variables, including those affected by a photoresistor, determine how attributes like rotation around the y and x-axis change, influencing the visual outcome and creating dynamic effects .

Creating an Arduino sketch involves writing code which consists of multiple functions. This sketch is then compiled into machine code, which is a low-level programming language made up of 1s and 0s. After compilation, the code goes through a 'bootloading' process allowing it to be uploaded to the microcontroller via the USB port. It is then stored in flash memory, where the microcontroller executes the instructions, such as blinking an LED .

A photoresistor is a component that changes its resistance based on ambient light, making it useful for interactive Arduino projects. It can control various parameters like color and size of particles. In Processing code, data from the photoresistor can influence elements such as rotation speed, creating immersive visual effects by changing parameters based on ambient light levels .

The bootloading process in Arduino is the step where compiled machine code is prepared for uploading to the microcontroller via a USB port. It is significant as it allows new sketches to be easily loaded and executed on the Arduino board, enabling rapid development and testing of interactive projects .

The analogWrite function is used in conjunction with a photoresistor to control the output signal's brightness on an LED. Specifically, it sets the output to the 'PinMode' based on the current 'pwm' variable, which varies according to the light detected by the photoresistor, allowing dynamic adjustment of LED brightness .

Simplicity in design ensures that code is straightforward and easy to understand, reducing complexity with simple functions like 'turnOn' or 'setColor'. Modularity divides code into independent, easily understandable modules, facilitating testing and debugging. These principles together improve readability and maintainability, allowing designers to manage complex projects more effectively by breaking them into simpler, testable parts .

You might also like