SlideShare a Scribd company logo
Implement the light effect as seen in
KIT, the Knight Rider car from the 80's
TV series with David Hasselhoff.
The sequence should be activated
when a user presses a button
HOMEWORK: KNIGHT RIDER
1
HOMEWORK: SOLVING IT
Besides wiring the breadboard, you
had to write the program needed to
make it work.
The “clever” solution makes use of
arrays, we iterate through them using a
FOR loop.
2
PHYSICAL PROTOTYPING
© 2011 K3 Creative Commons v3.0 SA-NC
Lab 2: Analog & Digital
With the Arduino prototyping board
for(counter=0; counter<end; counter++){}
1)The FOR loop is a software construct that will execute a
block of code a number of times.
2)The code will be looped until a certain condition is met
3)FOR loops are constructed with an initialization value, a
condition statement, and a counting statement
4)We use them to iterate a certain action a determined
amount of times
counter initialization
FOR LOOP
condition counter
increment / decrement
4
ARRAYS
1) ARRAYS are sets of indexed values arranged in order in
the processor's memory
2) All the elements in an array have an unique identifier
3) The different “positions” in the array are addressed through
numerical index values between squared brackets
4) Array constructors include the type, and the size of the
array (the number of elements they consist of)
5) The elements of an empty array are NULL (nothing)
6) It is possible to initialize an array with a specific set of
values:
E.g. int theList[] = {1, 3, 'e', 19};
5
WHAT IS “ANALOG”?
The real world is NOT digital.
Temperature fluctuation, for example,
involves a range of values and generally
does not changes abruptly over time.
Using analog sensors we measure
environmental parameters like
temperature, light intensity, etc.
These are a set
of analog values
6
Are sensors which transform environmental parameters
into a multi-level voltage value (between 0 and 5 volts)
There are many types of sensors that provide us with
analog voltage values:
LDR (or CDS): light dependent resistors aka light
sensors
NTC and PTC: temperature dependent resistors
aka temperature sensors
Potentiometers and sliders: angle and position
dependent resistors
ANALOG SENSORS
7
READING ANALOG VALUES
 Microprocessors cannot handle analog values as humans
do. They need to be translated into digital data, something
the microchip can understand.
 Sensors transform real world data like the temperature into a
voltage value between 0 and 5 volts. These values are
different from the HIGH (1) and LOW (0) that characterize
digital signals, because they can take any value between 0
and 5 volts.
E.g: 0.3 volts, 3.27 volts, 4.99 volts are possible values.
 The readings resolution depends on the capabilities of the
processor/microcontroller you are using.
Arduino can distinguish 1024 different levels between 0
and 5 volts.
8
 Are devices which change resistance (and thus the voltage) when
you twist or slide them.
 Arduino can measure the voltage which flows through them.
 We can use this data to control other things, like LED’s.
 We call potentiometer those that rotate around one of their axis
 We call sliders those that move linearly along one of their axis
POTENTIOMETERS vs SLIDERS
A circuit using a
potentiometer
A circuit using a
slider
9
CONNECTING THE POTENTIOMETER
Potentiometers are useful for improvising quick interfaces.
The recommended resistive value is 10 Kilo Ohms. (10K)
On the Arduino board there are 6 Analog Input pins, they are
numbered from 0 to 5.
Analog inputs are not declared in the setup of the programs,
unlike the Digital Inputs.
We will use this easy circuit to control the oscillation speed of the
basic Blink-LED example
10
analogRead(pin number);
 Returns the value from a specific analog
port
 Values from 0 to 1023
 0v = 0
 5v = 1023
READING THE SENSOR
11
int potPin = 2; // select the input pin for the potentiometer
int ledPin = 13; // select the pin for the LED
int val = 0; // variable to store the value coming from the
// sensor
void setup() {
pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT
}
void loop() {
val = analogRead(potPin); // read the value from the sensor
digitalWrite(ledPin, HIGH); // turn the ledPin on
delay(val); // stop the program for some time
digitalWrite(ledPin, LOW); // turn the ledPin off
delay(val); // stop the program for some time
}
EXAMPLES ► ANALOG ►
ANALOG INPUT
LDR
Light dependent resistor
 We call the resistor a “pull up” resistor
 It is usually 10K
 You can use exactly the same code as in the previous example
