0% found this document useful (0 votes)
23 views

Quarter II - Computer Science Reviewer - Ray

Reviewer

Uploaded by

Kurt Dela Pena
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Quarter II - Computer Science Reviewer - Ray

Reviewer

Uploaded by

Kurt Dela Pena
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

QUARTER II - COMPUTER SCIENCE

REVIEWER
Arduino Programming
ARDUINO
• Arduino is an open-source project that created microcontroller-based kits for
building digital devices and interactive objects that can sense and control
physical devices.
• Is an open-source electronics platform based on easy-to-use hardware and
software.
Two major parts:
1. Arduino board
- which is the piece of hardware where we can work on or where we build
our projects
2. IDE (Integrated Development Environment)
- which is the software/application/program that we will run on our
computer/machine
MICROCONTROLLER
• A small computer on a single integrated circuit containing a processor core,
memory, and programmable input/output peripherals.
• The most important part for us is that a microcontroller contains a processor
(which all computers have, even smartphones) and memory, and some
input/output pins that we can control.
GPIO – General Purpose Input Output Pins
- Input/output pins that we can control.
Examples of microcontrollers:
Raspberry Pi – color Green
Arduino – color Blue
EZboard – color Blue
- low power consumption Arduino™ compatible board, equipped with an
onboard WiFi controller, microSD card socket, temperature sensor, and
power relay.
GizDuino mini – color Red, made in the Philippines
ARDUINO SOFTWARE
IDE (Integrated Development Environment)
• Software used to program the Arduino board (microcontroller).
• Minimum requirement : MAC OS X; Windows XP 32-bit or 64-bit; Linux 32-
bit or 64-bit (Ubunto or similar)

Sketch
• It is the name that the Arduino program is called.
• Is a set of lines or instructions that will tell the board on what to do.
• It is based on a C/C++ platform.
• Arduino programs can be divided in three main parts: structure, values
(variables and constants), and functions.

Required for each sketch


• setup() - function is called when a sketch starts. Use it to initialize variables, pin
modes, start using libraries, etc. The setup function will only run once, after
each power up or reset of the Arduino board.
• loop() - After creating a setup() function, which initializes and sets the initial
values, the loop() function does precisely what its name suggests, and loops
consecutively, allowing your program to change and respond.

SKETCH FLOW
if() statement (Conditional Statement)
• most basic of all programming control structures. It allows you to
make something happen or not, depending on whether a given
condition is true or not. It looks like this:
if (someCondition) {
// do stuff if the condition is true
}

SYNTAX
; (semicolon)
- Used to end a statement.
- Forgetting to end a line in a semicolon will result in a compiler error.
{} (curly braces)
– Used for function(s), indicating start and finish of a function(s).
- it is used for loops, conditional statements.
________________________________________________________________

Comparison Operators: Boolean Operators:


== (equal to) && (and)
!= (not equal to) || (or)
< (less than) ! (not)
> (greater than)
<= (less than or equal to)
>= (greater than or equal to)
________________________________________________________________
FUNCTION
- a named section of a program that performs a specific task.
- type of procedure or routine.
- some programming languages make a distinction between a function,
which returns a value, and a procedure, which performs some operation
but does not return a value.
- most programming languages come with a prewritten set of functions that
are kept in a library.
There are prewritten or built in functions in Arduino programming.

DIGITAL i/o
pinMode()
- Configures the specified pin to behave either as an input or an output. See the
description of digital pins for details on the functionality of the pins.
Syntax : pinMode(pin, mode)
Parameters
pin: the number of the pin whose mode you wish to set
mode: INPUT, OUTPUT
Returns : None
Example
pinMode(13,OUTPUT);

digitalWrite()
-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 for HIGH, 0V (ground) for LOW.
-If the pin is configured as an INPUT, digitalWrite() will enable (HIGH) or disable
(LOW).
Syntax
digitalWrite(pin, value)
Parameters
pin: the pin number
value: HIGH or LOW
Returns : None
Example : digitalWrite(13, HIGH);

digitalRead()
- Reads the value from a specified digital pin, either HIGH or LOW.
Syntax
digitalRead(pin)
Parameters
pin: the number of the digital pin you want to read (int)
Returns : HIGH or LOW
Example : val = digitalRead(13);

DELAY
delay()
- Pauses the program for the amount of time (in miliseconds) specified as
parameter. (There are 1000 milliseconds in a second.)
Syntax
delay(ms)
Parameters
ms: the number of milliseconds to pause.
Returns : nothing
Example : delay(1000);

VARIABLE DECLARATION
Variable
- is a way of naming and storing a value for later use by the program, such as data
from a sensor or an intermediate value used in a calculation.
Declaring Variables
• Before they are used, all variables have to be declared. Declaring a variable
means defining its type, and optionally, setting an initial value (initializing the
variable). Variables do not have to be initialized (assigned a value) when they
are declared, but it is often useful.
Example:
int inputVariable1;
int inputVariable2 = 0;

