Fun With Interrupts – James Kyle

How it works:

I played around with buttons switches and potentiometers to change light blinking patterns and came up with this circuit. The switch has an interrupt which changes whether all lights blink at the same time or different times (a blink mode). The button changes which light blinks in the event that they are not blinking at the same time. The potentiometer changes the speed at which the lights blink.

I had some trouble with getting the switch interrupt to work more than once and I ended up having to place it before the button interrupt which I assume prioritizes it.

 

Code:

int toggle_color = 3;
int GREEN_LED = 7;
int YELLOW_LED = 6;
int RED_LED = 5;
int POT = A0;
int blink_rate = 250;
int toggle_blinkMode = 2;


//LED blinking variables
volatile int LED_pin = 5;
volatile bool individual_blink;


//Debounce variables
volatile unsigned long last_press = 0;
int wait_time = 50;




void setup() {

  Serial.begin(9600);

  //Initializing Pins
  pinMode(GREEN_LED, OUTPUT);
  pinMode(YELLOW_LED, OUTPUT);
  pinMode(RED_LED, OUTPUT);

  pinMode(toggle_color, INPUT_PULLUP);
  pinMode(POT, INPUT);


  //Interrupt initialization
  attachInterrupt(digitalPinToInterrupt(toggle_blinkMode), blinkMode, CHANGE);
  attachInterrupt(digitalPinToInterrupt(toggle_color), switchLED, CHANGE);


}

void switchLED() {

  //Turn off previous light
  digitalWrite(LED_pin, LOW);

  //Debounce
  if ((millis() - last_press) >= wait_time) {
    LED_pin++;
    last_press = millis();
  }

  //Go back to first light
  if (LED_pin > 7) {
    LED_pin = 5;
  }


}

void blinkMode() {

  if (individual_blink) {
    individual_blink = 0;
  } else {
    individual_blink = 1;
  }

}

void loop() {

  blink_rate = map(analogRead(POT), 0, 255, 100, 500);

  if (individual_blink) {
    digitalWrite(LED_pin, HIGH);
    delay(blink_rate);
    digitalWrite(LED_pin, LOW);
    delay(blink_rate);
  } else {
    digitalWrite(RED_LED, HIGH);
    digitalWrite(GREEN_LED, HIGH);
    digitalWrite(YELLOW_LED, HIGH);
    delay(blink_rate);
    digitalWrite(RED_LED, LOW);
    digitalWrite(GREEN_LED, LOW);
    digitalWrite(YELLOW_LED, LOW);
    delay(blink_rate);
  }

  bool value = individual_blink;
  Serial.println(value);


}

 

Messing Around With Interrupts

Messing Around With Interrupts:

Functionality:

There are two different states that the system can be put into. These states are controlled by an interrupt connected to the switch. When the switch is high, the system goes into adjustment mode where the user can use the potentiometer to adjust the brightness of the LED. This adjustment is only possible while in this state. When the switch is low, the system returns to its normal state where there is a blinking mode and solid mode. These modes are controlled by a second interrupt tied to the button. While in the blinking state, the LED’s flash individually for 0.5s each in a sequence of red to yellow to green and back to red. In the solid state, all of the LED’s remain on. The brightness of the LED’s in this mode is also the same as that set in the previous adjustment state.

Code:
/*  Interrupt Assignment 
 *  Judson Kyle 
 *  judsonk 
 *  01/31/2021 
*/
#define POT_PIN     A0
#define SWITCH      3
#define BUTTON      2

#define RED_LED     11
#define YELLOW_LED  10
#define GREEN_LED   9

#define RED     0
#define YELLOW  1
#define GREEN   2

volatile bool ADJUST_STATE = false;
volatile bool BLINK = false;

int potVal = 0;
double ledBrightness;

int currentLED = 0;

int waitTime = 500; //ms
long long startTime;

int buttonDebounceTime = 300;
long long buttonDebounceStart = 0;
volatile bool BUTTON_DEBOUNCE = false;
bool BUTTON_PREV_DEBOUNCE = false;


void setup() {
  
  pinMode(POT_PIN, INPUT);
  pinMode(SWITCH, INPUT);

  //Interrupts
  attachInterrupt(digitalPinToInterrupt(BUTTON), handleButton, RISING);

  //LED's
  pinMode(RED_LED, OUTPUT);
  pinMode(YELLOW_LED, OUTPUT);
  pinMode(GREEN_LED, OUTPUT);

  Serial.begin(9600);

}

void handleButton() {
  if (!BUTTON_DEBOUNCE) {
    BUTTON_DEBOUNCE = true;
    BLINK = !BLINK;
  }
}

