## Assignments

Hi Class, Im a second year mfaDT, recently doing my thesis project. I’m interested in datas, quantified self and digital interaction in a physical representation. I finished my BA in communication design in Shanghai. Before came to NYC, I had a briefly working experience at an agency mainly for designing building websites.

I don’t have much physical computing experience during the first year, in this class because recently I found that physical and environmental sensing interactions are interesting!

Assignment 1:
Buzzer emotion

Assignment 2:
Led + buzzer

## Emotion LED’s inside a box project

I found this project to be very rewarding and refreshing. I was surprised about how quickly it came together once I had obtained all of my supplies. Time is always an issue especially when working full time and attending courses.

Below is a video of my first iteration of this project. Soon I’ll be wiring up a speaker that will play 8 bit sound effects to accompany this box of lights.

Be aware that the video trails on a bit as I didn’t cut the music correctly. The videos is over after the calming section fades to black.

## Arduino Cookbook Reading/Homework

Come to Oct 7th’s Class having done and read:

Review: 1.1-1.5   [Read it for what you don’t know]

Variables Introduced:  2.0-2.2

Doing Math to Variables: 3.0-3.2

Serial Comm Intro: Read 4.0 and don’t worry if over your head. Do pay close attention to 4.1.

More Fun with Variables, Relational Operators: 2.17

*Switches Intro, with Pull-Up Resistor and De-bouncing: Read 5.0 and 5.1, Do 5.2 and 5.3

“If” and “Else If” Statements Intro: 2.12

*”While” and “For” Loop: Pages 2.13, 2.14

———————————————-

Come to Oct 14th’s Class having done and read:

2.4:   Arrays Introduced (for Switches and LED’s)

2.10:   Functions: Pages

7.1:  LED’s Introduced and Reviewed

7.6:  Making Knight Rider

2.15-2.16:  Break and Switch Case:

5.4:   Switches Intermediate:

2.19, 2.21:  Logical Operators on Variables:

Assignment:

1)  Change LED Blink Delay based on Amount of time Button is pressed.

2)  Make 6 Different Light Sequences with  3-4 Switches and 4 LED’s.  Use Logical Operator, Knight Rider Effect, Functions and/or Switch Cases.

———————————————-

Come to 21st’s Class having done and read:

Reading Analog Values: 5.6,

Map Function: 5.7

Sensor: 6.0-6.3

LED Fading, Color, and Control: 7.0, 7.2, 7.4, 7.5, 7.6

http://wiring.org.co/learning/basics/rgbled.html

Assignment:

Show 7.4 and 7.5 in Class.

• #### hirumi 4:21 pm on October 14, 2011 Permalink | Reply

Most useful/valuable exercises:
I found that using the serial input to be the most useful exercise from the homework. It was gratifying to see the computer communicate with the arduino. Functions was a useful read because it made my code more modular and clean.

Most difficult:
Both switchTime sketches made me want to bash my head into a wall. I couldn’t get them to work to save my life. I kept getting errors even though it seemed like I had copied the examples exactly from the book. I’m not sure if there was a typo, or if there was some sort of additional code I was supposed to know to include, but regardless I couldn’t troubleshoot the issue.

• #### noadol 4:24 pm on October 14, 2011 Permalink | Reply

Most useful and valuable:

Functions && Logical Operators on Variables.

These two exercise really pushed my understanding of code structure
and expand my options to control conditions.

Most difficult and confusing:

(5.4) Determining How Long a Switch Is Pressed:
I could get the code text and structure, but I was confused about what it’s supposed to do or how it’s functions.. I’m not sure I got the point of this assignment, meaning I won’t be able to apply it and develop it in other projects.

Formatting Serial Communication:
It was very technical, a lot of new expressions I’m not sure what’s their value (e.g. ASCII, BYTE, BIN..).

• #### mayaweinstein 4:24 pm on October 14, 2011 Permalink | Reply

I found the section on breaks helpful. It’s good to know how to break a for loop without ending the function. I also found the section on RGB led’s helpful, it was a good introduction on how to use RGB led’s.
I was really confused by the section covering the switch-case function. I understand what a function is and how it works but I did not understand what was being accomplished through the use of the switch-case. I was completely lost when it came down to the bitwise operations. I have no idea why you would be working with what looked like binary code in arduino. I’m not sure exactly what the code was trying to do or when you would actually use it.

• #### Catalina Cortazar 4:25 pm on October 14, 2011 Permalink | Reply

The codes I found more difficult and confusing were the following:

The example blink3 on the function part. The function that needs a parameter and gives 1 return value. I couldn’t get it to work at home and also don’t understand how and when do we call the function. Do we need to call it from inside the void loop?

Another thing that I still found confusing is the pull up button. They always start HIGH ? How do we do it to turn the light off, or maybe is there a way to change the state of the button?

I also don’t understand what the value >>= 2; means (shift value right to places)

Most useful or valuable

