programming for engineers - st.cs.uni-saarland.de
TRANSCRIPT
![Page 1: Programming for Engineers - st.cs.uni-saarland.de](https://reader034.vdocument.in/reader034/viewer/2022050116/626d2fa9e36b396e061a107c/html5/thumbnails/1.jpg)
Programming for Engineers
Winter 2015
Andreas Zeller, Saarland University
![Page 2: Programming for Engineers - st.cs.uni-saarland.de](https://reader034.vdocument.in/reader034/viewer/2022050116/626d2fa9e36b396e061a107c/html5/thumbnails/2.jpg)
A Computer• Device that
processes data according to an algorithm.
![Page 3: Programming for Engineers - st.cs.uni-saarland.de](https://reader034.vdocument.in/reader034/viewer/2022050116/626d2fa9e36b396e061a107c/html5/thumbnails/3.jpg)
Computers are everywhere
![Page 4: Programming for Engineers - st.cs.uni-saarland.de](https://reader034.vdocument.in/reader034/viewer/2022050116/626d2fa9e36b396e061a107c/html5/thumbnails/4.jpg)
Your Computer
![Page 5: Programming for Engineers - st.cs.uni-saarland.de](https://reader034.vdocument.in/reader034/viewer/2022050116/626d2fa9e36b396e061a107c/html5/thumbnails/5.jpg)
Arduino
• Physical-Computing-Platform for creating interactive, physical systems that connect hardware and software
• Microcontroller (processor) with analog and digital inputs and outputs
• Development environment on PC
![Page 6: Programming for Engineers - st.cs.uni-saarland.de](https://reader034.vdocument.in/reader034/viewer/2022050116/626d2fa9e36b396e061a107c/html5/thumbnails/6.jpg)
Input/Output
![Page 7: Programming for Engineers - st.cs.uni-saarland.de](https://reader034.vdocument.in/reader034/viewer/2022050116/626d2fa9e36b396e061a107c/html5/thumbnails/7.jpg)
Breadboard
![Page 8: Programming for Engineers - st.cs.uni-saarland.de](https://reader034.vdocument.in/reader034/viewer/2022050116/626d2fa9e36b396e061a107c/html5/thumbnails/8.jpg)
Plugging and Connecting
![Page 9: Programming for Engineers - st.cs.uni-saarland.de](https://reader034.vdocument.in/reader034/viewer/2022050116/626d2fa9e36b396e061a107c/html5/thumbnails/9.jpg)
Programming
![Page 10: Programming for Engineers - st.cs.uni-saarland.de](https://reader034.vdocument.in/reader034/viewer/2022050116/626d2fa9e36b396e061a107c/html5/thumbnails/10.jpg)
Goals
• Fundamentals of programming
• Handling of input/output devices
• Programming own controllers
![Page 11: Programming for Engineers - st.cs.uni-saarland.de](https://reader034.vdocument.in/reader034/viewer/2022050116/626d2fa9e36b396e061a107c/html5/thumbnails/11.jpg)
Structure
• Lecture on programming
• Exercise on Arduino-Board
• Free project
• Exam at the end of the course
![Page 12: Programming for Engineers - st.cs.uni-saarland.de](https://reader034.vdocument.in/reader034/viewer/2022050116/626d2fa9e36b396e061a107c/html5/thumbnails/12.jpg)
Lecture – topics on programming –
• Arduino overview
• Basics(commands, control, main loop)
• Functions with parameters
• Control structures
• Arrays
![Page 13: Programming for Engineers - st.cs.uni-saarland.de](https://reader034.vdocument.in/reader034/viewer/2022050116/626d2fa9e36b396e061a107c/html5/thumbnails/13.jpg)
Lecture• Characters
• Input/Output
• Algorithms
• Graphs
• Data structures
• Testing + Debugging
![Page 14: Programming for Engineers - st.cs.uni-saarland.de](https://reader034.vdocument.in/reader034/viewer/2022050116/626d2fa9e36b396e061a107c/html5/thumbnails/14.jpg)
Exercises – Projects –
• Blinkenlights
• Morse-Code
• Traffic light
• Nim the game
• Tic-Tac-Toe
![Page 15: Programming for Engineers - st.cs.uni-saarland.de](https://reader034.vdocument.in/reader034/viewer/2022050116/626d2fa9e36b396e061a107c/html5/thumbnails/15.jpg)
Exercises
• More Sensors
• Process measurements
• Navigation
• Webserver
• Internet of Things
![Page 16: Programming for Engineers - st.cs.uni-saarland.de](https://reader034.vdocument.in/reader034/viewer/2022050116/626d2fa9e36b396e061a107c/html5/thumbnails/16.jpg)
Work
![Page 17: Programming for Engineers - st.cs.uni-saarland.de](https://reader034.vdocument.in/reader034/viewer/2022050116/626d2fa9e36b396e061a107c/html5/thumbnails/17.jpg)
Team
![Page 18: Programming for Engineers - st.cs.uni-saarland.de](https://reader034.vdocument.in/reader034/viewer/2022050116/626d2fa9e36b396e061a107c/html5/thumbnails/18.jpg)
Success in a Team
![Page 19: Programming for Engineers - st.cs.uni-saarland.de](https://reader034.vdocument.in/reader034/viewer/2022050116/626d2fa9e36b396e061a107c/html5/thumbnails/19.jpg)
Exercises
1. Programming individually(to be submitted to tutor)
2. Executing and testing on own board3. Demonstration and individual
explanation to tutor
![Page 20: Programming for Engineers - st.cs.uni-saarland.de](https://reader034.vdocument.in/reader034/viewer/2022050116/626d2fa9e36b396e061a107c/html5/thumbnails/20.jpg)
Free Project• You come up with an Arduino project
(with hardware and software) in a group
• You implement the project
• Grading according toOriginalityComplexityFunctionality
![Page 21: Programming for Engineers - st.cs.uni-saarland.de](https://reader034.vdocument.in/reader034/viewer/2022050116/626d2fa9e36b396e061a107c/html5/thumbnails/21.jpg)
Light Clock Murat Güner, Maximilian Junk, Pierre Kehl and Thomas Kreis
![Page 22: Programming for Engineers - st.cs.uni-saarland.de](https://reader034.vdocument.in/reader034/viewer/2022050116/626d2fa9e36b396e061a107c/html5/thumbnails/22.jpg)
3 Datenstrukturen [15 Punkte]Einev
e
r
k
e
t
t
e
t
e
L
i
s
t
e ist eine dynamische Datenstruktur, die eine Speicherung von miteinander in
Beziehung stehenden Objekten erlaubt. Die Anzahl der Objekte ist im Vorhinein nicht bestimmt.
Die Liste wird durchZ
e
i
g
e
r auf das jeweils folgende Element realisiert.
Das folgende Bild zeigt eine Liste, bestehend aus drei Elementen. Jedes Element ist definiert als
s
t
r
u
c
t Elem {i
n
t value;// Der Wert
s
t
r
u
c
t Elem *next; // Zeiger auf das nächste Element
};
Der Zeiger des letzten Elements (hier 37) hat den Wert NULL.
Um auf eine Liste zuzugreifen, fängt man beim ersten Element (hier 12) an, und folgt dann den
Zeigern auf das jeweils nächste Element. Die folgende Funktion prüft, ob ein Element mit dem
Wertx in der Liste
e enthalten ist. Wenn ja, gibt sie einen Zeiger auf das Element zurück; wenn
nicht, gibt sie NULL zurück.// Erstes Element der Liste LIST mit Wert X zurückgeben
// (oder NULL, wenn nicht gefunden)s
t
r
u
c
t Elem *search(s
t
r
u
c
t Elem *list,i
n
t x) {
s
t
r
u
c
t Elem *e = list; // Erstes Element
w
h
i
l
e (e != NULL && e->value != x)e = e->next;
r
e
t
u
r
n e;}
Ihre Aufgabe ist es, eine Funktion zu schreiben, die ein gegebenes Elemente als letztes Element an
eine nicht-leere Listel
i
s
t anhängt.a) [3 Punkte] Nehmen wir an, Sie möchten ein Element mit Wert 44 an die Liste anhängen. Zeich-
nen Sie (ähnlich zu obigem Diagramm), wie die Liste nach dem Anhängen aussieht.
b) [8 Punkte] Um ein Element anzuhängen, müssen Sie zunächst das letzte Element finden.
Schreiben Sie eine Funktion last(), die (ähnlich wie search() oben) durch die Liste geht,
und das letzte Element liefert.// Letztes Element der Liste LIST zurückgeben
s
t
r
u
c
t Elem *last(s
t
r
u
c
t Elem *list) {// Ihr Code hier}
c) [4 Punkte] Gegeben sei nun ein existierendes ElementE . Nutzen Sie Ihre Funktion last(),
um an das letzte Listenelement das ElementE anzuhängen. Implementieren Sie die Funkti-
on append() entsprechend; achten Sie darauf, dass der Zeiger des (neuen) letzten Elements
anschließend NULL sein muss.// Element E an die Liste LIST anhängen
v
o
i
d append(s
t
r
u
c
t Elem *list,s
t
r
u
c
t Elem *e) {
// Ihr Code hier}
5
Exam
• Checks yourprogramming skills
• At the end of the course
• In English
![Page 23: Programming for Engineers - st.cs.uni-saarland.de](https://reader034.vdocument.in/reader034/viewer/2022050116/626d2fa9e36b396e061a107c/html5/thumbnails/23.jpg)
Overall Grading
Project25 %
Exercises25 %
50 %
Exam (must be
passed successfully)
![Page 24: Programming for Engineers - st.cs.uni-saarland.de](https://reader034.vdocument.in/reader034/viewer/2022050116/626d2fa9e36b396e061a107c/html5/thumbnails/24.jpg)
What You Need
Starterkit “Funduino MEGA 1”
![Page 25: Programming for Engineers - st.cs.uni-saarland.de](https://reader034.vdocument.in/reader034/viewer/2022050116/626d2fa9e36b396e061a107c/html5/thumbnails/25.jpg)
What You Need
LCD-Module I2C/TWI 1602 Serial
![Page 26: Programming for Engineers - st.cs.uni-saarland.de](https://reader034.vdocument.in/reader034/viewer/2022050116/626d2fa9e36b396e061a107c/html5/thumbnails/26.jpg)
What You Need
W5100 Ethernet Schield for Arduino Mega
![Page 27: Programming for Engineers - st.cs.uni-saarland.de](https://reader034.vdocument.in/reader034/viewer/2022050116/626d2fa9e36b396e061a107c/html5/thumbnails/27.jpg)
What You Need
Development environment (Windows, Mac OS X, Linux)
![Page 28: Programming for Engineers - st.cs.uni-saarland.de](https://reader034.vdocument.in/reader034/viewer/2022050116/626d2fa9e36b396e061a107c/html5/thumbnails/28.jpg)
What You Need
![Page 29: Programming for Engineers - st.cs.uni-saarland.de](https://reader034.vdocument.in/reader034/viewer/2022050116/626d2fa9e36b396e061a107c/html5/thumbnails/29.jpg)
Your Source
https://www.st.cs.uni-saarland.de/edu/pfe/ws15/
![Page 30: Programming for Engineers - st.cs.uni-saarland.de](https://reader034.vdocument.in/reader034/viewer/2022050116/626d2fa9e36b396e061a107c/html5/thumbnails/30.jpg)
Next Steps• Registration
• Assignment to groups
• Obtaining of boards and parts
https://www.st.cs.uni-saarland.de/edu/pfe/ws15/