void loop() {

  //Read switch state
  ADJUST_STATE = digitalRead(SWITCH);
  Serial.println(ADJUST_STATE);
  
//  Serial.print("DEBOUNCE: \t");
//  Serial.print(DEBOUNCE);
//
//  Serial.print("\tdebounceStart: \t");
//  Serial.print((int)debounceStart);
//
//  Serial.print("\tTime Elapsed: \t");
//  Serial.println(millis() - (int)debounceStart);

  //Process switch logic
  if (ADJUST_STATE) {
    potVal = analogRead(POT_PIN);
    ledBrightness = (256*potVal)/1024;
    analogWrite(RED_LED, (int)ledBrightness);
    analogWrite(YELLOW_LED, (int)ledBrightness);
    analogWrite(GREEN_LED, (int)ledBrightness);
  }

  //Change brightness of LED based off potentiometer switch when not in blink mode
  if (BLINK) {
    if (millis() - startTime > waitTime) {
      startTime = millis();
      currentLED++;
      if (currentLED >= 3) {
        currentLED = 0;
      }
    }
    
    switch(currentLED) {
      case RED:
        analogWrite(RED_LED, (int)ledBrightness);
        analogWrite(YELLOW_LED, LOW);
        analogWrite(GREEN_LED, LOW);
        break;
      case YELLOW:
        analogWrite(RED_LED, LOW);
        analogWrite(YELLOW_LED, (int)ledBrightness);
        analogWrite(GREEN_LED, LOW);
        break;
      case GREEN:
        analogWrite(RED_LED, LOW);
        analogWrite(YELLOW_LED, LOW);
        analogWrite(GREEN_LED, (int)ledBrightness);
        break;
      default:
        break;
    }
  }
  else {  //If not in blinking mode make all LED's light up
    analogWrite(RED_LED, (int)ledBrightness);
    analogWrite(YELLOW_LED, (int)ledBrightness);
    analogWrite(GREEN_LED, (int)ledBrightness);
  }

  //Handle button debounce
  if (BUTTON_DEBOUNCE && !BUTTON_PREV_DEBOUNCE) {
    buttonDebounceStart = millis();
  }
  if (abs(buttonDebounceStart - millis()) > buttonDebounceTime) {
    BUTTON_DEBOUNCE = false;
  }
  BUTTON_PREV_DEBOUNCE = BUTTON_DEBOUNCE;
}

 

Images:

Interrupts

Interrupt, Switch Blinking LED from Red to Yellow

Experimented with some of the values.

Tested the button with pin13 before proceeding- button works.

Did not consistently get it to switch colors every time I pressed the button down.

First interrupt attempt (successful), includes questions:

int rLED=9;
int yLED=10;

int ledOn=5;

volatile int switch_color=2;

//see loop for onoff pattern, did other iterations with more complex onoff patterns, made it more difficult to cue the interrupt
int ledDelay=250;

void setup() {

  pinMode(rLED,OUTPUT);
  pinMode(yLED,OUTPUT);

  pinMode(switch_color,INPUT);
  attachInterrupt(digitalPinToInterrupt(switch_color),switchLed,FALLING);
//does rising or falling matter? maybe only needed with more than 2

  ledOn=rLED;

  Serial.begin(9600);
//does this impact the switch back to red from yellow?

}


void switchLed() {
    ledOn++;
    if (ledOn > yLED) {
        ledOn = rLED;
    }
}


void loop() {
//red LED turns on and off based on delay variable, then on for delay*10, and off for delay*5 before repeating
digitalWrite(ledOn,HIGH);
delay(ledDelay);
digitalWrite(ledOn, LOW);
delay(ledDelay);


}

Tangible Interface for Geospatial Modelling

http://tangible-landscape.github.io/#:~:text=Tangible%20Landscape%20is%20an%20open,by%20GRASS%20GIS%20and%20Blender.&text=This%20makes%20geographic%20information%20systems,developers%20%2D%20like%20gaming%20with%20GIS.

^Intended for education. I was reminded of this after reading about the dynamic sand table in Make It So.

Make It So Readings: how did we think about the future in the past? – Erin P

General Notes

-Science fiction technologies evolve as audiences become more sophisticated and informed by real technological advances.

-Real technology sets a bar for interface/technology expectations of sci-fi audiences – must go above and beyond present reality within believable bounds to distinguish itself from pure ‘magical fantasy.’

-Interface defined as ‘all parts of a thing that enable its use.’ Spans industrial design, information design, and interaction design.

