Lab Activity:
Our sequence in Arduino involved pressing the button once to turn the LED on, pressing a second time to make it blink sequentially, and a third time to turn the LED off.
This is the code for our sequence:
int ledPin = 13; // choose the pin for the LEDSoft Wearable
int inputPin = 2; // choose the input pin (for a pushbutton)
int val = 0; // variable for reading the pin status
int mode = 0;
boolean press;
void setup() {
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(inputPin, INPUT); // declare pushbutton as input
}
void loop(){
val = digitalRead(inputPin); // read input value
if (val == HIGH) { // check if the input is HIGH
press = true;
if (mode == 0) {
digitalWrite(ledPin, LOW); // turn LED ON
}
else if (mode == 1) {
digitalWrite(ledPin, LOW); // turn LED ON
delay(500);
digitalWrite(ledPin, HIGH); // turn LED ON
delay(500);
}
else if (mode == 2) {
digitalWrite(ledPin, HIGH); // turn LED OFF
}
}
else {
if (press == true) {
press = false;
digitalWrite(ledPin, LOW); // turn LED ON
mode += 1;
if (mode == 3) {
mode = 0;
}
}
}
}
The soft wearable we'll be handing in this week is a bracelet made of felt with 5 LEDs running off of 2 circuits embedded around the outside. The Arduino will control the circuits to turn on, off, or alternate blinking. It will be attached via a ribbon cable up the arm further to stay hidden. The circuit is completed with copper ribbon tape on the inside of the bracelet:
Sketch One Brainstorming:
In discussing soft wearables we played with the idea of possibly making a visor which is touch and light-sensitive with LEDs lighting up according to the sensor. If we developed this idea it would be an interactive wearable head-piece.
Attachments:
Assignment 2: Reading
No comments:
Post a Comment