N - e ž a
WEEK 6
ELECTRONICS
To learn about the basics of electronics, what a micro controller is and how to read sensors and how to control actuator by writing a code with Arduino program. Intention is to work in a pair and make two components work, either actuator or sensor and share the documentation.
WORKSHOP ABOUT BASIC ELECTRONICS
2
NEOPIXEL MATRIX
Neopixel matrix
is it a sensor or an actuator?
ASSIGNMENT
-el. Current flows from higher to lower voltage
-ground is the point of voltage and circuit

-in the circuits you are building them to el. Current flow in one direction: direct current
-in al. current (from plus to minus) : power from the walls, good way to translate bigger sizes of el.

Voltage(V): difference in el. Charge between two points-volts (V)
Current(I): rate at which el. Charge is flowing-amperes (A)
Resistance(R): material’s tendency to resist the flow of el. current (OHM)
Increasing voltage-current goes faster

Why is this important?
-LED’s have certain amount of current flowing through them before they burn out
-current rating is the maximum amount of current that can flow through the LEDs (usually 20mA)
-resistant needs to be there otherwise the LEDs would burn out instantly
OHM’s law: V=IxR; all of these are connected, relationships between voltage, current and resistance

-elements in series
-elements in parallel
Neopixel Matrix is an actuator.
Why is that?
Well actuator can be anything that converts electric energy in an output, for example a display, a led, a loudspeakers etc. So the energy is converted into a sort of motion. The motion can be in one direction, circular or opposite directions at regular intervals.
links to tutorials used
learning about the basics
name and image of component
datasheet and link to a supplier
https://cdn-shop.adafruit.com/datasheets/WS2812B.pdf
https://www.adafruit.com/product/1487
links to libraries needed
Adafruit_GFX
Adafruit_NeoMatrix
Adafruit_NeoPixel
schematic of the working circuit
https://learn.adafruit.com/adafruit-neopixel-uberguide/neomatrix-library
Starting with NeoPixel:
https://www.youtube.com/watch?v=sUzdY9qE3Go
https://www.youtube.com/watch?v=T-LYYBJsu4Y

Creating colour palettes:
https://learn.adafruit.com/simple-beautiful-color-changing-light-strand/creating-color-palettes

self made tutorials
1. Changing the colour



2. Changing the text



3. Changing the size


4. Changing the speed


In the code you find matrix, print and beside it says "Howdy", in order to be able to change it you simply replace the Howdy text with the one you prefer



If you prefer that your texts consists of 4 raws, the way to achieve that is to change the matrix.seCursor coordinates from (x, 0) to in this case (x, 4)

If you want to have longer words or sentences, you have to change the if row, the higher the number the longer the sentence you can write.
working, annotated Arduino code for this component
// Adafruit_NeoMatrix example for single NeoPixel Shield.
// Scrolls 'Howdy' across the matrix in a portrait (vertical) orientation.

#include
#include
#include
#ifndef PSTR
#define PSTR // Make Arduino Due happy
#endif

#define PIN D1

// MATRIX DECLARATION:
// Parameter 1 = width of NeoPixel matrix
// Parameter 2 = height of matrix
// Parameter 3 = pin number (most are valid)
// Parameter 4 = matrix layout flags, add together as needed:
// NEO_MATRIX_TOP, NEO_MATRIX_BOTTOM, NEO_MATRIX_LEFT, NEO_MATRIX_RIGHT:
// Position of the FIRST LED in the matrix; pick two, e.g.
// NEO_MATRIX_TOP + NEO_MATRIX_LEFT for the top-left corner.
// NEO_MATRIX_ROWS, NEO_MATRIX_COLUMNS: LEDs are arranged in horizontal
// rows or in vertical columns, respectively; pick one or the other.
// NEO_MATRIX_PROGRESSIVE, NEO_MATRIX_ZIGZAG: all rows/columns proceed
// in the same order, or alternate lines reverse direction; pick one.
// See example below for these values in action.
// Parameter 5 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)


// Example for NeoPixel Shield. In this application we'd like to use it
// as a 5x8 tall matrix, with the USB port positioned at the top of the
// Arduino. When held that way, the first pixel is at the top right, and
// lines are arranged in columns, progressive order. The shield uses
// 800 KHz (v2) pixels that expect GRB color data.
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(8, 8, PIN,
NEO_MATRIX_TOP + NEO_MATRIX_RIGHT +
NEO_MATRIX_COLUMNS + NEO_MATRIX_PROGRESSIVE,
NEO_GRB + NEO_KHZ800);