The most useful and valuable thing I found was the use of arrays in order to declare more than one element. I also think it’s useful the logical operators and comparison, in order to give “instruction” to what and when to do something.

Another thing I found useful is the use of break;
specially when we have lots of information and we don’t want to use infinitive number of if, else if commands.

• #### mónica arias. 4:25 pm on October 14, 2011 Permalink | Reply

– Both sections regarding logical operators on variables. I had never seen it explained in so much detail, but at the same time in a concise way. They weren’t exercises per se, but it was one of the most helpful chapters. (2.19, 2.21: Logical Operators on Variables)

MOST DIFFICULT ASSIGNMENTS:
– 2.4: Arrays Introduced (for Switches and LED’s): The book makes a fine job explaining it, so it might be just a personal issue I have against arrays in general.
– 2.15-2.16: Break and Switch Case… yeah. I understood the concept, BUT I still don’t feel comfortable explaining it, or doing it. But hey, isn’t experimentation key? I’m sure that if I spend more time on it, I would eventually get it.

• #### dss49 4:26 pm on October 14, 2011 Permalink | Reply

I guess I neglected some of the reading although I found a very helpful tutorial online that sort of walked me through basic input/output using buttons and LED’s. (I’ll be sure to stay on top of it in the future). The link can be found at http://www.ladyada.net/learn/arduino/lesson5.html.

Essentially they create a problem set starting with basic switch functions… helping build the code ground up for recognizing change in state and output controls. Towards the end they give you a series of problems involving a Bike company that needs help programming a new lighting system. The various stages of the prompt test your abilities and end with the creation of a light system which has 4-5 separate modes activated by the button. This piecemeal way of learning was personally very helpful.

There were a number of other tutorials that I found helpful, one of which explained the use of millis() instead of delay(). By using millis() as a timer instead of delay(), one is able to nest other functionality within conditionals that otherwise would not be able to run with delay() since delay() stops all processes within the Arduino. A notable example would be having one LED blink 500ms after another has started blinking, creating a sort of Lag effect. Using delay() would prevent you from activating another LED while the former is being delayed. Another use of millis() was creating a stopwatch which blinks as a timer begins… the push of a button turns the timer off, the start and end times are calculated as Serial.println spits out the time.

• #### dss49 4:28 pm on October 14, 2011 Permalink | Reply

debouncing was helpful as well.. making sure both readings of the input were consistent.

• #### yonglee2011 4:27 pm on October 14, 2011 Permalink | Reply

Two Exercise that I like or helpful:
The custom function for different Blinks are good sample of diverse options we can use. I wish the codes are more detailed, so it is easy to follow on the Arduino. I type the code from the book, but the code didn’t work.

Conditional section show diverse conditional options. But I wish the conditional section has more sample codes.

Difficult exercise:

There are some samples of using arrays. I played with Arrays, and wish there are more samples to look up. I found the book is helpful, but it seems it doesn’t have depth details.

I really like what While and For Loop do, and wish there are more exercise to help a stater to understand the concepts and samples.

• #### mrcansler 4:27 pm on October 14, 2011 Permalink | Reply

The two readings I found most interesting were 2.10 (Functions), and 2.19 (Logical Operators). Until this point, I was unaware that functions even existed within this programming environment, and they appear to be a useful resource when constructing larger sections of code later. The logical operators sections was useful, as they are actually very basic concepts, but I was not particularly familiar with these basics. Still feel like I’m playing catchup with Syntax.

I had some difficulty with arrays, as I feel like I completely get them structurally, but whenever I try to implement them I always seem to mess up the for loops associated with counting through them. I’m also having a bit of trouble digesting 2.16 “Switch”, and figuring out when to use these vs if/else statements. Is there a specific number of inputs before it’s best to use SwitchCase?

• #### Aneta Genova 4:27 pm on October 14, 2011 Permalink | Reply

I found most useful the array reading and exercise.It makes working with many variables extremely easy and certainly shortens the code. I developed a project about bouncing animals in a field and the array list was the easiest way to do them.

I found very easy the functions reading and exercise. The first exercise about blinking and delay was very familiar to sketches we’ve done in class.

I found challenging the logical operators and logical comparisons and I definitely get confused when we get to compare strings. I was not able to do that assignment.

• #### jasonkim1006 4:27 pm on October 14, 2011 Permalink | Reply

1. Which two exercises or code did you find most useful or valuable from the reading? Be as specific as possible.

