Sunday, 5 August 2012

Week 2

The theme for week 2 was 'making interactions'. This involved the process of interaction design learned in the previous week. The task was to gather any working/non-working electronic products and break them down to see how they work and to possibly re-use some components such as wires, speakers, motors, buttons and displays. The extra electronics would then be connected to arduino to see if we can make certain processes work. The group hoped that this exersize would not only educate us on the process, but also spark some ideas for the team project.

The group organised a children's toy 'The Leap Frog Educational Learning Tablet', which has audio speakers, buttons and a LCD display.







This final picture shows the set up of the children's toy. From here the group attempted to use some electronics with the arduino system.

The group attempted to connect a speaker to the arduino in the tutorial, however, it did not work. It was a suspected coding error that turned out to be a faulty component. Below is the incorrect code used in tutorial.

Failed Code – Tutorial 4


// Speaker (analog wave-form) output with Switches
// (with a complex use of Pulse-width Modulation)
// prepared by Yasu Santo July 2008
// refer to Language Reference at www.arduino.cc for
// detailed descriptions of commands
// --- part of this script was borrowed from
// http://www.arduino.cc/en/Tutorial/PlayMelody

#define pbPin1 1 // assign 2 to constant "pbPin1"
#define pbPin2 2 // assign 3 to constant "pbPin2"
// PWM can be used with pin 3, 5, 6, 9, 10 and 11.
#define speakerPin 6 // assign 9 to constant "speakerPin"

#define tc 3817 // 1 / (262Hz) = 3817 milliseconds
#define tcs 3610 // 1 / (277Hz) = 3610 milliseconds
#define td 3401 // 1 / (294Hz) = 3401 milliseconds
#define tds 3215 // 1 / (311Hz) = 3215 milliseconds
#define te 3030 // 1 / (330Hz) = 3030 milliseconds
#define tf 2865 // 1 / (349Hz) = 2865 milliseconds
#define tfs 2703 // 1 / (370Hz) = 2703 milliseconds
#define tg 2551 // 1 / (392Hz) = 2551 milliseconds
#define tgs 2410 // 1 / (415Hz) = 2410 milliseconds
#define ta 2273 // 1 / (440Hz) = 2273 milliseconds
#define tas 2146 // 1 / (466Hz) = 2146 milliseconds
#define tb 2024 // 1 / (494Hz) = 2024 milliseconds
#define tcc 1912 // 1 / (523Hz) = 1912 milliseconds

int button1 = 0; // assign "0" to variable "button1"
int button2 = 0; // assign "0" to variable "button2"

void setup(){
Serial.begin(9600); // open serial port with a specified baud rate
pinMode(pbPin1, INPUT); // set the digital pin as INPUT
pinMode(pbPin2, INPUT); // set the digital pin as INPUT
pinMode(speakerPin, OUTPUT); // set the digital pin as OUTPUT
}

void playTone(int tone, long duration){ // Fundtion to play a tone for a set duration
long elapsed_time = 0;
while(elapsed_time < duration){ // while elapsed time of this function is less than the set duration
digitalWrite(speakerPin, 1); // this and next 3 lines generate wave form for a specific tone.
delayMicroseconds(tone/2);
digitalWrite(speakerPin, 0);
delayMicroseconds(tone/2);
elapsed_time += tone; // add the duration of tone just played to the elapsed time.
}
}

void loop(){
button1 = digitalRead(pbPin1);
button2 = digitalRead(pbPin2);

if(button1 == 0 && button2 == 0){ // if both buttons are "0" or ON then
Serial.println("both ON"); // send a message to debug window
playTone(te, 100000);
}else if(button1 == 0){ // if only button 1 is "0" or ON then
Serial.println("(1) ON"); // send a message to debug window
playTone(tc, 100000);
}else if(button2 == 0){ // if only button 2 is "0" or ON then
Serial.println("(2) ON"); // send a message to debug window
playTone(td, 100000);
}
}

After realising this issue, the failed code and faulty component were replaced with the working components and the activity was succesful.

This allowed the group to start to brainstorm some initial ideation ideas about what we want the product to do.  http://www.youtube.com/watch?v=6mXM-oGggrM This website gives some indication into where intial brainstorming started.

Arduino Tutorials:

Tutorial 1 Digital Outputs




Tutorial 2 Digital Input


Tutorial 3 Digital I/O


Tutorial 4 Analog Output



Tutorial 5 Analog Input



All member of the team are individually learning the arduino system so that the team has 4 experinced programmers that have strong ideas as to how to use arduino for the assesment.


No comments:

Post a Comment