13
FADING LEDS
1) LEDs are Light Emmitting Diodes, and can only be turned on
or off.
2) However, it is possible to fake their level of intensity through
the use of a mathematical trick called PWM (Pulse Width
Modulation) which will be explained later.
3) In essence, what you need to know for making the next
experiment, is that there is a function called analogWrite(pin,
intensity) that will write an analog value to one of the PWM-
labelled pins on your prototyping boards.
4) PWM runs in parallel to the rest of Arduino, which means
it will not stop any of the other processes which are running.
5) Hook up one LED with it's correspondent resistor to
e.g. pin 10, and execute the following example.
14
EXAMPLES ► ANALOG ► FADING LED
int value = 0; // variable to keep the actual value
int ledpin = 9; // light connected to digital pin 9
void setup() { // nothing for setup
}
void loop() {
for(value = 0; value <= 255; value+=5) // fade in (from min to max)
{
analogWrite(ledpin, value);
delay(30); // waits for 30 milliseconds
}
for(value = 255; value >=0; value-=5) // fade out (from max to min)
{
analogWrite(ledpin, value);
delay(30);
}
}
SERIAL COMMUNICATION
USING THE SERIAL LIBRARY
Serial.xxxx
Serial defines a method to use the serial port
Serial.begin(baud);
Placed in setup to initiate serial communication ”baud” is baudrate
(”communication-speed”)
Serial.print();
Writes (sends) something to the serial port
Serial.println();
Writes (sends) with cr and lf
16
PROGRAMMING SUMMARY
Commonly used Arduino methods:
int analogRead(pin);
reads an analog value from an analog pin number
analogWrite(pin, value);
writes a time-dependant signal through the use of the
so-called PWM pins
Serial.println(data);
sends data back to the computer to be seen through the
serial monitor
Serial.begin(baud);
opens the serial communication at baud speed
17

More Related Content

What's hot

Qt arduino serial_port
Qt arduino serial_portQt arduino serial_port
Qt arduino serial_port
satyendrajaladi
 
Embedded systems الانظمة المدمجة
Embedded systems  الانظمة المدمجة Embedded systems  الانظمة المدمجة
Embedded systems الانظمة المدمجة
salih mahmod
 
Arduino اردوينو
Arduino اردوينوArduino اردوينو
Arduino اردوينو
salih mahmod
 
02 General Purpose Input - Output on the Arduino
02   General Purpose Input -  Output on the Arduino02   General Purpose Input -  Output on the Arduino
02 General Purpose Input - Output on the Arduino
Wingston
 
How to measure frequency and duty cycle using arduino
How to measure frequency and duty cycle using  arduinoHow to measure frequency and duty cycle using  arduino
How to measure frequency and duty cycle using arduino
Sagar Srivastav
 
Arduino slides
Arduino slidesArduino slides
Arduino slides
sdcharle
 
Embedded system course projects - Arduino Course
Embedded system course projects - Arduino CourseEmbedded system course projects - Arduino Course
Embedded system course projects - Arduino Course
Elaf A.Saeed
 
Starting with Arduino
Starting with Arduino Starting with Arduino
Starting with Arduino
MajdyShamasneh
 
برمجة الأردوينو - اليوم الأول
برمجة الأردوينو - اليوم الأولبرمجة الأردوينو - اليوم الأول
برمجة الأردوينو - اليوم الأول
Ahmed Sakr
 
Distance measurement using Ultrasonic sensor on Arduino Uno
Distance measurement using Ultrasonic sensor on Arduino UnoDistance measurement using Ultrasonic sensor on Arduino Uno
Distance measurement using Ultrasonic sensor on Arduino Uno
Aswin KP
 
Intro to Arduino
Intro to ArduinoIntro to Arduino
Intro to Arduino
Qtechknow
 
GCC 4-1-16
GCC 4-1-16GCC 4-1-16
GCC 4-1-16
Kayla Leung
 
Gcc 4 15-16
Gcc 4 15-16Gcc 4 15-16
Gcc 4 15-16
Kayla Leung
 
2009 11-17-arduino-basics
2009 11-17-arduino-basics2009 11-17-arduino-basics
2009 11-17-arduino-basics
Jhonny Wladimir Peñaloza Cabello
 
Arduino Robotics workshop Day1
Arduino Robotics workshop Day1Arduino Robotics workshop Day1
Arduino Robotics workshop Day1
Sudar Muthu
 
All about ir arduino - cool
All about ir   arduino - coolAll about ir   arduino - cool
All about ir arduino - cool
Vlada Stoja
 
Arduino windows remote control
Arduino windows remote controlArduino windows remote control
Arduino windows remote control
VilayatAli5
 
Arduino
ArduinoArduino
Arduino
ArduinoArduino
GCC 3-18-16
GCC 3-18-16GCC 3-18-16
GCC 3-18-16
Kayla Leung
 

What's hot (20)

Qt arduino serial_port
Qt arduino serial_portQt arduino serial_port
Qt arduino serial_port
 
Embedded systems الانظمة المدمجة
Embedded systems  الانظمة المدمجة Embedded systems  الانظمة المدمجة
Embedded systems الانظمة المدمجة
 
Arduino اردوينو
Arduino اردوينوArduino اردوينو
Arduino اردوينو
 
02 General Purpose Input - Output on the Arduino
02   General Purpose Input -  Output on the Arduino02   General Purpose Input -  Output on the Arduino
02 General Purpose Input - Output on the Arduino
 
How to measure frequency and duty cycle using arduino
How to measure frequency and duty cycle using  arduinoHow to measure frequency and duty cycle using  arduino
How to measure frequency and duty cycle using arduino
 
Arduino slides
Arduino slidesArduino slides
Arduino slides
 
Embedded system course projects - Arduino Course
Embedded system course projects - Arduino CourseEmbedded system course projects - Arduino Course
Embedded system course projects - Arduino Course
 
