Blog - Sketching with Hardware

Day 2 – Introduction to Arduino

Published on: | Author: Kai Holländer | Categories: 2015a, Daily Logs, Lecture


Day 2 – Part 1
9 – 12 am

After getting started on day one with basic principles of electrical engineering, we got in touch with physical problems. Pure programming follows a clear logic. Building hardware requires knowledge about the interaction of several parts, which needs to be kept in mind while developing ideas.

We participated in a quick introduction to Arduino and started out with a couple of short programs. Further information can be found here: Slides day 2.

Hint:
If using a Linux operating system, e.g. Ubuntu the Arduino software needs to be started as super user (sudo).
On any OS the port has to be selected via the Arduino UI. Afterwards it is possible to transfer your code to your Arduino board.

Lets have a look at some basic Arduino codes using digital signals.

1. Simple LED code:

int led = 13;
int button = 2;
void setup() {
pinMode(led, OUTPUT);
pinMode(button, INPUT);
}
void loop(){
if (digitalRead(button) == HIGH)
digitalWrite(led, HIGH);
else
digitalWrite(led, LOW);
}

The hardware setup for this code is quiet easy, since pin 13 controls the build in LED on the Arduino board.

Hint:
Arduino example codes can be found pre-installed in the Arduino UI via “Datei” -> “Beispiele”.

Additionally we learned how to use a so called “pull down resistor”.
It is necessary in order to set the basic condition to a certain value.
In most cases a signal is on “LOW” an gets set to “HIGH” if e.g. a button is pressed.
A pull down resistor turns this the other way round.

2. Simple LED code using a pull down resistor and a button. Positive pole and ground are switched:

int led = 13;
int button = 2;
void setup() {
pinMode(led, OUTPUT);
pinMode(button, INPUT);
digitalWrite(button, HIGH);
}
void loop(){
if (digitalRead(button) == HIGH)
digitalWrite(led, HIGH);
else
digitalWrite(led, LOW);
}

Hardware setup:Setup code 2

Serial is used for communication between the Arduino board and a computer or other devices. All Arduino boards have at least one serial port (also known as a UART or USART): Serial. It communicates on digital pins 0 (RX) and 1 (TX) as well as with the computer via USB. Thus, if you use these functions, you cannot also use pins 0 and 1 for digital input or output. Source.

3. Simple code using serial method and a pull down resistor:

int led = 13;
int button = 2;
void setup() {
pinMode(led, OUTPUT);
pinMode(button, INPUT);
digitalWrite(button, HIGH);
Serial.begin(9600);
}
void loop(){
if (digitalRead(button) == HIGH) {
digitalWrite(led, LOW);
Serial.println("Button pressed");
}
else{
digitalWrite(led, HIGH);
Serial.println("No incoming Signal");
}
}

Until now we worked with digital signals, analogue signals are supported by Arduino as well.
An analogue signal could be used in order to achieve the visual effect of dimming a LED.
In this case a LED does not get dimmed for real, but is turned on and off instead within a short period of time.

4. Simple code using analogue input via potentiometer:

void setup() {
Serial.begin(9600);
}
void loop() {
int wert = analogRead(0);
Serial.print("Wert: ");
Serial.println(wert);
analogWrite(led, wer / 2.8);
}

Hardware setup:

We also had a quick look at Servo Motors. They use a analogue output and it is possible to set the angle precisely.
In general most sensors have three wires. One for plus pole (often red), one for ground (often black) and one for signals (often yellow).
In order to generate a circuit diagram certain software can be used. Fritzing is the recommended program to pick, it is easy to start with and it is able to export SVG graphics. Eagle is another alternative and often used in professional environments. PCBs can be build by manufacturers based on Eagle data. Further information can be found here: Slides day 2.

Bevore the break we got introduced to this years topic:

Music Instruments – Building a MIDI input or output device



Part 2
1 – 4 pm

We started the second part of the day with a little brainstroming.
Many different ideas were discussed, thus many groups introduced multiple ideas.
These are the very first versions of our suggestions how to solve the task:

Group 1:

  • A glove which can transfer color into noise
  • If the glove moves over a surface with different colors it plays different sounds
  • Every color has its own note.

Group 2:

  • A t-shirt which includes a speaker
  • Different gestures are used to create sounds from different musical instruments
  • There is a gesture for an accordion, a guitar and a flue

Group 3:

  • A toy dog which dances to music
  • A telephone where the dial plate is used as an input device
  • A mask which is able to sing

Group 4:

  • Timbre, pitch and tilt of a remote control are used to set the output sound
  • Buttons are used as well for additional features
  • Bike wheel rims are used to generate output sound
  • Shoes which create sound based on used pressure and their space between each other
  • A hose with a ball inside where the position of the ball sets the output sound

Group 5:

  • A musical clock is used as an output device
  • Every melody coming in via MIDI port is played by an xylophone connected to the adjustable musical clock

Group 6:

  • MPC (Music Production Center) build by an telephone
  • Buttons of the phone are used to create different noises
  • The space between handset and the telephone is used to set the pitch
  • Additionally the telephone display can be used and LEDs as well as sound samples are supported

Group 7:

  • The music mushroom will support the vibes of the sound played
  • The head of the mushroom device will shine in different colors and is able to move
  • The mushroom is able to change the sound volume

Impressions of day 2:
Group 5 working out ideas


Learning theory

linked categories 2015a, Daily Logs, Lecture

|

Write a comment

Comment