Spring 2017 – Week 5 Class Notes

URGENT MESSAGE – NO CLASS NEXT WEEK – IF YOU ARE A STUDENT READING THIS TELL YOUR PARENTS ABOUT IT RIGHT NOW. I’ll email you later this week about it, but just wanted to put that out there up front.

As always, if you need more information or get stuck on anything, please feel free to email me!

Programming

This week in programming we looked at other properties of HTML elements we could modify using JavaScript. We made things move by modifying their CSS padding (you may want to look at the CSS chapter again), and then we animated the movement using the setTimeout function. setTimeout has two parameters – the first is the function you want to run, and the second is the number of milliseconds it should wait until it runs your function. Remember to just send the name of the function to run, or a function declaration (i.e., function(){ /* function here */ }). If you call the function when you send it, it does not do the right thing! In other words, we did setTimeout(moveme, 20);. We DID NOT do setTimeout(moveme(), 20); The latter one would call moveme once, and setTimeout would probably signal an error because it would receive a null (the function’s return value) instead of the function itself.

We are basically past the end of the book at this point (we skipped one chapter that we may return to), so for your reading this week we are going to start reading web tutorials. Most of what you need to learn to program is available on the web, and practicing learning from other people’s documentation is a good habit to learn.

One thing we did not cover in class is why we had to use setTimeout instead of a simple loop. The main reason is that JavaScript does a lot of stuff for us while we aren’t looking (watching for button clicks, scrolling the page, redrawing the screen, etc.). However, it can’t do these things while we are occupying the processor. So, when we do a setTimeout, we are allowing the computer to go about its business doing other necessary things (including drawing the change we made) while we wait for the next time to do our iteration. However, the same sorts of things we have in loops are needed with setTimeout – we need initialization, we need a condition to know when we need to stop, etc. It’s just that, in this case, “stopping” is just not calling setTimeout again.

So, for your reading this week, I want you to read through these two documents:

  • A list of JavaScript HTML events (focus on the “mouse events” section, but also look around to see what the other possibilities are; also note that the event name in the list is mouseout but in JavaScript we will install the handler with an “on” prefix, like element.onmouseout = myfunction;)
  • A list of CSS styles (you don’t need to read all of them, but pick out 2 or 3 sections of this to read in detail; remember to use the camelcased name of the CSS style in JavaScript, and to attach it to the element’s style property)

What I want you to do this week is read through these, and then write two short programs demonstrating these new event handlers and CSS properties. As an example, there is a double-click event. There is a font CSS property. So, I could have a program that, on double-click of something, changed the font. If you can add in animations, that would be good for practice as well.

Electronics

This week we did RC (resistor-capacitor) circuits, focusing on the RC time constant (note – it takes 5 RC time constants to fully charge a capacitor). I rechapterized the book this week, so previous chapter numbers do not apply. The chapter to read / work this week is Chapter 19. I would like everyone to bring in their box the final project in the chapter, whose schematic is in Figure 19.4 or as best/close as you can. Next week we will introduce oscillators.

Also, this week we are using the voltage comparator chip. Since it is still winter, you all have static electricity in your bodies that can damage the chip, so be sure to touch something metal before working with the comparator chip to discharge any static electricity and keep the chip intact.

Calculus

This week we went through infinite series again using both Taylor series and McLaurin series. I’ll have more here and in the book later this week.

Comments are closed.