Starting with Arduino
Starting with Arduino Starting with Arduino
Starting with Arduino
 
برمجة الأردوينو - اليوم الأول
برمجة الأردوينو - اليوم الأولبرمجة الأردوينو - اليوم الأول
برمجة الأردوينو - اليوم الأول
 
Distance measurement using Ultrasonic sensor on Arduino Uno
Distance measurement using Ultrasonic sensor on Arduino UnoDistance measurement using Ultrasonic sensor on Arduino Uno
Distance measurement using Ultrasonic sensor on Arduino Uno
 
Intro to Arduino
Intro to ArduinoIntro to Arduino
Intro to Arduino
 
GCC 4-1-16
GCC 4-1-16GCC 4-1-16
GCC 4-1-16
 
Gcc 4 15-16
Gcc 4 15-16Gcc 4 15-16
Gcc 4 15-16
 
2009 11-17-arduino-basics
2009 11-17-arduino-basics2009 11-17-arduino-basics
2009 11-17-arduino-basics
 
Arduino Robotics workshop Day1
Arduino Robotics workshop Day1Arduino Robotics workshop Day1
Arduino Robotics workshop Day1
 
All about ir arduino - cool
All about ir   arduino - coolAll about ir   arduino - cool
All about ir arduino - cool
 
Arduino windows remote control
Arduino windows remote controlArduino windows remote control
Arduino windows remote control
 
Arduino
ArduinoArduino
Arduino
 
Arduino
ArduinoArduino
Arduino
 
GCC 3-18-16
GCC 3-18-16GCC 3-18-16
GCC 3-18-16
 

Viewers also liked

David Cuartielles and Tony Olsson - Going Physical (K3 research seminar)
David Cuartielles and Tony Olsson - Going Physical (K3 research seminar)David Cuartielles and Tony Olsson - Going Physical (K3 research seminar)
David Cuartielles and Tony Olsson - Going Physical (K3 research seminar)
K3Research
 
Las Mejores Herramientas
Las Mejores HerramientasLas Mejores Herramientas
Las Mejores Herramientas
Giomar Lázaro
 
DDC WHITE-PAPER
DDC WHITE-PAPER DDC WHITE-PAPER
DDC WHITE-PAPER
Scott Drossos
 
Herrera
HerreraHerrera
Aliñamos aceitunas
Aliñamos  aceitunasAliñamos  aceitunas
Aliñamos aceitunas
maryjose65
 
WW eBrochure JLinderbaum
WW eBrochure JLinderbaumWW eBrochure JLinderbaum
WW eBrochure JLinderbaum
Jill Linderbaum
 
Amigos lectores
Amigos lectoresAmigos lectores
Amigos lectores
maryjose65
 
LINK - Discovery Communications
LINK - Discovery CommunicationsLINK - Discovery Communications
LINK - Discovery Communications
Gabriela Galke
 
Aliñamos aceitunas
Aliñamos  aceitunasAliñamos  aceitunas
Aliñamos aceitunas
maryjose65
 
13 Tips: How to Succeed in Business (without really trying)
13 Tips: How to Succeed in Business (without really trying)13 Tips: How to Succeed in Business (without really trying)
13 Tips: How to Succeed in Business (without really trying)
David Verbraska
 
Gongali Model Presentation
Gongali Model PresentationGongali Model Presentation
Gongali Model Presentation
Gabriela Galke
 
Week Day Vegetarian
Week Day Vegetarian Week Day Vegetarian
Week Day Vegetarian
Megan Davis
 
Data mining
Data miningData mining
Data mining
Udit Agarwal
 
1C. Cвиноводство - описание модулей
1C. Cвиноводство - описание модулей1C. Cвиноводство - описание модулей
1C. Cвиноводство - описание модулей
matrix24ru
 

Viewers also liked (14)

David Cuartielles and Tony Olsson - Going Physical (K3 research seminar)
David Cuartielles and Tony Olsson - Going Physical (K3 research seminar)David Cuartielles and Tony Olsson - Going Physical (K3 research seminar)
David Cuartielles and Tony Olsson - Going Physical (K3 research seminar)
 
Las Mejores Herramientas
Las Mejores HerramientasLas Mejores Herramientas
Las Mejores Herramientas
 
DDC WHITE-PAPER
DDC WHITE-PAPER DDC WHITE-PAPER
DDC WHITE-PAPER
 
Herrera
HerreraHerrera
Herrera
 
Aliñamos aceitunas
Aliñamos  aceitunasAliñamos  aceitunas
Aliñamos aceitunas
 
WW eBrochure JLinderbaum
WW eBrochure JLinderbaumWW eBrochure JLinderbaum
WW eBrochure JLinderbaum
 
Amigos lectores
Amigos lectoresAmigos lectores
Amigos lectores
 
LINK - Discovery Communications
LINK - Discovery CommunicationsLINK - Discovery Communications
LINK - Discovery Communications
 
Aliñamos aceitunas
Aliñamos  aceitunasAliñamos  aceitunas
Aliñamos aceitunas
 