-Interface evaluation (for purposes of this book) require media that is audiovisual, time-based, and consistent.

-Genre of media is speculative/science fiction, loose definition, not getting too into the weeds on definitions.

-Motorola’s StarTAC took cues from Star Trek communicator

-‘all design in fiction- at least until it gets built.’

Past Thoughts about the Future

-Ch. 1 touches on the reciprocal influence of speculative fiction technology and the real world, and examples of this from the past. The design ‘kitchen of the future’ came up in last class, would be curious to know more about the reciprocal relationship there. Read an article about the Frankfurt kitchen a few days ago: https://www.bloomberg.com/news/articles/2019-05-08/the-frankfurt-kitchen-changed-how-we-cook-and-live

-Interfaces have ‘legacies’ – buttons/knobs/switches (also appealing to use for human hand). Digital controls and touch screens are only recently available. New interfaces most understandable when they build on ones that users/audiences are familiar with.

-Industrial age paradigm: few mechanical controls (levers, buttons, knobs), direct, mechanical feedback via interfaces with ‘very little abstraction between cause and effect.’

-Electrical age paradigm: more mechanical controls, with people using levers/buttons/knobs everyday

-WWI brought vast numbers of people into contact with military technology- control rooms, radio and communications.

-Dedication to realism increased over time  (ex: restrained control board in Destination Moon, 1950).

-Low budget lead to the design of the touchscreen-esque interface in Star Trek: The Next Generation in 1980s – movement away from mechanical controls.

-Computation resulted in very abstracted feedback between cause and effect, with graphical user interfaces restoring greater sense of ‘direct manipulation’ for user.

-Virtual/mechanical control fix likely in fiction and in real life due to advantages of each, ie fine motor control for mechanical and complexity allowed by virtual.

 

 

Assignment 2 – James Kyle

Some interrupts in daily life:

    • The urge to drink water
    • The sunset – indicates it’s time to go home
    • A notification on your phone (quite literally an interrupt)
    • Gas light in your car – tells you it’s time to fill up

 

Thoughts on Make it So:

The reading talks a lot about how science fiction and design are symbiotic in nature because of the way that they both influence each other. I thought this cat and mouse description of the way designers and science fiction writers interact was interesting because they are in competition to push the future to customers but it’s not necessarily clear whether the fiction or the design comes first. I also liked the way they explained how design frequently follows science fiction because it is a way of determining what products will succeed. If a work of fiction does well, i.e. Star Trek, then maybe products from that universe will also do well. I think the idea of using what already exists is a powerful tool because I feel like as an engineer myself I often get caught up in trying to design a solution from end to end (which is quite inefficient and not very successful) instead of leveraging what has already created to actually make something new.

I also liked the note about feedback and time delay when they talk about minimizing the time between a users action and the systems reaction. The field of haptics relies on this minimization of interaction and system reaction in order to convey realism from electromechanical systems so it makes sense that the same rule applies in visual mediums as well.

Assignment 2 – Judson Kyle

Thinking About the Future:

One way that people thought about the future in the past brought up in “Make It So” is by connecting it to what already exists. The first two chapters have many examples of this, but one of the most notable is the connection between science fiction and the future. In the past, science fiction has been used as a starting point for futuristic designs because the genre cements certain expectations and ideas in the general public of how things should look. The popularity of science fiction causes people to be more comfortable with the new technology and ideas proposed. As mentioned in the reading, people this comfort results in a certain expectation of how things should look which in turn drives how people think about design problems. Another example of this looking for comfort can be found in how people dreamed about and pursued space travel. Similar to how ships and the sea were seen as the new way of the future a while ago, space was beginning to emerge as this new frontier. Since people already had an association between nautical references and exploring the unknown, this became a large inspiration for things like the word astronaut or the way space ships were designed. Both of these examples from the reading demonstrate the search for familiarity in designing for the future which resulted in expansion of what already existed.

In addition to this expansion on the present, people also thought about the future as having to do with interaction of some sort. As mentioned throughout the reading, the future consisted of products that had to have human interaction of some sort in order to function requiring some sort of interface to work. As mentioned previously, the connection between design and science fiction is also important here because a lot of science fiction has to do with how people interact with futuristic devices.

Interrupts In Daily Life – Judson Kyle

Some Examples of Interrupts:

As a diver, when I am learning a new dive, the coach will yell at us while we are in the air and upon hearing the call we will come out ready to enter the water. Another interrupt is when you have the urge to use the restroom, especially during the night. An example of a less common interrupt would be a fire alarm for a fire drill or actual fire emergency.