This document provides an overview of basic Arduino code structure and programming concepts. It explains that Arduino programs have two main sections - setup() and loop(). Setup() is used to initialize inputs and outputs, and loop() contains the repeating code. It also covers digital input/output functions, variables, conditional statements, boolean logic, and interrupts. Examples are provided for blinking LEDs, reading sensors, and creating simple programs.
The following presentation is a part of the level 4 module -- Digital Logic and Signal Principles. This resources is a part of the 2009/2010 Engineering (foundation degree, BEng and HN) courses from University of Wales Newport (course codes H101, H691, H620, HH37 and 001H). This resource is a part of the core modules for the full time 1st year undergraduate programme.
The BEng & Foundation Degrees and HNC/D in Engineering are designed to meet the needs of employers by placing the emphasis on the theoretical, practical and vocational aspects of engineering within the workplace and beyond. Engineering is becoming more high profile, and therefore more in demand as a skill set, in today’s high-tech world. This course has been designed to provide you with knowledge, skills and practical experience encountered in everyday engineering environments.
The following presentation is a part of the level 4 module -- Digital Logic and Signal Principles. This resources is a part of the 2009/2010 Engineering (foundation degree, BEng and HN) courses from University of Wales Newport (course codes H101, H691, H620, HH37 and 001H). This resource is a part of the core modules for the full time 1st year undergraduate programme.
The BEng & Foundation Degrees and HNC/D in Engineering are designed to meet the needs of employers by placing the emphasis on the theoretical, practical and vocational aspects of engineering within the workplace and beyond. Engineering is becoming more high profile, and therefore more in demand as a skill set, in today’s high-tech world. This course has been designed to provide you with knowledge, skills and practical experience encountered in everyday engineering environments.
Logic gates ANS gate nor gate xor gate nor gate all the gates in the DLD digital logic design. all the gates are explain in details
for more go to www.healthbeautytips.com.pk
Logic gates ANS gate nor gate xor gate nor gate all the gates in the DLD digital logic design. all the gates are explain in details
for more go to www.healthbeautytips.com.pk
What will be quantization step size in numbers and in voltage for th.pdfSIGMATAX1
What will be quantization step size in numbers and in voltage for this Arduino Code? Using 5V
const int led1 = 2;
const int led2 = 3;
const int led3 = 4;
void setup() {
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
int dataConv = sensorValue*(8.0/1024);
//write analog equvivalant data on led pins
switch(dataConv)
{
case 0: {
digitalWrite(led1,LOW);
digitalWrite(led2,LOW);
digitalWrite(led3,LOW);
break;
}
case 1: {
digitalWrite(led1,HIGH);
digitalWrite(led2,LOW);
digitalWrite(led3,LOW);
break;
}
case 2: {
digitalWrite(led1,LOW);
digitalWrite(led2,HIGH);
digitalWrite(led3,LOW);
break;
}
case 3: {
digitalWrite(led1,HIGH);
digitalWrite(led2,HIGH);
digitalWrite(led3,LOW);
break;
}
case 4: {
digitalWrite(led1,LOW);
digitalWrite(led2,LOW);
digitalWrite(led3,HIGH);
break;
}
case 5: {
digitalWrite(led1,HIGH);
digitalWrite(led2,LOW);
digitalWrite(led3,HIGH);
break;
}
case 6: {
digitalWrite(led1,LOW);
digitalWrite(led2,HIGH);
digitalWrite(led3,HIGH);
break;
}
case 7: {
digitalWrite(led1,HIGH);
digitalWrite(led2,HIGH);
digitalWrite(led3,HIGH);
break;
}
}
Serial.println(sensorValue); // print out the value you read:
Serial.println(dataConv);
delay(1000); // delay in between reads for stability
}
const int led1 = 2;
const int led2 = 3;
const int led3 = 4;
void setup() {
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
int dataConv = sensorValue*(8.0/1024);
//write analog equvivalant data on led pins
switch(dataConv)
{
case 0: {
digitalWrite(led1,LOW);
digitalWrite(led2,LOW);
digitalWrite(led3,LOW);
break;
}
case 1: {
digitalWrite(led1,HIGH);
digitalWrite(led2,LOW);
digitalWrite(led3,LOW);
break;
}
case 2: {
digitalWrite(led1,LOW);
digitalWrite(led2,HIGH);
digitalWrite(led3,LOW);
break;
}
case 3: {
digitalWrite(led1,HIGH);
digitalWrite(led2,HIGH);
digitalWrite(led3,LOW);
break;
}
case 4: {
digitalWrite(led1,LOW);
digitalWrite(led2,LOW);
digitalWrite(led3,HIGH);
break;
}
case 5: {
digitalWrite(led1,HIGH);
digitalWrite(led2,LOW);
digitalWrite(led3,HIGH);
break;
}
case 6: {
digitalWrite(led1,LOW);
digitalWrite(led2,HIGH);
digitalWrite(led3,HIGH);
break;
}
case 7: {
digitalWrite(led1,HIGH);
digitalWrite(led2,HIGH);
digitalWrite(led3,HIGH);
break;
}
}
Serial.println(sensorValue); // print out the value you read:
Serial.println(dataConv);
delay(1000); // delay in between reads for stability
}
Solution
// Random LED Dots - from noise source
// Ed Nisley - KE4ANU - September 2015
//----------
// Pin assignments
const byte PIN_HEARTBEAT = 8; // DO - heartbeat LED
const byte PIN_SYNC = A3; // DO.
A piece of computer hardware and software that is designed to achieve a specific goal, either independently or as part of a larger system, is referred to as embedded system programming.
Introduction to Digital Marketing Certification Course.pdfThe IOT Academy
Digital marketing refers to the promotion of products, services, or brands using digital technologies such as the Internet, social media, search engines, mobile devices, and other digital channels. Digital marketing involves a range of strategies that are used to reach and engage with target audiences through various digital platforms.
Table of Contents
● What is SEO?
● Examples of popular Search Engines
● Search Engines Market share
● Why is Search Engine marketing important?
● Advantages of SEO
● Disadvantages of SEO
● What is a SEO Algorithm?
● Steps to developing a good SEO Strategy
● SEO Ranking Factors
● Basic tips for optimization
● Top SEO Tools
● Conclusion
C++ is an Object-Oriented Programming Language which was developed by Bjarne Stroustrup at Bell Labs in the year 1980. It is based on C Language. It is created for writing programs for different purposes. It is procedural / functional / object-oriented / generic / imperative in nature. You can create Softwares and Video Games in C++. You can make Desktop Applications, GUI Applications, Game Applications, Graphic Designing Applications in C++.
Machine Learning (ML) gives computers the capability to learn without being explicitly programmed. It is a subset of artificial intelligence. We can use Machine Learning with Python Programming for Face Recognition/ Online customer support/ Product recommendations/ Online Fraud Detection/ Video Surveillance/ Social media services/ Refining search-engine results /Automatic Translation /Self-driving cars/ Virtual Personal Assistants/ Predicting Music Choices, etc.
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
As AI technology is pushing into IT I was wondering myself, as an “infrastructure container kubernetes guy”, how get this fancy AI technology get managed from an infrastructure operational view? Is it possible to apply our lovely cloud native principals as well? What benefit’s both technologies could bring to each other?
Let me take this questions and provide you a short journey through existing deployment models and use cases for AI software. On practical examples, we discuss what cloud/on-premise strategy we may need for applying it to our own infrastructure to get it to work from an enterprise perspective. I want to give an overview about infrastructure requirements and technologies, what could be beneficial or limiting your AI use cases in an enterprise environment. An interactive Demo will give you some insides, what approaches I got already working for real.
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
Sidekick Solutions uses Bonterra Impact Management (fka Social Solutions Apricot) and automation solutions to integrate data for business workflows.
We believe integration and automation are essential to user experience and the promise of efficient work through technology. Automation is the critical ingredient to realizing that full vision. We develop integration products and services for Bonterra Case Management software to support the deployment of automations for a variety of use cases.
This video focuses on the notifications, alerts, and approval requests using Slack for Bonterra Impact Management. The solutions covered in this webinar can also be deployed for Microsoft Teams.
Interested in deploying notification automations for Bonterra Impact Management? Contact us at sales@sidekicksolutionsllc.com to discuss next steps.
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
Generating a custom Ruby SDK for your web service or Rails API using Smithyg2nightmarescribd
Have you ever wanted a Ruby client API to communicate with your web service? Smithy is a protocol-agnostic language for defining services and SDKs. Smithy Ruby is an implementation of Smithy that generates a Ruby SDK using a Smithy model. In this talk, we will explore Smithy and Smithy Ruby to learn how to generate custom feature-rich SDKs that can communicate with any web service, such as a Rails JSON API.
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
Are you looking to streamline your workflows and boost your projects’ efficiency? Do you find yourself searching for ways to add flexibility and control over your FME workflows? If so, you’re in the right place.
Join us for an insightful dive into the world of FME parameters, a critical element in optimizing workflow efficiency. This webinar marks the beginning of our three-part “Essentials of Automation” series. This first webinar is designed to equip you with the knowledge and skills to utilize parameters effectively: enhancing the flexibility, maintainability, and user control of your FME projects.
Here’s what you’ll gain:
- Essentials of FME Parameters: Understand the pivotal role of parameters, including Reader/Writer, Transformer, User, and FME Flow categories. Discover how they are the key to unlocking automation and optimization within your workflows.
- Practical Applications in FME Form: Delve into key user parameter types including choice, connections, and file URLs. Allow users to control how a workflow runs, making your workflows more reusable. Learn to import values and deliver the best user experience for your workflows while enhancing accuracy.
- Optimization Strategies in FME Flow: Explore the creation and strategic deployment of parameters in FME Flow, including the use of deployment and geometry parameters, to maximize workflow efficiency.
- Pro Tips for Success: Gain insights on parameterizing connections and leveraging new features like Conditional Visibility for clarity and simplicity.
We’ll wrap up with a glimpse into future webinars, followed by a Q&A session to address your specific questions surrounding this topic.
Don’t miss this opportunity to elevate your FME expertise and drive your projects to new heights of efficiency.
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
2. Arduino Code Basics
Arduino programs run on two basic sections:
void setup() {
//setup motors, sensors etc
}
void loop() {
// get information from sensors
// send commands to motors
}
3. SETUP
The setup section is used for assigning input and
outputs (Examples: motors, LED’s, sensors etc) to
ports on the Arduino
It also specifies whether the device is OUTPUT or
INPUT
To do this we use the command “pinMode”
3
5. LOOP
5
void loop() {
digitalWrite(9, HIGH);
delay(1000);
digitalWrite(9, LOW);
delay(1000);
}
Port # from setup
Turn the LED on
or off
Wait for 1 second
or 1000 milliseconds
6. TASK 1
Using 3 LED’s (red, yellow and green) build a traffic
light that
Illuminates the green LED for 5 seconds
Illuminates the yellow LED for 2 seconds
Illuminates the red LED for 5 seconds
repeats the sequence
Note that after each illumination period the LED is
turned off!
6
7. TASK 2
Modify Task 1 to have an advanced green (blinking
green LED) for 3 seconds before illuminating the
green LED for 5 seconds
7
16. IF Example
16
int counter = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
if(counter < 10)
{
Serial.println(counter);
}
counter = counter + 1;
}
17. Integer: used with integer variables with value between
2147483647 and -2147483647.
Ex: int x=1200;
Character: used with single character, represent value from -
127 to 128.
Ex. char c=‘r’;
Long: Long variables are extended size variables for number
storage, and store 32 bits (4 bytes), from -2,147,483,648 to
2,147,483,647.
Ex. long u=199203;
Floating-point numbers can be as large as 3.4028235E+38and
as low as -3.4028235E+38.They are stored as 32 bits (4 bytes) of
information.
Ex. float num=1.291; [The same as double type]
Data Types and operators
18. Statement represents a command, it ends with ;
Ex:
int x;
x=13;
Operators are symbols that used to indicate a specific
function:
- Math operators: [+,-,*,/,%,^]
- Logic operators: [==, !=, &&, ||]
- Comparison operators: [==, >, <, !=, <=, >=]
Syntax:
; Semicolon, {} curly braces, //single line comment,
/*Multi-linecomments*/
Statement and operators:
21. Switch case:
switch (var) {
case 1:
//do somethingwhen var equals 1
break;
case 2:
//do somethingwhen var equals 2
break;
default:
// if nothing else matches, do the default
// default is optional
}
Control statements:
22. Do… while:
do
{
Statements;
}
while(condition); // thestatementsare run at least once.
While:
While(condition)
{statements;}
for
for (int i=0; i <= val; i++){
statements;
}
Loop statements:
Use break statement to stop the loop whenever needed.
23. Void setup(){}
Used to indicate the initial values of system on starting.
Void loop(){}
Contains the statements that will run whenever the system is powered
after setup.
Code structure:
24. Led blinking example:
Used functions:
pinMode();
digitalRead();
digitalWrite();
delay(time_ms);
other functions:
analogRead();
analogWrite();//PWM.
Input and output:
25. Input & Output
Transferring data from the computer to an Arduino is
done using Serial Transmission
To setup Serial communication we use the following
25
void setup() {
Serial.begin(9600);
}
26. Writing to the Console
26
void setup() {
Serial.begin(9600);
Serial.println(“Hello World!”);
}
void loop() {}
27. IF - ELSE Condition
if( “answer is true”)
{
“perform some action”
}
else
{
“perform some other action”
}
28. IF - ELSE Example
28
int counter = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
if(counter < 10)
{
Serial.println(“less than 10”);
}
else
{
Serial.println(“greater than or equal to 10”);
Serial.end();
}
counter = counter + 1;
}
29. IF - ELSE IF Condition
if( “answer is true”)
{
“perform some action”
}
else if( “answer is true”)
{
“perform some other action”
}
30. IF - ELSE Example
30
int counter = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
if(counter < 10)
{
Serial.println(“less than 10”);
}
else if (counter == 10)
{
Serial.println(“equal to 10”);
}
else
{
Serial.println(“greater than 10”);
Serial.end();
}
counter = counter + 1;
}
31. BOOLEAN OPERATORS - AND
If we want all of the conditions to be true we need to use ‘AND’ logic
(AND gate)
We use the symbols &&
Example
31
if ( val > 10 && val < 20)
32. BOOLEAN OPERATORS - OR
If we want either of the conditions to be true we need to use ‘OR’
logic (OR gate)
We use the symbols ||
Example
32
if ( val < 10 || val > 20)
33. TASK
Create a program that illuminates the green LED if the counter is
less than 100, illuminates the yellow LED if the counter is between
101 and 200 and illuminates the red LED if the counter is greater
than 200
33
34. INPUT
We can also use our Serial connection to get input from the computer
to be used by the Arduino
34
int val = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
if(Serial.available() > 0) {
val = Serial.read();
Serial.println(val);
}
}
35. Task
Using input and output commands find the ASCII values of
35
#
1
2
3
4
5
ASCII
49
50
51
52
53
#
6
7
8
9
ASCII
54
55
56
57
@
a
b
c
d
e
f
g
ASCII
97
98
99
100
101
102
103
@
h
i
j
k
l
m
n
ASCII
104
105
106
107
108
109
110
@
o
p
q
r
s
t
u
ASCII
111
112
113
114
115
116
117
@
v
w
x
y
z
ASCII
118
119
120
121
122
36. INPUT EXAMPLE
36
int val = 0;
int greenLED = 13;
void setup() {
Serial.begin(9600);
pinMode(greenLED, OUTPUT);
}
void loop() {
if(Serial.available()>0) {
val = Serial.read();
Serial.println(val);
}
if(val == 53) {
digitalWrite(greenLED, HIGH);
}
else {
digitalWrite(greenLED, LOW);
}
}
37. Task
Create a program so that when the user enters 1 the green
light is illuminated, 2 the yellow light is illuminated and 3
the red light is illuminated
37
• Create a program so that when the user enters ‘b’ the
green light blinks, ‘g’ the green light is illuminated ‘y’
the yellow light is illuminated and ‘r’ the red light is
illuminated
40. TASK
Write a program that asks the user for a number and outputs the
number that is entered. Once the number has been output the
program finishes.
EXAMPLE:
40
Please enter a number: 1 <enter>
The number you entered was: 1
41. TASK
Write a program that asks the user for a number and
outputs the number squared that is entered. Once the
number has been output the program finishes.
41
Please enter a number: 4 <enter>
Your number squared is: 16
42. Important functions
Serial.println(value);
Prints the value to the Serial Monitor on your computer
pinMode(pin, mode);
Configures a digital pin to read (input) or write (output) a digital value
digitalRead(pin);
Reads a digital value (HIGH or LOW) on a pin set for input
digitalWrite(pin, value);
Writes the digital value (HIGH or LOW) to a pin set for output
43. Using LEDs
void setup()
{
pinMode(77, OUTPUT); //configure pin 77 as output
}
// blink an LED once
void blink1()
{
digitalWrite(77,HIGH); // turn the LED on
delay(500); // wait 500 milliseconds
digitalWrite(77,LOW); // turn the LED off
delay(500); // wait 500 milliseconds
}
44. Creating infinite loops
void loop() //blink a LED repeatedly
{
digitalWrite(77,HIGH); // turn the LED on
delay(500); // wait 500 milliseconds
digitalWrite(77,LOW); // turn the LED off
delay(500); // wait 500 milliseconds
}
45. Using switches and buttons
const int inputPin = 2; // choose the input pin
void setup() {
pinMode(inputPin, INPUT); // declare pushbutton as input
}
void loop(){
int val = digitalRead(inputPin); // read input value
}
46. Reading analog inputs and scaling
const int potPin = 0; // select the input pin for the potentiometer
void loop() {
int val; // The value coming from the sensor
int percent; // The mapped value
val = analogRead(potPin); // read the voltage on the pot (val ranges from 0 to
1023)
percent = map(val,0,1023,0,100); // percent will range from 0 to 100.
47. Creating a bar graph using LEDs
const int NoLEDs = 8;
const int ledPins[] = { 70, 71, 72, 73, 74, 75, 76, 77};
const int analogInPin = 0; // Analog input pin const int wait = 30;
const boolean LED_ON = HIGH;
const boolean LED_OFF = LOW;
int sensorValue = 0; // value read from the sensor
int ledLevel = 0; // sensor value converted into LED 'bars'
void setup() {
for (int i = 0; i < NoLEDs; i++)
{
pinMode(ledPins[i], OUTPUT); // make all the LED pins outputs
}
}
48. Creating a bar graph using LEDs
void loop() {
sensorValue = analogRead(analogInPin); // read the analog in value
ledLevel = map(sensorValue, 0, 1023, 0, NoLEDs); // map to the number of LEDs
for (int i = 0; i < NoLEDs; i++)
{
if (i < ledLevel ) {
digitalWrite(ledPins[i], LED_ON); // turn on pins less than the level
}
else {
digitalWrite(ledPins[i], LED_OFF); // turn off pins higher than the level:
}
}
}
49. Measuring Temperature
const int inPin = 0; // analog pin
void loop()
{
int value = analogRead(inPin);
float millivolts = (value / 1024.0) * 3300; //3.3V
analog input
float celsius = millivolts / 10; // sensor output is
10mV per degree Celsius
delay(1000); // wait for one second
}
50. Reading data from Arduino
void setup()
{
Serial.begin(9600);
}
void serialtest()
{
int i;
for(i=0; i<10; i++)
Serial.println(i);
}
51. Using Interrupts
On a standard Arduino board, two pins can be used as interrupts:
pins 2 and 3.
The interrupt is enabled through the following line:
attachInterrupt(interrupt, function, mode)
attachInterrupt(0, doEncoder, FALLING);
52. Interrupt example
int led = 77;
volatile int state = LOW;
void setup()
{
pinMode(led, OUTPUT);
attachInterrupt(1, blink, CHANGE);
}
void loop()
{
digitalWrite(led, state);
}
void blink()
{
state = !state;
}
53. Timer functions (timer.h library)
int every(long period, callback)
Run the 'callback' every 'period' milliseconds. Returns the ID of
the timer event.
int every(long period, callback, int repeatCount)
Run the 'callback' every 'period' milliseconds for a total of
'repeatCount' times. Returns the ID of the timer event.
int after(long duration, callback)
Run the 'callback' once after 'period' milliseconds. Returns the ID
of the timer event.
54. Timer functions (timer.h library)
int oscillate(int pin, long period, int startingValue)
Toggle the state of the digital output 'pin' every 'period' milliseconds.
The pin's starting value is specified in 'startingValue', which should be
HIGH or LOW. Returns the ID of the timer event.
int oscillate(int pin, long period, int startingValue, int repeatCount)
Toggle the state of the digital output 'pin' every 'period' milliseconds
'repeatCount' times. The pin's starting value is specified in
'startingValue', which should be HIGH or LOW. Returns the ID of the
timer event.
55. Timer functions (Timer.h library)
int pulse(int pin, long period, int startingValue)
Toggle the state of the digital output 'pin' just once after 'period'
milliseconds. The pin's starting value is specified in 'startingValue',
which should be HIGH or LOW. Returns the ID of the timer event.
int stop(int id)
Stop the timer event running. Returns the ID of the timer event.
int update()
Must be called from 'loop'. This will service all the events associated
with the timer.
56. Example (1/2)
#include "Timer.h"
Timer t;
int ledEvent;
void setup()
{
Serial.begin(9600);
int tickEvent = t.every(2000, doSomething);
Serial.print("2 second tick started id=");
Serial.println(tickEvent);
pinMode(13, OUTPUT);
ledEvent = t.oscillate(13, 50, HIGH);
Serial.print("LED event started id=");
Serial.println(ledEvent);
int afterEvent = t.after(10000, doAfter);
Serial.print("After event started id=");
Serial.println(afterEvent);
}
57. Example (2/2)
void loop()
{
t.update();
}
void doSomething()
{
Serial.print("2 second tick: millis()=");
Serial.println(millis());
}
void doAfter()
{
Serial.println("stop the led event");
t.stop(ledEvent);
t.oscillate(13, 500, HIGH, 5);
}
58. Digital I/O
pinMode(pin, mode)
Sets pin to either INPUT or OUTPUT
digitalRead(pin)
Reads HIGH or LOW from a pin
digitalWrite(pin, value)
Writes HIGH or LOW to a pin
Electronic stuff
Output pins can provide 40 mA of current
Writing HIGH to an input pin installs a 20KΩ pullup
59. Arduino Timing
• delay(ms)
– Pauses for a few milliseconds
• delayMicroseconds(us)
– Pauses for a few microseconds
• More commands:
arduino.cc/en/Reference/HomePage
61. Real-Time Operating System
An OS with response for time-controlled and event-controlled
processes.
Very essential for large scale
embedded systems.
62. Real-Time Operating System
Function
1. Basic OS function
2. RTOS main functions
3. Time Management
4. Predictability
5. Priorities Management
6. IPC Synchronization
7. Time slicing
8. Hard and soft real-time operability
63. When RTOS is necessary
Multiple simultaneous tasks/processes with hard time lines.
Inter Process Communication is necessary.
A common and effectiveway of handling of the hardware
source calls from the interrupts
I/O managementwith devices, files, mailboxes becomes
simple using an RTOS
Effectivelyscheduling and running and blocking of the tasks
in cases of many tasks.