13 Tips: How to Succeed in Business (without really trying)
13 Tips: How to Succeed in Business (without really trying)13 Tips: How to Succeed in Business (without really trying)
13 Tips: How to Succeed in Business (without really trying)
 
Gongali Model Presentation
Gongali Model PresentationGongali Model Presentation
Gongali Model Presentation
 
Week Day Vegetarian
Week Day Vegetarian Week Day Vegetarian
Week Day Vegetarian
 
Data mining
Data miningData mining
Data mining
 
1C. Cвиноводство - описание модулей
1C. Cвиноводство - описание модулей1C. Cвиноводство - описание модулей
1C. Cвиноводство - описание модулей
 

Similar to Physical prototyping lab2-analog_digital

Fun with arduino
Fun with arduinoFun with arduino
Fun with arduino
Ravikumar Tiwari
 
Arduino Workshop (3).pptx
Arduino Workshop (3).pptxArduino Workshop (3).pptx
Arduino Workshop (3).pptx
HebaEng
 
Arduino intro.pptx
Arduino intro.pptxArduino intro.pptx
Arduino intro.pptx
SanthanaMari11
 
01 Intro to the Arduino and it's basics.ppt
01 Intro to the Arduino and it's basics.ppt01 Intro to the Arduino and it's basics.ppt
01 Intro to the Arduino and it's basics.ppt
pindi2197
 
Arduino programming
Arduino programmingArduino programming
Arduino programming
MdAshrafulAlam47
 
Arduino Programming Basic
Arduino Programming BasicArduino Programming Basic
publish manual
publish manualpublish manual
publish manual
John Webster
 
ARDUINO (1).pdf
ARDUINO (1).pdfARDUINO (1).pdf
ARDUINO (1).pdf
SoumikBanerjee43
 
Bidirect visitor counter
Bidirect visitor counterBidirect visitor counter
Bidirect visitor counter
Electric&elctronics&engineeering
 
INT4073 L07(Sensors and AcutTORS).pdf
INT4073 L07(Sensors and AcutTORS).pdfINT4073 L07(Sensors and AcutTORS).pdf
INT4073 L07(Sensors and AcutTORS).pdf
MSingh88
 
Arduino Slides With Neopixels
Arduino Slides With NeopixelsArduino Slides With Neopixels
Arduino Slides With Neopixels
sdcharle
 
4 IOT 18ISDE712 MODULE 4 IoT Physical Devices and End Point-Aurdino Uno.pdf
4 IOT 18ISDE712  MODULE 4 IoT Physical Devices and End Point-Aurdino  Uno.pdf4 IOT 18ISDE712  MODULE 4 IoT Physical Devices and End Point-Aurdino  Uno.pdf
4 IOT 18ISDE712 MODULE 4 IoT Physical Devices and End Point-Aurdino Uno.pdf
Jayanthi Kannan MK
 
Electronz_Chapter_3.pptx
Electronz_Chapter_3.pptxElectronz_Chapter_3.pptx
Electronz_Chapter_3.pptx
Mokete5
 
FIRE ALARM SYSTEM PPT.pptx
FIRE ALARM SYSTEM PPT.pptxFIRE ALARM SYSTEM PPT.pptx
FIRE ALARM SYSTEM PPT.pptx
RaJYadav196733
 
Arduino projects &amp; tutorials
Arduino projects &amp; tutorialsArduino projects &amp; tutorials
Arduino projects &amp; tutorials
Anshu Pandey
 
Arduino: Analog I/O
Arduino: Analog I/OArduino: Analog I/O
Arduino: Analog I/O
June-Hao Hou
 
Basics of arduino uno
Basics of arduino unoBasics of arduino uno
Basics of arduino uno
Rahat Sood
 
Arduino Workshop
Arduino WorkshopArduino Workshop
Arduino Workshop
atuline
 
Arduino cic3
Arduino cic3Arduino cic3
Arduino cic3
Jeni Shah
 
EEE UNIT-2 PPT.pdf
EEE UNIT-2 PPT.pdfEEE UNIT-2 PPT.pdf
EEE UNIT-2 PPT.pdf
VishalPatil57559
 

Similar to Physical prototyping lab2-analog_digital (20)

Fun with arduino
Fun with arduinoFun with arduino
Fun with arduino
 
Arduino Workshop (3).pptx
Arduino Workshop (3).pptxArduino Workshop (3).pptx
Arduino Workshop (3).pptx
 
Arduino intro.pptx
Arduino intro.pptxArduino intro.pptx
Arduino intro.pptx
 
01 Intro to the Arduino and it's basics.ppt
01 Intro to the Arduino and it's basics.ppt01 Intro to the Arduino and it's basics.ppt
01 Intro to the Arduino and it's basics.ppt
 
Arduino programming
Arduino programmingArduino programming
Arduino programming
 
Arduino Programming Basic
Arduino Programming BasicArduino Programming Basic
Arduino Programming Basic
 
publish manual
publish manualpublish manual
publish manual
 
ARDUINO (1).pdf
ARDUINO (1).pdfARDUINO (1).pdf
ARDUINO (1).pdf
 
