__ __ _ _ ___ _ _ _ _
| \/ | __ _ __ _(_) ___ / |/ _ \/ | __ _(_) |_| |__
| |\/| |/ _` |/ _` | |/ __| | | | | | | \ \ /\ / / | __| '_ \
| | | | (_| | (_| | | (__ | | |_| | | \ V V /| | |_| | | |
|_| |_|\__,_|\__, |_|\___| |_|\___/|_| \_/\_/ |_|\__|_| |_|
|___/
__ __ _
\ \ / /__ __ _ _ __ __ _ __ _ _ __ __| |
\ V / _ \ / _` | '_ \ / _` | / _` | '_ \ / _` |
| | (_) | (_| | | | | (_| | | (_| | | | | (_| |
|_|\___/ \__,_|_| |_|\__,_| \__,_|_| |_|\__,_|
_ _
| | ___ ___ ___ _ __ | |__
_ | |/ _ \/ __|/ _ \ '_ \| '_ \
| |_| | (_) \__ \ __/ |_) | | | |
\___/ \___/|___/\___| .__/|_| |_|
|_|
2025-04-17
- WH.02.110 (Computer room IAS) 9:30 - 16:30
Timetable
- 9:30 - 10:30: Introduction
- 10:30 - 11:00: Hello World!
- 11:00 - 11:30: Blink
- 11:30 - 11:45: break
- 11:45 - 12:15: More blink
- 12:15 - 12:45: Speaker
- 12:45 - 13:30: Lunchbreak
- 13:30 - 14:00: speaker and button
- 14:00 - 14:30: speaker and potentiometer
- 14:30 - 15:00: servo motor and potentionmeter
- 15.00 - 16:30: Painting machine
Introduction
1. Welcome to the Interaction Station (your favourite station at the wdka *smily*)
2. Introduction to the topic: Interactive Archive Interventions
3. Getting hands on
Hello World!
void setup() {
}
void loop() {
Serial.println("Hello World!"); //sends a message to the computer
}
Simple Led blink example
int ledPin = 13; //the int ledPin is 13
void setup() {
pinMode(ledPin,OUTPUT); //ledPin is a OUTPUT
}
void loop() {
digitalWrite(ledPin,HIGH); //turns pin 13 on
delay(500); //stops the loop for 500 milliseconds
digitalWrite(ledPin,LOW); //turns pin 13 off
delay(500); //stops the loop for 500 milliseconds
}
Traffic light example
int RedLedPin = 13; //the int RedLedPin is 13
int GreenLedPin = 12; //the int GreenLedPin is 12
void setup() {
pinMode(RedLedPin,OUTPUT); //ledPin is a OUTPUT
pinMode(GreenLedPin,OUTPUT); //ledPin is a OUTPUT
}
void loop() {
digitalWrite(GreenLedPin,HIGH); //turns green led on
delay(5000); //stops the loop for 5000 milliseconds
for(int i = 0; i < 5; i++){ //this for loop gets 5 times repeated
digitalWrite(GreenLedPin,LOW); //turns green led off
delay(500); //stops the loop for 500 milliseconds
digitalWrite(GreenLedPin,HIGH); //turns green led off
delay(500); //stops the loop for 500 milliseconds
}
digitalWrite(GreenLedPin,LOW); //turns green led off
digitalWrite(RedLedPin,HIGH); //turns red led on
delay(5000); //stops the loop for 5000 milliseconds
digitalWrite(RedLedPin,LOW); //turns red led on
}
Speaker example
int speaker = 13; //int speaker is 13
void setup() {
pinMode(speaker, OUTPUT); //pin 13 is an output
}
void loop() {
for(int i = 100; i< 1000;i++){ //for loop counts from 100 to 1000
tone(speaker, i); //generates a tone on pin 13 with the frequency of int i
delay(10); //stops the code for 10 milliseconds
}
}
Speaker and button example
//code generates on button press a random tone
int speaker = 13; //int speaker is 13
int button = 12; //int speaker is 12
void setup() {
Serial.begin(115200); //makes a serial connection to the computer
pinMode(speaker, OUTPUT); //pin 13 is an output
pinMode(button, OUTPUT); //pin 12 is an output
}
void loop() {
bool buttonState = digitalRead(button); //reads pin 12 & bool is a on or off value
if(buttonState == HIGH){ //if the button is HIGH(pressed)
int randomValue = random(100,1000); // creates an int called randomValue with a random value between 100 and 1000
tone(speaker, randomValue); //creates an tone on pin 13 with the random value as frequency
delay(500); //stops the loop for 500 milliseconds
}
}
Servo motor and potentiometer
//code controls a server motor with a potentionmeter
int poti = A0; //poti is connected to pin A0
Servo aServo;
void setup() {
pinMode(A0, INPUT); //pin A0 is an INPUT
aServo.attach(3); //pin 11 connected to the servo motor
}
void loop() {
int value = analogRead(poti); //read the value of the potentionmeter
value = map(value, 0,1023, 0,180); //we map the servo value from 0-1023 to 0-180
aServo.write(value); //we give the servo a new position
delay(10); //we wait a bit
}
Servo motor movement between 0 and 90 degrees
//this example controls a standard servo motor and moves it between 0 and 90 degrees
//the servo has three different wires
//the red wire is plus and connected to 5v
//the brown wire is minus and connected to GND
//the orange wire is the signal wire and connected to pin 3 (remember the ~-symbol - it means PWM)
#include <Servo.h>
Servo theServo;
void setup() {
Serial.begin(115200);
theServo.attach(3);
}
void loop() {
for(int i = 0; i < 90; i++){
theServo.write(i);
Serial.println(i);
delay(50);
}
for(int i = 90; i > 0; i--){
theServo.write(i);
Serial.println(i);
delay(10);
}
}
painting machine
File:Paintingmachinevideo.mp4
//in this sketch one poti controls one servo
#include <Servo.h>
Servo jointOne;
void setup() {
Serial.begin(115200);
Serial.println("start");
jointOne.attach(10);
}
void loop() {
int value = analogRead(A0);
value = map(value, 0, 1023, 0, 180);
jointOne.write(value);
delay(10);
}