Skip to main content

Posts

Showing posts with the label math

Day 3: Linear Interpolation, Mathematical Functions, and Arduino Buttons

Figure 1.1 Linear interpolation  assumes that a straight line joins two points f(a) and f(c), and that the value of f(b), where b lies between a and c, lies on this line. Figure 1.2 Cubic spline interpolation  is when the points f(a) and f(c) are joined by a cubic polynomial, and the value of f(b), a function of b, which lies between points a and c, lies on this curve. Formula Assumes a<b<c f(b)=f(a)+((b-a)/(c-a))[f(c)-f(a)] Example 1 The data was given, shown in Figure 1.1 at right. Figure 2.1 Example 2 In the example on the left, we used linear interpolation to find the freezing temperature of certain salinities of water. 1. Problem Statement Use linear interpolation to determine the freezing temperature of water with a certain salinity. 2. Input/Output Description Inputs: first salinity, second salinity, first freezing temperature, second freezing temperature, new salinity. Output: new freezing temperature 3. Hand Example See...

Day 2: Math Operations, Overflow and Underflow, Printf and Scanf

Lab Today we started with our first Arduino lab. We first wanted to make one LED on a breadboard blink, then get 4 LEDs to blink. I was able to do this successfully using the code below. void setup() {   // put your setup code here, to run once: pinMode(11, OUTPUT); pinMode(10, OUTPUT); pinMode(9, OUTPUT); pinMode(3, OUTPUT); } void loop() {   // put your main code here, to run repeatedly:   digitalWrite(11, HIGH);      delay(500);   digitalWrite(11,LOW);   digitalWrite(10,HIGH);      delay(500);   digitalWrite(10,LOW);   digitalWrite(9,HIGH);      delay(500);   digitalWrite(9,LOW);      delay(100);   digitalWrite(11, HIGH);   digitalWrite(3,HIGH);   digitalWrite(10,HIGH);   digitalWrite(9,HIGH);   delay(100);   digitalWrite(11, LOW);   digitalWrite(3,LOW);   digitalWrite(10,LOW);   digitalWrite(9,LOW); ...