Bidirect visitor counter
Bidirect visitor counterBidirect visitor counter
Bidirect visitor counter
 
INT4073 L07(Sensors and AcutTORS).pdf
INT4073 L07(Sensors and AcutTORS).pdfINT4073 L07(Sensors and AcutTORS).pdf
INT4073 L07(Sensors and AcutTORS).pdf
 
Arduino Slides With Neopixels
Arduino Slides With NeopixelsArduino Slides With Neopixels
Arduino Slides With Neopixels
 
4 IOT 18ISDE712 MODULE 4 IoT Physical Devices and End Point-Aurdino Uno.pdf
4 IOT 18ISDE712  MODULE 4 IoT Physical Devices and End Point-Aurdino  Uno.pdf4 IOT 18ISDE712  MODULE 4 IoT Physical Devices and End Point-Aurdino  Uno.pdf
4 IOT 18ISDE712 MODULE 4 IoT Physical Devices and End Point-Aurdino Uno.pdf
 
Electronz_Chapter_3.pptx
Electronz_Chapter_3.pptxElectronz_Chapter_3.pptx
Electronz_Chapter_3.pptx
 
FIRE ALARM SYSTEM PPT.pptx
FIRE ALARM SYSTEM PPT.pptxFIRE ALARM SYSTEM PPT.pptx
FIRE ALARM SYSTEM PPT.pptx
 
Arduino projects &amp; tutorials
Arduino projects &amp; tutorialsArduino projects &amp; tutorials
Arduino projects &amp; tutorials
 
Arduino: Analog I/O
Arduino: Analog I/OArduino: Analog I/O
Arduino: Analog I/O
 
Basics of arduino uno
Basics of arduino unoBasics of arduino uno
Basics of arduino uno
 
Arduino Workshop
Arduino WorkshopArduino Workshop
Arduino Workshop
 
Arduino cic3
Arduino cic3Arduino cic3
Arduino cic3
 
EEE UNIT-2 PPT.pdf
EEE UNIT-2 PPT.pdfEEE UNIT-2 PPT.pdf
EEE UNIT-2 PPT.pdf
 

Recently uploaded

Communications Mining Series - Zero to Hero - Session 3
Communications Mining Series - Zero to Hero - Session 3Communications Mining Series - Zero to Hero - Session 3
Communications Mining Series - Zero to Hero - Session 3
DianaGray10
 
Semantic-Aware Code Model: Elevating the Future of Software Development
Semantic-Aware Code Model: Elevating the Future of Software DevelopmentSemantic-Aware Code Model: Elevating the Future of Software Development
Semantic-Aware Code Model: Elevating the Future of Software Development
Baishakhi Ray
 
leewayhertz.com-AI agents for healthcare Applications benefits and implementa...
leewayhertz.com-AI agents for healthcare Applications benefits and implementa...leewayhertz.com-AI agents for healthcare Applications benefits and implementa...
leewayhertz.com-AI agents for healthcare Applications benefits and implementa...
alexjohnson7307
 
Redefining Cybersecurity with AI Capabilities
Redefining Cybersecurity with AI CapabilitiesRedefining Cybersecurity with AI Capabilities
Redefining Cybersecurity with AI Capabilities
Priyanka Aash
 
UX Webinar Series: Essentials for Adopting Passkeys as the Foundation of your...
UX Webinar Series: Essentials for Adopting Passkeys as the Foundation of your...UX Webinar Series: Essentials for Adopting Passkeys as the Foundation of your...
UX Webinar Series: Essentials for Adopting Passkeys as the Foundation of your...
FIDO Alliance
 
Mastering OnlyFans Clone App Development: Key Strategies for Success
Mastering OnlyFans Clone App Development: Key Strategies for SuccessMastering OnlyFans Clone App Development: Key Strategies for Success
Mastering OnlyFans Clone App Development: Key Strategies for Success
David Wilson
 
