Grady + Bowen + Yu Hann + Fan Pu + Yi Yang
group1.jpg
Day 1
Today, we learnt about the basics behind wireless and electronics. It was indeed interesting to finally learn the works behind everyday electronics that we use. It was exciting to learn about the various components behind the exterior of common devices (i.e. mobile phones) as well as how information is transmitted on the circuits. It was also interesting to learn about the different electromagnetic waves in our daily lives for once, as even though they are invisible to us, they play a big part in making our lives much more convenient as well as interesting. The seemingly simple act of making a call was actually made out to be a relatively elaborate process, and such insights were what made this session very enjoyable for us.

Day 2

We started off today with an introduction on Arduino and learnt a bit on how to use it. We received a lot of parts, such as the breadboard, resistor, photoresistor, potentiometer, push button, servo motor, transistor, LED and Piezo speaker. Initially when we just received the circuit board, we felt quite confused and a bit uncertain looking at numerous small parts of the circuit board. However once we started doing the examples it was a lot easier to comprehend what was going on in it, and we had a lot of fun in the process! After that, we used the GSM to construct a working phone. We encountered a lot of frustrating errors with HyperTerminal, such as being unable to type in the text box. After some long minutes, we realized the one of the cables were in the wrong place!

day2-7.jpg


Apart from that, there was also an error with CME ERROR 27, which kept showing up when we tried to call someone. When we finally managed to get it to work, it was quite exciting although only one person could use the earpiece and hear the conversation. Later on during the lesson, we used the Piezo speaker and programmed some notes for it to play. We found it very interesting but didn’t have enough time to continue to experiment, and so hope that we will be able to make the Piezo speaker sing a Rick Roll tomorrow.

Day 3

Today we started on our final project. We are planning to make a simple machine which will play music when activated.We experimented with the arduino to play music with the peizoelectric speakers and tried to make the LED lights flash along to the music.

We also created a program to cause the tri-color LED light to change colors.To create our final program, we will be making a simple arduino circutry where when activated with a LDR or a switch, a song will play from the peizospeakers. However, we were unable to get our machine to play notes higher than G. We found today very engaging as we were able to experiment with the arduino board and understand it better. Also, we found it very entertaining as we can create many interesting products with it.



Day 4

Today we perfected our final product. Our simple machine now plays 'Nyan Cat' with LEDs lighting up and a moving servo with a Nyan Cat on it. We have solved the problem with sound frequency on the Piezoelectric Buzzer. We have also learnt about level shifters and ways to connect the GSM board to the Arduino Board. It was great fun for us in the process of building our project. The mechanism behind the level shifter was also fascinating.

Initially, we were rather frustrated with the coding, as we could not figure out the way for Arduino to recognize our code simultaneously. However, Yu Hann and Fan Pu were unfalteringly resilient. After an hour of research on the internet, we finally sorted out the code to work concurrently (buzzer and LED and servo).



Our code:

#include <Servo.h>
#define REST 0
#define NOTE_B0 31
#define NOTE_C1 33
#define NOTE_CS1 35
#define NOTE_D1 37
#define NOTE_DS1 39
#define NOTE_E1 41
#define NOTE_F1 44
#define NOTE_FS1 46
#define NOTE_G1 49
#define NOTE_GS1 52
#define NOTE_A1 55
#define NOTE_AS1 58
#define NOTE_B1 62
#define NOTE_C2 65
#define NOTE_CS2 69
#define NOTE_D2 73
#define NOTE_DS2 78
#define NOTE_E2 82
#define NOTE_F2 87
#define NOTE_FS2 93
#define NOTE_G2 98
#define NOTE_GS2 104
#define NOTE_A2 110
#define NOTE_AS2 117
#define NOTE_B2 123
#define NOTE_C3 131
#define NOTE_CS3 139
#define NOTE_D3 147
#define NOTE_DS3 156
#define NOTE_E3 165
#define NOTE_F3 175
#define NOTE_FS3 185
#define NOTE_G3 196
#define NOTE_GS3 208
#define NOTE_A3 220
#define NOTE_AS3 233
#define NOTE_B3 247
#define NOTE_C4 262
#define NOTE_CS4 277
#define NOTE_D4 294
#define NOTE_DS4 311
#define NOTE_E4 330
#define NOTE_F4 349
#define NOTE_FS4 370
#define NOTE_G4 392
#define NOTE_GS4 415
#define NOTE_A4 440
#define NOTE_AS4 466
#define NOTE_B4 494
#define NOTE_C5 523
#define NOTE_CS5 554
#define NOTE_D5 587
#define NOTE_DS5 622
#define NOTE_E5 659
#define NOTE_F5 698
#define NOTE_FS5 740
#define NOTE_G5 784
#define NOTE_GS5 831f
#define NOTE_A5 880
#define NOTE_AS5 932
#define NOTE_B5 988
#define NOTE_C6 1047
#define NOTE_CS6 1109
#define NOTE_D6 1175
#define NOTE_DS6 1245
#define NOTE_E6 1319
#define NOTE_F6 1397
#define NOTE_FS6 1480
#define NOTE_G6 1568
#define NOTE_GS6 1661
#define NOTE_A6 1760
#define NOTE_AS6 1865
#define NOTE_B6 1976
#define NOTE_C7 2093
#define NOTE_CS7 2217
#define NOTE_D7 2349
#define NOTE_DS7 2489
#define NOTE_E7 2637
#define NOTE_F7 2794
#define NOTE_FS7 2960
#define NOTE_G7 3136
#define NOTE_GS7 3322
#define NOTE_A7 3520
#define NOTE_AS7 3729
#define NOTE_B7 3951
#define NOTE_C8 4186
#define NOTE_CS8 4435
#define NOTE_D8 4699
#define NOTE_DS8 4978
int intro[] = {
intro
NOTE_DS5,
NOTE_E5,
NOTE_FS5,
NOTE_B5,
NOTE_DS5,
NOTE_E5,
NOTE_FS5,
NOTE_B5,
NOTE_CS6,
NOTE_DS6,
NOTE_CS6,
NOTE_AS5,
NOTE_B5,
NOTE_FS5,
NOTE_DS5,
NOTE_E5,
NOTE_FS5,
NOTE_B5,
NOTE_CS6,
NOTE_AS5,
NOTE_B5,
NOTE_CS6,
NOTE_E6,
NOTE_DS6,
NOTE_E6,
NOTE_B5,
};
Servo myservo;
int pos = 0;
note durations: 4 = quarter note, 8 = eighth note, etc.:
int noteDurations[] = {
16,
16,
8,
8,
16,
16,
16,
16,
16,
16,
16,
16,
8, 13
8,
16,
16,
8,
8,
16,
16,
16,
16,
16,
16,
16,
16 25 intro
};
void loop2(void){
for(pos = 0; pos < 180; pos += 1) goes from 0 degrees to 180 degrees
{ in steps of 1 degree
myservo.write(pos); tell servo to go to position in variable 'pos'
delay(5); waits 5ms for the servo to reach the position
}
for(pos = 180; pos>=1; pos-=1) goes from 180 degrees to 0 degrees
{
myservo.write(pos); tell servo to go to position in variable 'pos'
delay(5); waits 5ms for the servo to reach the position
}
loop2();
}
void setup() {
myservo.attach(9);
for (int thisNote = 0; thisNote < 25; thisNote++) {
to calculate the note duration, take one second
divided by the note type.
e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
int noteDuration = 1500/noteDurations[thisNote];
tone(8, intro[thisNote],noteDuration);
o distinguish the notes, set a minimum time between them.
the note's duration + 30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
8,
 
8,
 
8,
 
 
 
8,
 
16,
 
16,
 
8,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
8,
 
8,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
8,
 
16,
 
16,
 
8,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
 
 
8,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
8,
 
8,
 
 
 
8,
 
16,
 
16,
 
8,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
8,
 
8,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
8,
 
16,
 
16,
 
8,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
 
 
8,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
16,
 
8,
 
8
 
};
 
int pos = 0;
 
boolean hit = false;
 
void loop() {
 
iterate over the notes of the melody:
 
for (int thisNote = 0; thisNote < 216; thisNote++) {
 
 
if(pos < 180 && hit == false) goes from 0 degrees to 180 degrees
 
{ in steps of 1 degree
 
myservo.write(pos);
 
pos += 30; tell servo to go to position in variable 'pos'
 
delay(5); waits 5ms for the servo to reach the position
 
}
 
else if(pos > 1 && hit == true) goes from 180 degrees to 0 degrees
 
{
 
myservo.write(pos); tell servo to go to position in variable 'pos'
 
pos -= 30;
 
delay(5); waits 5ms for the servo to reach the position
 
}
 
if(pos >= 180)hit = true;
 
if(pos <= 1)hit = false;
 
to calculate the note duration, take one second
 
divided by the note type.
 
e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
 
int noteDuration = 1400/melodyNoteDurations[thisNote];
 
tone(8, melody[thisNote],noteDuration);
to distinguish the notes, set a minimum time between them.
 
the note's duration + 30% seems to work well:
 
int pauseBetweenNotes = noteDuration * 1.30;
 
delay(pauseBetweenNotes);
 
// stop the tone playing:
 
noTone(8);
 
}
}