const uint16_t colors[] = {
matrix.Color(255, 0, 0), matrix.Color(0, 255, 0), matrix.Color(0, 0, 255) };

void setup() {
matrix.begin();
matrix.setTextWrap(false);
matrix.setBrightness(10);
matrix.setTextColor(colors[0]);
}

int x = matrix.width();
int pass = 0;

void loop() {
matrix.fillScreen(0);
matrix.setCursor(x, 0);
matrix.print(F("Howdy"));
if(--x < -36) {
x = matrix.width();
if(++pass >= 3) pass = 0;
matrix.setTextColor(colors[pass]);
}
matrix.show();
delay(100);
}

GIFs of the working components and output in serial monitor
common use case as well as less common use case that especially interests you
It is used as a display, to show different texts, to give messages through moving picture of LED lights.
It brings attention with the lights changing, used to create and show certain pattern, which consists of colours.
Since it attracts attention could be used as warning display.
Used to in a simple way understand how LED displays actually work.
When connected to a sensor it could showcase certain information which sensor detects, such as if 1 person comes close to the sensor, 1 light turns on, if 2 people come close 2 lights turn on etc.
problems encountered, solutions found
The first problem that we ran into was the fact you need to connect the Neopixel matrix to 5V but on the Arduino board there is no sign for 5V. We found out that VIN on the Arduino board has similar properties as 5V.
The other problem we encountered was when 3 rows of LED lights did not respond, they kept shining even when adjusting the code. We figured out that in the code instead of saying (8, 8, pin) it said (8, 5, pin) which actually leaves out 3 rows of the LED lights and doesn't give them the commands.
Yellow: D6
Red: GND
Black: VIN
To start with we had to make basic circuits. In order that circuit works, the circuit needs to be a loop so that the electrodes can flow from Anode to Cathode. Only the components that are connected to the circuit are functional.

First loop that we have made consists of the LED light, resistor and the battery and its main intention is to light up the LED light. The battery is supplying the circuit with 3V of energy. In order to make LED work, you need to resistor otherwise the LED could burn out. Coper tape is necessary to connect all the components.
The next step was to learn how to solder. First you have to prepare the solder stick, the metal wire, air blower and of course the component which you are going to solder. Underneath there are pictures of all the steps.
INFRARED OBSTACLE AVOIDANCE SENSOR
-infrared obstacle avoidance sensor
name and image of component
TRYING TO MAKE PIR WORK
-it is a sensor
-problems encountered, solutions found

It was too sesitive it always stayed on even when changing the sensitivity and the time. On advice of Sirley we changed to a different one.
is it a sensor or an actuator?
-it is a sensor
-it works how the image is showing below, one of the LED is emitting infrared and on is receiving it, it will only send a digital signal of 1 or a 0, you can change the sensitivity by turning the distance adjuster with a screwdriver
datasheet and link to a supplier
-supplier:
https://www.banggood.com/Infrared-Obstacle-Avoidance-Sensor-For-Arduino-Smart-Car-Robot-p-72965.html?cur_warehouse=CN
-datasheet: https://www.rhydolabz.com/documents/26/IR_line_obstacle_detection.pdf
fritzing schematic of the working circuit
-we made a circuit with a lamp so the lamp will switch when you are closeby. You can use the sensor for different things
links to tutorials used
-https://www.youtube.com/watch?v=yLC_j87qfpQ
-https://www.youtube.com/watch?v=A2Yyab2VGyc
working, annotated Arduino code for this component
TRYING OUT COMPONENTS FROM RICK AND ASLE
Second part of the assignment was to test the components of the other team, by following only their guide which they posted on hot glue website.
tilt sensor
the servo
-the informations about the components are not so in depth, so it is hard to understand the function of the sensors and motors or what it should do, what is expected
-the tilt sensor doesn't always work
-there is no instruction about the position the tilt sensor should be in order to make the motor work
-the schematic was not completely correct, since pins were switched, that is why was hard to make it work, without asking for extra help
-pin D2 and D1 switched
-there is no data sheet for the servo so it is hard to understand its intention
FEEDBACK RECEIVED
-going through Fritzing drawing again to remove small mistakes
-chronologically change the order of content in order to be more easy to read