Category Archives: Mstr Atoms and Bits

Is this seat free?

In this very very basic project, this switch reveals if a seat is available or occupied, using similar lighting signals to a taxi. When the seat is free, the switch is not activated and the light remains on and blinking. When someone sits down, the switch is activated, turning the switch off. The code I used for this is the same one that we used in class. The photo shows the Arduino set up but does not include the switch (I left that at home). The red and black wires are connected to the switch when it is attached.

seatfreeifswitch

Switching It Off – Securing the Butt Pocket Part 2

Continuing from the first part of the pocket switch, this new part incorporates a a watch. Basically, the user now has the option to turn off the motor and lit LED that activate when the phone/wallet is removed. With the power of the switch, the user can turn it to the “Off” setting to turn off the LED and motor. Once the phone/wallet is back in the pocket, the switch can be flipped back to reset the security.

 

And here is the source code:

 

Arduino Code
My source code

 

 

Trying (Piano Fingers!)

Hi Guys,

As someone very new to this and to the class(though I’m sure most of you are too)- I’ve tried for the last few days to just situate myself with the arduino. After watching countless tutorials and trying to read the manual, I found that I understood some things. After trying to teach myself, I’ve learned how to blink lights, and that I probably should have came in for some help.

To make this slightly more interesting, I wrote the code for the blinking to the song “Mary Had A Little Lamb”

The first five fingers represent the first five LED lights. Watching the LED lights as you play on the piano simultaneously would allow you to play the first part of that song.

Ideally, the blinking lights could correspond to a key on the piano to provide visual stimulus to music. This could be a musical learning product.

IMG_2261

 

void setup() {
// initialize the digital pin as an output.
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
pinMode(8, OUTPUT);

}

digitalWrite(10, HIGH); //
delay(50); //
digitalWrite(10, LOW); //
delay(10); //

digitalWrite(11, HIGH); //
delay(50); //
digitalWrite(11, LOW); //
delay(10); //