Garbage In, Garbage Out: Why poor data curation is killing your AI models (an...
Garbage In, Garbage Out: Why poor data curation is killing your AI models (an...Garbage In, Garbage Out: Why poor data curation is killing your AI models (an...
Garbage In, Garbage Out: Why poor data curation is killing your AI models (an...
Zilliz
 
Improving Learning Content Efficiency with Reusable Learning Content
Improving Learning Content Efficiency with Reusable Learning ContentImproving Learning Content Efficiency with Reusable Learning Content
Improving Learning Content Efficiency with Reusable Learning Content
Enterprise Knowledge
 
NVIDIA at Breakthrough Discuss for Space Exploration
NVIDIA at Breakthrough Discuss for Space ExplorationNVIDIA at Breakthrough Discuss for Space Exploration
NVIDIA at Breakthrough Discuss for Space Exploration
Alison B. Lowndes
 
Accelerating Migrations = Recommendations
Accelerating Migrations = RecommendationsAccelerating Migrations = Recommendations
Accelerating Migrations = Recommendations
isBullShit
 
COVID-19 and the Level of Cloud Computing Adoption: A Study of Sri Lankan Inf...
COVID-19 and the Level of Cloud Computing Adoption: A Study of Sri Lankan Inf...COVID-19 and the Level of Cloud Computing Adoption: A Study of Sri Lankan Inf...
COVID-19 and the Level of Cloud Computing Adoption: A Study of Sri Lankan Inf...
AimanAthambawa1
 
Google I/O Extended Harare Merged Slides
Google I/O Extended Harare Merged SlidesGoogle I/O Extended Harare Merged Slides
Google I/O Extended Harare Merged Slides
Google Developer Group - Harare
 
Computer HARDWARE presenattion by CWD students class 10
Computer HARDWARE presenattion by CWD students class 10Computer HARDWARE presenattion by CWD students class 10
Computer HARDWARE presenattion by CWD students class 10
ankush9927
 
kk vathada _digital transformation frameworks_2024.pdf
kk vathada _digital transformation frameworks_2024.pdfkk vathada _digital transformation frameworks_2024.pdf
kk vathada _digital transformation frameworks_2024.pdf
KIRAN KV
 
Vulnerability Management: A Comprehensive Overview
Vulnerability Management: A Comprehensive OverviewVulnerability Management: A Comprehensive Overview
Vulnerability Management: A Comprehensive Overview
Steven Carlson
 
Premium Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service ...
Premium Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service ...Premium Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service ...
Premium Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service ...
shanihomely
 
Retrieval Augmented Generation Evaluation with Ragas
Retrieval Augmented Generation Evaluation with RagasRetrieval Augmented Generation Evaluation with Ragas
Retrieval Augmented Generation Evaluation with Ragas
Zilliz
 
Discovery Series - Zero to Hero - Task Mining Session 1
Discovery Series - Zero to Hero - Task Mining Session 1Discovery Series - Zero to Hero - Task Mining Session 1
Discovery Series - Zero to Hero - Task Mining Session 1
DianaGray10
 
Vertex AI Agent Builder - GDG Alicante - Julio 2024
Vertex AI Agent Builder - GDG Alicante - Julio 2024Vertex AI Agent Builder - GDG Alicante - Julio 2024
Vertex AI Agent Builder - GDG Alicante - Julio 2024
Nicolás Lopéz
 
Types of Weaving loom machine & it's technology
Types of Weaving loom machine & it's technologyTypes of Weaving loom machine & it's technology
Types of Weaving loom machine & it's technology
ldtexsolbl
 

Recently uploaded (20)

Communications Mining Series - Zero to Hero - Session 3
Communications Mining Series - Zero to Hero - Session 3Communications Mining Series - Zero to Hero - Session 3
Communications Mining Series - Zero to Hero - Session 3
 
Semantic-Aware Code Model: Elevating the Future of Software Development
Semantic-Aware Code Model: Elevating the Future of Software DevelopmentSemantic-Aware Code Model: Elevating the Future of Software Development
Semantic-Aware Code Model: Elevating the Future of Software Development
 
leewayhertz.com-AI agents for healthcare Applications benefits and implementa...
leewayhertz.com-AI agents for healthcare Applications benefits and implementa...leewayhertz.com-AI agents for healthcare Applications benefits and implementa...
leewayhertz.com-AI agents for healthcare Applications benefits and implementa...
 
Redefining Cybersecurity with AI Capabilities
Redefining Cybersecurity with AI CapabilitiesRedefining Cybersecurity with AI Capabilities
Redefining Cybersecurity with AI Capabilities
 
UX Webinar Series: Essentials for Adopting Passkeys as the Foundation of your...
UX Webinar Series: Essentials for Adopting Passkeys as the Foundation of your...UX Webinar Series: Essentials for Adopting Passkeys as the Foundation of your...
UX Webinar Series: Essentials for Adopting Passkeys as the Foundation of your...
 
Mastering OnlyFans Clone App Development: Key Strategies for Success
Mastering OnlyFans Clone App Development: Key Strategies for SuccessMastering OnlyFans Clone App Development: Key Strategies for Success
Mastering OnlyFans Clone App Development: Key Strategies for Success
 
Garbage In, Garbage Out: Why poor data curation is killing your AI models (an...
Garbage In, Garbage Out: Why poor data curation is killing your AI models (an...Garbage In, Garbage Out: Why poor data curation is killing your AI models (an...
Garbage In, Garbage Out: Why poor data curation is killing your AI models (an...
 
Improving Learning Content Efficiency with Reusable Learning Content
Improving Learning Content Efficiency with Reusable Learning ContentImproving Learning Content Efficiency with Reusable Learning Content
Improving Learning Content Efficiency with Reusable Learning Content
 
NVIDIA at Breakthrough Discuss for Space Exploration
NVIDIA at Breakthrough Discuss for Space ExplorationNVIDIA at Breakthrough Discuss for Space Exploration
NVIDIA at Breakthrough Discuss for Space Exploration
 
Accelerating Migrations = Recommendations
Accelerating Migrations = RecommendationsAccelerating Migrations = Recommendations
Accelerating Migrations = Recommendations
 
COVID-19 and the Level of Cloud Computing Adoption: A Study of Sri Lankan Inf...
COVID-19 and the Level of Cloud Computing Adoption: A Study of Sri Lankan Inf...COVID-19 and the Level of Cloud Computing Adoption: A Study of Sri Lankan Inf...
COVID-19 and the Level of Cloud Computing Adoption: A Study of Sri Lankan Inf...
 
Google I/O Extended Harare Merged Slides
Google I/O Extended Harare Merged SlidesGoogle I/O Extended Harare Merged Slides
Google I/O Extended Harare Merged Slides
 
Computer HARDWARE presenattion by CWD students class 10
Computer HARDWARE presenattion by CWD students class 10Computer HARDWARE presenattion by CWD students class 10
Computer HARDWARE presenattion by CWD students class 10
 
kk vathada _digital transformation frameworks_2024.pdf
kk vathada _digital transformation frameworks_2024.pdfkk vathada _digital transformation frameworks_2024.pdf
kk vathada _digital transformation frameworks_2024.pdf
 
Vulnerability Management: A Comprehensive Overview
Vulnerability Management: A Comprehensive OverviewVulnerability Management: A Comprehensive Overview
Vulnerability Management: A Comprehensive Overview
 
Premium Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service ...
Premium Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service ...Premium Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service ...
Premium Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service ...
 
Retrieval Augmented Generation Evaluation with Ragas
Retrieval Augmented Generation Evaluation with RagasRetrieval Augmented Generation Evaluation with Ragas
Retrieval Augmented Generation Evaluation with Ragas
 
Discovery Series - Zero to Hero - Task Mining Session 1
Discovery Series - Zero to Hero - Task Mining Session 1Discovery Series - Zero to Hero - Task Mining Session 1
Discovery Series - Zero to Hero - Task Mining Session 1
 
Vertex AI Agent Builder - GDG Alicante - Julio 2024
Vertex AI Agent Builder - GDG Alicante - Julio 2024Vertex AI Agent Builder - GDG Alicante - Julio 2024
Vertex AI Agent Builder - GDG Alicante - Julio 2024
 
Types of Weaving loom machine & it's technology
Types of Weaving loom machine & it's technologyTypes of Weaving loom machine & it's technology
Types of Weaving loom machine & it's technology
 

Physical prototyping lab2-analog_digital

  • 1. Implement the light effect as seen in KIT, the Knight Rider car from the 80's TV series with David Hasselhoff. The sequence should be activated when a user presses a button HOMEWORK: KNIGHT RIDER 1
  • 2. HOMEWORK: SOLVING IT Besides wiring the breadboard, you had to write the program needed to make it work. The “clever” solution makes use of arrays, we iterate through them using a FOR loop. 2
  • 3. PHYSICAL PROTOTYPING © 2011 K3 Creative Commons v3.0 SA-NC Lab 2: Analog & Digital With the Arduino prototyping board
  • 4. for(counter=0; counter<end; counter++){} 1)The FOR loop is a software construct that will execute a block of code a number of times. 2)The code will be looped until a certain condition is met 3)FOR loops are constructed with an initialization value, a condition statement, and a counting statement 4)We use them to iterate a certain action a determined amount of times counter initialization FOR LOOP condition counter increment / decrement 4
  • 5. ARRAYS 1) ARRAYS are sets of indexed values arranged in order in the processor's memory 2) All the elements in an array have an unique identifier 3) The different “positions” in the array are addressed through numerical index values between squared brackets 4) Array constructors include the type, and the size of the array (the number of elements they consist of) 5) The elements of an empty array are NULL (nothing) 6) It is possible to initialize an array with a specific set of values: E.g. int theList[] = {1, 3, 'e', 19}; 5
  • 6. WHAT IS “ANALOG”? The real world is NOT digital. Temperature fluctuation, for example, involves a range of values and generally does not changes abruptly over time. Using analog sensors we measure environmental parameters like temperature, light intensity, etc. These are a set of analog values 6
  • 7. Are sensors which transform environmental parameters into a multi-level voltage value (between 0 and 5 volts) There are many types of sensors that provide us with analog voltage values: LDR (or CDS): light dependent resistors aka light sensors NTC and PTC: temperature dependent resistors aka temperature sensors Potentiometers and sliders: angle and position dependent resistors ANALOG SENSORS 7
  • 8. READING ANALOG VALUES  Microprocessors cannot handle analog values as humans do. They need to be translated into digital data, something the microchip can understand.  Sensors transform real world data like the temperature into a voltage value between 0 and 5 volts. These values are different from the HIGH (1) and LOW (0) that characterize digital signals, because they can take any value between 0 and 5 volts. E.g: 0.3 volts, 3.27 volts, 4.99 volts are possible values.  The readings resolution depends on the capabilities of the processor/microcontroller you are using. Arduino can distinguish 1024 different levels between 0 and 5 volts. 8
  • 9.  Are devices which change resistance (and thus the voltage) when you twist or slide them.  Arduino can measure the voltage which flows through them.  We can use this data to control other things, like LED’s.  We call potentiometer those that rotate around one of their axis  We call sliders those that move linearly along one of their axis POTENTIOMETERS vs SLIDERS A circuit using a potentiometer A circuit using a slider 9
  • 10. CONNECTING THE POTENTIOMETER Potentiometers are useful for improvising quick interfaces. The recommended resistive value is 10 Kilo Ohms. (10K) On the Arduino board there are 6 Analog Input pins, they are numbered from 0 to 5. Analog inputs are not declared in the setup of the programs, unlike the Digital Inputs. We will use this easy circuit to control the oscillation speed of the basic Blink-LED example 10
  • 11. analogRead(pin number);  Returns the value from a specific analog port  Values from 0 to 1023  0v = 0  5v = 1023 READING THE SENSOR 11
  • 12. int potPin = 2; // select the input pin for the potentiometer int ledPin = 13; // select the pin for the LED int val = 0; // variable to store the value coming from the // sensor void setup() { pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT } void loop() { val = analogRead(potPin); // read the value from the sensor digitalWrite(ledPin, HIGH); // turn the ledPin on delay(val); // stop the program for some time digitalWrite(ledPin, LOW); // turn the ledPin off delay(val); // stop the program for some time } EXAMPLES ► ANALOG ► ANALOG INPUT
  • 13. LDR Light dependent resistor  We call the resistor a “pull up” resistor  It is usually 10K  You can use exactly the same code as in the previous example 13
  • 14. FADING LEDS 1) LEDs are Light Emmitting Diodes, and can only be turned on or off. 2) However, it is possible to fake their level of intensity through the use of a mathematical trick called PWM (Pulse Width Modulation) which will be explained later. 3) In essence, what you need to know for making the next experiment, is that there is a function called analogWrite(pin, intensity) that will write an analog value to one of the PWM- labelled pins on your prototyping boards. 4) PWM runs in parallel to the rest of Arduino, which means it will not stop any of the other processes which are running. 5) Hook up one LED with it's correspondent resistor to e.g. pin 10, and execute the following example. 14
  • 15. EXAMPLES ► ANALOG ► FADING LED int value = 0; // variable to keep the actual value int ledpin = 9; // light connected to digital pin 9 void setup() { // nothing for setup } void loop() { for(value = 0; value <= 255; value+=5) // fade in (from min to max) { analogWrite(ledpin, value); delay(30); // waits for 30 milliseconds } for(value = 255; value >=0; value-=5) // fade out (from max to min) { analogWrite(ledpin, value); delay(30); } }
  • 16. SERIAL COMMUNICATION USING THE SERIAL LIBRARY Serial.xxxx Serial defines a method to use the serial port Serial.begin(baud); Placed in setup to initiate serial communication ”baud” is baudrate (”communication-speed”) Serial.print(); Writes (sends) something to the serial port Serial.println(); Writes (sends) with cr and lf 16
  • 17. PROGRAMMING SUMMARY Commonly used Arduino methods: int analogRead(pin); reads an analog value from an analog pin number analogWrite(pin, value); writes a time-dependant signal through the use of the so-called PWM pins Serial.println(data); sends data back to the computer to be seen through the serial monitor Serial.begin(baud); opens the serial communication at baud speed 17