a) The first code I found to be very useful was the case / break code. It was really interesting to get input from the serial monitor and make the LED blink.
if(Serial.available()){
char ch = Serial.read();
switch(ch){
case ‘1’:
for(int i = 0; i<4; i++){
}

Using default, we can set the default input and by using the switch case, we can use any key on the keyboard to create an input and make, for example, an LED blink sequence. Just by using the case '1':, case '2':, etc. we can determine how many different types of sequences we want.

b) The second code I found very useful were using logical operators such as and (&&), or (||), and not (!). By using logical operators, we can determine diverse situations such as if both switches are pressed, both the switch and the tilt sensor are sending input, either the first button or the last button is pressed, etc. By including logical operators, there can be so many different types of situations with just four buttons. Instead of making one button do one thing, we can make a combination of one, two, three, or four buttons to something else. The logical operators are also good for setting up boundaries or giving certain conditions to inputs.

2.Which two exercises or code did you find most difficult or confusing from the reading? Be as specific as possible.

a) The first code that was really difficult to understand was calculating the amount of time using the switchTime() function. It was really hard to understand because whenever I tried it, the counter would increase rapidly or even decrease to a high negative number. I want to try using the "long" and "millis()" more so that I can understand its concept better. Because we used pullup resistors inside the Arduino, the HIGH and LOW was also a bit confusing to understand. The state should be inverted when using different resistors.

long switchTime(){
static unsigned long startTime = 0;
static boolean state;

state =! state;
startTime = millis();
}
if(state == LOW){
return millis() – startTime;
}
else{
return 0;
}
}

b) Related with the switchTime() function is the debounce code. It took me a long time to understand the debounce code by using booleans of state and previousState. I think it was especially hard to understand because the debounce does not actually give direct feedback. Switch codes worked without having to use the debounce code and therefore it was at first hard to understand what "debouncing" actually did to my code. Later did I find out it was just a check for a few milliseconds to see if the button was stable enough to input and output information. It was a comparison between the current state and previousState and to see if they were equal.

• #### litchirhythm 4:29 pm on October 14, 2011 Permalink | Reply

● The most useful exercise would be 5.4, the switch timer, for sure. It shows how to use timing (millis() function) to count how long you push the button and make led lit up in relative amount of time.

And the other one that is interesting is 2.16 on the ‘switch’ logical command which I never know before. It function can be written with a long list of if statement but switch can be really handy on another person (or yourself) to read and understand the code much easier.

● The most difficult would also be the 5.4, the switch timer, since the first homework assignment is to tweak this one to make it blink. So I have to know this code inside out to be able to tweak it. In it, I have to apply the concept of custom function that count the time and return the data back to the main loop (the concept from 2.10 the function block), It’s like a wrap up of all exercises.

Another thing that I find most difficult is Array (2.4). Even we have saw some of them on the example we work on. But to read and understand all of the concept and remember the syntax so that I can think and make it to work in the way I want is still hard. Because you’ll have to use a for loop to run the arrays all the time. But I think I understand it much more now.

• #### josefayala 4:33 pm on October 14, 2011 Permalink | Reply

I liked the vast majority of the tutorials. My favorite was Arrays because in the past I have not been able to properly execute them. There is something gratifying about making 100 ellipses with 3-4 lines of code (otherwise we’d have to hard code each ellipse). With regards to Arduino work it’s nice to know that I can call on a group of pins for one purpose by simply calling an array. What I was surprised to find out is that the array can hold a string of characters. I found that character strings are good possibly for Serial Monitor work. Functions were also a good time, and it was good to get a good look at the use of parameters and returns.

Switch statements can be difficult, but overall the concept is well embedded into my mind. I understand the importance of using breaks within a switch command but kind of miss the logic of setting it up with what seem to be all the arguments wrapped between the switch (I guess from the purpose of switching). Is it comparable to an array ? Who knows…I guess I have to re-read it.

-josef

• #### aisencc 5:02 pm on October 14, 2011 Permalink | Reply

10/14 Reading Assignment Response
The easiest sections from the readings were the Arrays Introduced and Logical Operators. Both of these sections are reviews to the Processing and Arduino IDEs. Both of these sections seemed a bit redundant, since it is crucial to know these in order to create any functions or when working with a variety of pins that are programmed to do similar things. For the homework assignment I used both of these methods in structuring my code. Every time I use these

The most challenging chapters were Determining How Long a Switch is Pressed and Knight Rider. These are not necessarily hard to understand, but more dense than the practical sections I mentioned above. The Knight Rider was not complicated, but it was dense. Understanding arrays makes this section easy, because the use of for loops with the right amount of delay HIGH and LOW patterns is what makes the LED pins blink one at a time. Determining How Long a Switch is Pressed was the most challenging section of the homework because it introduces a counter and functions. I am still having to read it over and over again, to try to understand exactly what it’s doing.

## Links for LOL Shield (working list)

```It prints everything sent on the serial line of the arduino, as a banner
on Jimmie P Rodger's LoLShield.
https://github.com/guyzmo/LoL-shield-dynamic-banner

Nice Test Pattern:
http://tronixstuff.wordpress.com/2011/09/07/kit-review-the-lol-shield/

LoL Shield Theatre```

## Reading Assignment for 2nd Class

Hi All,

I had too much trouble getting a good scan for you for the reading assignment stated in our first class.  We are going to do that reading another week.

For the second class meeting please pull up this page:  http://arduino.cc/en/Guide/HomePage

1) The sections titled “Introduction”.

2) The section on the operating system you use, Window, Mac,….

Skim:

c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r