SOME VARIABLE TYPES


• char - A data type that takes up 1 byte of memory that stores a character value.
• byte - A byte stores an 8-bit unsigned number, from 0 to 255.
• int - Integers are your primary data-type for number storage. Stores a 16-bit (2-
byte) value.
• unsigned int – same as “int” however it will only store positive values.
• long
• unsigned long
• float
• double
Program example:
int ledPin = 13; // LED connected to digital pin 13
void setup()
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
}
void loop()
{
digitalWrite(ledPin, HIGH); // sets the LED on
delay(1000); // waits for a second
digitalWrite(ledPin, LOW); // sets the LED off
delay(1000); // waits for a second
Arduino – Comic Strip
ARDUINO
- An open-source electronics prototyping platform.
OPEN SOURCE
- Resources that can be used, redistributed or rewritten free of charge.
- Often software or hardware
ELECTRONICS
- Technology which makes use of the controlled motion of electrons through
different media
PROTOTYPE
- An original form that can serve as a basis or standard for other things
PLATFORM
- Hardware architecture with software framework on which other software can
run

ARDUINO
Microchip
- Very small computer that you can program to respond to things
- Measure conditions (like how much light there is in the room)
- Can control how other objects react to those conditions (room gets dark and
an LED turns on.
- Can respond to something as simple as the press of a switch
Mouse
- Common input device for a desktop computer
Monitor
- Common output device for a desktop computer
Microcontrollers
- Use inputs and outputs
Inputs – capture information from the user or the environment
Outputs – do something with the information that has been captured
- Any object we want to turn on and off and control; could be a motor or even a
computer
Switch or Sensor
- Could be an input into the Arduino

Inputs and outputs can be DIGITAL or ANALOG.


Digital Information
- Binary, either true or false
- Discrete and finite
- Described in two states, 1 or 0, on or off
Analog Information
- Continuous, can hold a range of values
- Characterized by continuous nature
- Infinite number of possible values

A switch is a digital input, a sensor is an analog input. The range of an analog sensor
is limited by its conversion to digital data.
TWO COMMON TYPES OF CIRCUITS
1. Direct Current – current always flows in one direction
2. Alternating Current – current flows in opposite directions in regular cycles

Integrated Development Environment (IDE)


- Combines a text editor with a compiler and other features to help
programmers develop software
- Allow to write sketches or programs
TWO MAJOR PARTS OF A SKETCH
1. Setup – happens one time when program starts to run
2. Loop – repeats over and over again
These are both blocks of code called Functions that every sketch will have. They are
blocked out by curly braces { }.
Solderless breadboard – allow us to quickly set up and test circuits
- Has 2 rows running left and right side, 5 rows of holes in the middle
- Side rows connected vertically, holes in the middle are connected horizontally

LED (Light Emitting Diode)


- Lights up when current flows in right direction
Anode – longer, connects to power
Cathode – shorter, connects to ground
Potentiometer (pot)
- A variable resistor, amount of resistance changes as it turned; increasing or
decreasing
Serial Monitor
- Button in order to see the values as you turn the pot
Pulse Width Modulation
- Method of simulating an analog value by manipulating the voltage
Activity 1: Simple Circuit (LED and Resistor)
Materials:
- 10 Kilo Ohms Resistor (Brown-Black-Orange-Gold) (1/2 watt)
- 300 Ohms Resistor (Orange-Black-Brown-Gold) (1/2 watt)
- 30 Kilo Ohms Resistor (Orange-Black-Orange-Gold) (1/2 watt)
- Light-emitting diode (any color)
- Jumper wires
- Battery with holder
- Breadboard

Activity 2: Charging ang Discharging Capacitor


Materials:
- 300 Ohms Resistor (Orange-Black-Brown-Gold) (1/2 watt)
- 10 Kilo Ohms Resistor (Brown-Black-Orange-Gold) (1/2 watt)
- Light-emitting diode (any color)
- Breadboard
- Jumper wires
- 6 volts Battery with connector

Activity 3: Light Dependent Resistor and LED


Materials:
- Light Dependent Resistor
- Jumper wires
- Light-emitting diode (any color)
- Battery with battery holder
- Breadboard

Activity 4: Comparing Simple, Series and Parallel Circuit


Materials:
- (2 pcs.) 300 Ohms Resistor (Orange-Black-Brown-Gold) (1/2 watt)
- Jumper wires
- Light-emitting diode (any color)
- Battery with connector
- Breadboard

Activity 5: Simple Night Switch


Materials:
- 10 Kilo Ohms Resistor (Brown-Black-Orange-Gold) (1/2 watt)
- 300 Ohms Resistor (Orange-Black-Brown-Gold) (1/2 watt)
- Light Dependent Resistor/ Light Sensor
- CD4069 Inverter IC
- Light-Emitting Diode
- Batteries with Battery holder
- Jumper wires

Activity 6:
(Lack of information since sir Julius haven’t give us the activity 6 paper)

You might also like