Editor's Notes

  1. Encourage people to interrupt you so you can help them immediately. Explain they do you a favor. It’s good to time the duration of the presentation.
  2. Explain the three parameters.
  3. Again use the cooky jar analogy. Explain the importance of positions. Position 0 is the first position in the array. Instead of 1. Find an explanatory picture
  4. The real world has a range of values between 0 and 1. Arduino does not understand ranges of values. The analog pins are used to transform values between a resistance measurement between 0 and 5 volts, chopped up in a range of 1024 values.
  5. LDR means Light Dependent Resistor. Resistor which changes value based on the amount of light. NTC, temperature sensor, gives value between 0 and 1024 based on temperature. NTC means Negative Temperature Coefficient resistor, NTC’s are also called Thermistors. Potentiometers and sliders. These are commonly used in equalizers, and hi-fi sets and other consumer electronics. Explain potentiometer. It used 3 pins, An analog pin, power and ground. You actually measure the resistance through the potentiometer to the ground. Always connect the middle pin on the potentiometer to an analog pin first, because if you mix the pins up then it burns out! The power and ground pins don’t matter which way around you connect them, only the values will be inverted. Explain analogRead. When it reads 0 it means there is 0 volts going through the potentiometer, if it shows 1023 then 5 volts is going through it.
  6. Finns det tid så kombinera med knight ridern!
  7. Do a livecoding session showing the analog input session
  8. Explain how you can make an LED burn at half brightness by quickly turning it on and off. Water analogy: Turning on and off a water tap to make a steady flow. PWM pins: 3,5,6,10,11 identifiable the tilde ~ sign. Now finally Windows users can have that nice fading LED effect when they charge their computer. ;) Let’s do live coding here also, the fading LED example
  9. Next time: Serial communication. Serial communication is a library so we can call it when we need it. You don’t always need it so you can save space by leaving it out. Use println to print out data on a new line. Otherwise it lines up and becomes illegible. What we explained now is 90% of all the code you ever need to write. CR = carriage return LF = line feed
  10. Get some funny examples to show.