void loop() {
digitalWrite(12, HIGH); //
delay(50); //
digitalWrite(12, LOW); //
delay(10); //

digitalWrite(11, HIGH); //
delay(50); //
digitalWrite(11, LOW); //
delay(10); //

digitalWrite(10, HIGH); //
delay(50); //
digitalWrite(10, LOW); //
delay(10); //

digitalWrite(10, HIGH); //
delay(50); //
digitalWrite(10, LOW); //
delay(10); //

digitalWrite(10, HIGH); //
delay(200); //
digitalWrite(10, LOW); //
delay(10); //

digitalWrite(11, HIGH); //
delay(50); //
digitalWrite(11, LOW); //
delay(10); //

digitalWrite(11, HIGH); //
delay(50); //
digitalWrite(11, LOW); //
delay(10); //

digitalWrite(11, HIGH); //
delay(200; //
digitalWrite(11, LOW); //
delay(10); //

digitalWrite(10, HIGH); //
delay(50; //
digitalWrite(10, LOW); //
delay(10); //

digitalWrite(9, HIGH); //
delay(50); //
digitalWrite(9, LOW); //
delay(10); //
digitalWrite(9, HIGH); //
delay(50); //
digitalWrite(9, LOW); //
delay(10); //

 

}

Big Red Button (PANIC)

FRUSTRATION!!
Assignment No. 2 Photo

ICM: Assignment No. 2 from Nicole Kim on Vimeo.

For my program, I had three switches and three LEDs. I wanted to have switch A turn on the red LED, switch B to turn on the green LED, and switches A and B when pressed simultaneously to turn on the yellow LED. The big red button on the third switch would make the LEDs blink sequentially (panic!!).

For some reason when I coded the yellow LED separately from the rest of the program, I got it to work when both switches were turned on. I even got the code to work with the whole system one time, but then I stupidly fidgeted with the wiring, so the only-yellow-LED code doesn’t work! Frustration!!

void setup(){
pinMode(8,INPUT);
pinMode(7,INPUT);
pinMode(6,INPUT);
pinMode(5,OUTPUT); //red light
pinMode(4,OUTPUT); //yellow light
pinMode(3,OUTPUT); //green light
}

void loop(){
if(digitalRead(8)==HIGH && digitalRead(7)==HIGH){
digitalWrite(4,HIGH);
digitalWrite(5,LOW);
digitalWrite(3,LOW);
}else{
digitalWrite(4,LOW);
digitalWrite(5,LOW);
digitalWrite(3,LOW);
}

(Code for the yellow LED- why do green and red LEDs turn on as well?!)

If anyone wants a little extra homework and wants to help me figure this out later….aaaarggg!! (But I’m still excited && proud of my code this week!)

 

You better do your reading

The idea:

(Still don’t know what to do with the two ugly yellow wires…)

This time, I decided that having a red “warning” light on would remind me of past horrors of falling behind on readings and thus give me enough anxiety to open to the page marked by the Starbucks sleeve. When I reach the page marked by The Bean sleeve, I would tuck the Starbucks sleeve inside, turning the red light off and turning on a blue “strobe” light. Time to treat myself to a coffee break AND a dance party in my room.

Better do your reading (Yes, I slapped an Instagram filter over it, whatever.)

The code:

void setup(){
pinMode(7,OUTPUT);
pinMode(4,OUTPUT);
pinMode(8,INPUT);
}

void loop(){
if (digitalRead(8) == LOW){
digitalWrite(7,LOW);
digitalWrite(4,HIGH);
}

if (digitalRead(8) == HIGH){
digitalWrite(7,HIGH);
delay(100);
digitalWrite(7,LOW);
delay(100);
digitalWrite(4,LOW);
}
}

simple switch

simpleswitch

 

 

 

 

 

 

 

 

 

 

I decided to keep it simple and just create two switches that would each activate a separate LED. The first would activate the large blue light and the second would activate a set of three smaller, red lights.

Here is it in action: http://www.youtube.com/watch?v=WCdfZnBvoR

And here is the code:

 

 

RGBlink

 

Ok, so after messing around with the RGB LED for a good two hours, I’ll report my results:

“If you are using a common ANODE LED instead of common CATHODE, connect the long pin to +5 instead of ground”

so.. connecting it to ground as we do with the others won’t work, also, if I write LOW to a pin will turn the LED on and if I write HIGH, that will turn it off. Oh yeah, and all 3 inputs use the same ground (which is actually 5V). Hopefully at some point in class we can delve deeper into why I can’t get it to listen to me, no matter what I do. 

So, here is something I managed to get to work much earlier in the night:

the RGBlink!

http://www.youtube.com/watch?v=dhUMZsbcsf0&feature=youtu.be

The red wires connect the red switch and LED, the green to the green, the blue to the blue. Pressing the switch makes the LED blink, pressing both switches makes both blink, etc. If all 3 are pressed, the LEDs will blink in order starting from whichever was pressed first. I used the two tiny button switches and one that I soldered earlier this week. Here is the code:

 

 

UPDATE::::: after learning a bit more about cathodes and anodes, I figured out that we have a common anode LED, so the long leg from the LED should always lead to 5v, and passing a value of 0 through the LED turns it on (while passing 255 will turn it off) so it is a little counter-intuitive. And on a frustrating, though less important note, the leg order is: R(Anode)BG, not RGB like I thought.

I borrowed this RGB blink code from an instuctable and added an switch+if statement:

http://www.youtube.com/watch?v=nvrFK9KNcvk

 

it still didn’t work 100% as I expected, but I figured you guys might like the blinky LED

 

Catman Strikes Again!

I made a simple circuit with two lightbulbs.

photo (12) photo 2

The green bulb blinks whenever the switch is not in use. The blue bulb is set off when a connection is made within the switch. In this scenario, Lil Elephant tries to warn Rubber Ducky about Catman with a secret message embedded in the blue bulb using really sloppy Morse Code. Can you guess what it is?

Catman Strikes Again

Code:

void setup(){
pinMode(7,OUTPUT);
pinMode(8,INPUT);
pinMode(3,OUTPUT);
}

void loop(){
if(digitalRead(8) == HIGH)
{
digitalWrite(3,HIGH);
delay(2000);
digitalWrite(3,LOW);
delay(300);
digitalWrite(3,HIGH);
delay(700);
digitalWrite(3,LOW);
delay(300);
digitalWrite(3,HIGH);
delay(2000);
digitalWrite(3,LOW);
delay(300);
digitalWrite(3,HIGH);
delay(700);
digitalWrite(3,LOW);
delay(300);
digitalWrite(3,HIGH);
delay(700);
digitalWrite(3,LOW);
delay(300);
digitalWrite(3,HIGH);
delay(2000);
digitalWrite(3,LOW);
delay(300);
digitalWrite(3,HIGH);
delay(2000);
digitalWrite(3,LOW);
delay(300);
}
else{
digitalWrite(7,HIGH);
delay(350);
digitalWrite(7,LOW);
delay(350);

}
}

 

Switching It Up

When the switch is turned on, the blue light is illuminated and the red and green lights are off. When the switch is turned off, the red and green lights are on and the blue light is off.

IMG_4591

IMG_4594

IMG_4595


CODE:

void setup(){
pinMode(10,OUTPUT);
pinMode(8,OUTPUT);
pinMode(7,OUTPUT);
pinMode(4,INPUT);

}//Setup

void loop(){

if (digitalRead(4) == HIGH){
digitalWrite(10,HIGH);
digitalWrite(8,LOW);
digitalWrite(7,HIGH);

}//if HIGH

if(digitalRead(4) == LOW) {
digitalWrite(10,LOW);
digitalWrite(8,HIGH);
digitalWrite(7,LOW);

}//if LOW

Don’t Forget Your Keys (Part 2)

The switch is activated.
The switch is activated.

So to be 100% honest I forgot to take a picture of my circuit before I disassembled it and I just didn’t feel making it again just to take a picture. However, because my project this week tied in to last weeks switch I just reused that picture. So I’ll just describe everything and I swear it works. The idea was that if the keys were on the hook and the door was closed one LED would flash on and off. If the key was on the hook but the door was opened the LED would stay on constantly and a buzzer would go off. If the key wasn’t on the hook though nothing would happen. To keep things simple though I just used two panic button switches instead of using the key and door switches. Below is the code for this. Also I couldn’t get the buzzer to work so I just used two LED lights instead.

void setup(){
pinMode(8,INPUT);
pinMode(7,OUTPUT);
pinMode(13,INPUT);
pinMode(12,OUTPUT);
}
void loop(){
if (digitalRead(8) == HIGH){
if (digitalRead(13)==HIGH){
digitalWrite(7,HIGH);
digitalWrite(12,LOW);
delay(1000);
digitalWrite(7,LOW);
digitalWrite(12,LOW);
delay(1000);
}
else {digitalWrite(7,HIGH);
digitalWrite(12,HIGH);}
}
else {digitalWrite(7,LOW);
digitalWrite(12,LOW);
}
}

Double the switches, double the fun

Video

Meet the two switches involved in making this project:

Caleb's first soldered piece, ever
Mr. panic button from last week
Emily's Switch
the well-soldered not-so-panic button

 

…and the full setup:

a tad complicado

 

Using the code below, we made a setup which set off different LED light combinations based on which switches were open and closed. Watch the video to view all of the different LED blinking combinations.

void setup(){
pinMode(7,OUTPUT);
pinMode(10, OUTPUT);
pinMode(8,INPUT);
pinMode(9,INPUT);
}

void loop(){

if (digitalRead(8) == HIGH){
digitalWrite(7,HIGH);
delay(300);
digitalWrite(7,LOW);
delay(300);
}

if (digitalRead(9) == HIGH){
digitalWrite(10,HIGH);
delay(100);
digitalWrite(10,LOW);
delay(100);

}
}

Five Finger Switch

The idea behind my switch is that it is a hand, with each finger switching on a different LED when combined with the thumb. The metal bits are meant to go on the tips of the fingers of one hand. The red wire is the thumb, going down to the pinky with the green wire. When you touch your thumb and pointer finger, the red LED comes on, thumb + middle finger = blue LED, etc. A combination of fingers will turn on a combination of LEDs, but the combination must include the thumb.  I got this idea with the hopes of making it into gestural video art. Instead of LEDs, the combination of fingers would turn on different videos, or layer them in different combinations.

five finger_1

five finger_2

video

the code:

void setup(){
pinMode(7,OUTPUT);
pinMode(6,INPUT);
pinMode(9,OUTPUT);
pinMode(8,INPUT);
pinMode(11,OUTPUT);
pinMode(10,INPUT);
pinMode(13,OUTPUT);
pinMode(12\,INPUT);
}

void loop(){

if (digitalRead(6) == HIGH){
digitalWrite(7,HIGH);
}
else {
digitalWrite(7,LOW);
}

if (digitalRead(8) == HIGH){
digitalWrite(9,HIGH);
}
else {
digitalWrite(9,LOW);
}

if (digitalRead(10) == HIGH){
digitalWrite(11,HIGH);
}
else {
digitalWrite(11,LOW);
}

if (digitalRead(12) == HIGH){
digitalWrite(13,HIGH);
}
else {
digitalWrite(13,LOW);
}
}

 

Ooo ooO

a tad complicado

Caleb and I made TWO separate switches with TWO separate LEDs that blinked at TWO separate speeds.