Category Archives: Assignments

Week 4: Button Combination Lock

The button combination lock assignment commissioned us to make a electric lock that could be “unlocked” when a predetermined combination was input into the Arduino processor.  I attempted this assignment in two different ways.

The first was engendered by an Instructables page, HOW TO: MULTIPLE BUTTONS ON 1 ANALOG PIN – ARDUINO TUTORIAL, through this way I gained a better understanding of how to set up the breadboard circuitry. However, the method failed as I was not getting a consistent return on data from each button.

Assembly:

As seen in the pictures I set up the breadboard as the tutorial had indicated, using a resistor ladder, so that all the input could be sent through a single connection (0A). Unlike the tutorial, my return when each button was pressed was not a single identifying number, but a series of randomly repeating numbers. For example, the green button when pushed would show a random compilation string of the numbers 2,3, and 4. Thusly, I was unsure of how to proceed to associated the series to a variable.

Also unlike the tutorial, I found that the resistors they recommended, 1x 1K, 2K, 3K and 10K resistors, were too strong, resulting in more inconsistent returned numbers from the buttons. When I changed the resistors to those of a weaker level the series of numbers returned had less 0s and a more unique set (if you will). In the image below of the Arduino monitor screen you can see a set of 4 randomly occurring numbers. Starting from the left; blue button was 1, 9, 8, 2, and 0, yellow button was 1, 2, and 3, green button was 2, 3, and 4, and lastly red button was 6, 5, and 1.

Materials:

  • Arduino uno
  • Breadboard
  • 4x button sw
  • 4x leds (yellow,red,blue,green)
  • 4x 330 Ohm (or 220Ohm) resistors
  • 1x 1K, 2K, 3K and 10K resistors

How it works/ Issues:

According to the Instructable, “for every time a button is pressed, the Arduino receives an analog value from 0 to 1023. ” Depending resistance to each button this value changes, which is what I saw when I changed the resistance to a lower value. The architect of this assembly found that they would recognize which button was pressed by the analoged value from the resistor (1st button: 1013
2nd button:1004, 3rd button: 995, 4th button: 871), however like previously state, mine did not have a consistent return value.

http://www.instructables.com/id/How-to-Multiple-Buttons-on-1-Analog-Pin-Arduino-Tu/

void setup() {
Serial.begin(9600);
int buttonvalue;
pinMode(A0,OUTPUT);
const int ledPin = 13; //Pin 13 will have the LED light
}
void loop() {
  int sensorValue = analogRead(A0);
  Serial.print(sensorValue);
  delay(1000);
}

Since I don’t have much experience with code, nonetheless Arduino circuitry, I turned to a classmate for help. Together we recoded part of the arduino and changed the board to where there was no longer a single connection transporting the data, but one direct connection per button. The coding was mostly his doing and its subsequent dissection allowed me to see the synatx of his method.

Assembly:

  1. Using a bread board and two jumper wires connect the ground to GND on the Arduino and the power to 5V on the Arduino.
  2. Take out the four buttons and place them abreast one another and in the center of the board.
  3. On the ground side take out the 4x resistors (800ohm to 1,400 ohm) and per button, connect the ground to the button leg (leave space for the jumper wire).
  4. Using 4x jumper wire, place the wire in between the button and resistor and connect to a subsequent digital pin (13-10).
  5. Connect another 4x jumper wires from the other side of the button to the power.
  6. The 220 ohm resistors will connect into ground and orient them towards the center of the board.
  7. Place the LED (negative side) along side the resistor.
  8. One the positive side of the LED place the remaining two jumper wires and connect them to digital pins (8 & 9).

Materials:

  • Arduino uno
  • Breadboard
  • 4x button sw
  • 12x jumpers
  • 4x resistors ranging from 800ohm to 1,500ohm
  • 2x 220 ohm resistors
  • 2x LED (green and red)

How it works/ Issues:

In comparison to the Arduino code the physical circuitry was relatively easy to put together. Nevertheless it still doesn’t work, so I can’t for certain say my composition is functional. Each button is connected to it’s own jumper cable which is then connected to an individual pin on the Arduino. Using const int I associated the pin number (13-10) to a correlating button (green, red, blue, yellow). The resistor were connected into ground while the end cable was connected to power to complete the circuit. Since each isolated pin could relay data directly to the board, in theory, it made identifying the buttonpush easier, from this point the Boolean code and conditionals would determine a combination and process the data. This part was out of my depth, but my classmate’s help and contributions have allowed me to gain a better understanding of how the Arduino processes information.

Button Combination Lock

I will include the code with my dissection.

Chyelle’s Dissection of Arduino Code Syntax

 

Combination Lock – Xiaoyu

Goal of project/interaction

Utilize 4 small buttons to create a combination locker
Use 1 big button to submit & reset
Green and red led to show whether the passcode is right or not
Yellow led to show each correct press

The lock passcode: 4213

Core components

4 * small buttons
1 * big button
3 * LED (red, yellow, green)
5 * 10k ohms resistors
3 * 220 ohms resistors
Wires & jumpwires
Arduino board

How it works

Press the button sequentially once a time with no repeat
If it is in right sequence, yellow led will blink
Press the yellow big button to submit (and it will reset at the same time)
Green led means unlocked (right), red led means locked (wrong)

Problems/bugs

If you don’t start with 4, and then you pressed 4, then press the buttons in a right sequence, the locker can still be unlocked.

 

 

Code

https://drive.google.com/file/d/1dMNzO5L76kNQxGnp5vSFpdWs0Kjg4Gy6/view?usp=sharing

 

Combination Lock (Week 4)

  1. Goal of the project : By utilizing a sequence of button presses, make multiple leds to radiate. Like a concept of lock, each led represents whether it is locked / unlocked.
  2. Core components : 4 buttons, 4 x 10K ohms resistors, yellow and blue leds, 2 x 220 ohms resistors, breadboard, arduino board, jumper wires
  3. How it works : I made a circuit that enables a certain rule of button press to make each led shine. When button 1 and button 3 are pressed at the same time, yellow led emits, and if button 2 and button 4 are pressed at the same time, blue led emits.
  4. Problems encountered : A little confusion with making a circuit for multiple buttons – where to the power and output connections go – but I figured out with reminding the basic mechanism of buttons.

Continue reading

Week 4: Combination lock

This Week’s assignment was to create a circuit for a combination lock. The default state for this circuit is locked (represented by a red LED). When all four buttons are pressed in the right sequence, the circuit becomes unlocked (LED turns green).

List of Materials

1 x Elegoo Uno R3

1 x Full sized breadboard

4 x Pushbuttons

2 x LED’s (Red and Green)

Resistors: 4 x 220 Ohms (for the LEDs), 2 x 10K Ohms (for the buttons)

Jumper wires

Description of assembly 

  1. Connect both sides of the breadboard to each other. The ground to the ground and the power to the power using jumper wires.
  2. Connect the ground side of the breadboard to the GND pin, and the power side to the 5V pin, on the Arduino.
  3. Add pushbuttons to the breadboard, where one of the legs is connected to the power source, the adjacent leg to the ground (through the resistor). Connect the leg opposite the ground to a digital pin. When the pushbutton is not pressed, the digital output pin is connected to the ground and returns a LOW state. When it is pressed, the circuit gets complete, electricity flows through it, and a HIGH state is recorded.
  4. Arrange the LEDs with the shorter leg connected to the ground through a resistor and the longer leg to the digital pins.
  5. Upload the code to the Arduino IDE.
  6. Debug, check connections and keep working on iterations.

How it works

The Arduino code, has nested if loops that sequentially check whether certain conditions hold true. It first checks whether button 1 is pressed, if it is, then it checks if button 2 is pressed and so on and so forth. There are two variables being used buttonPushCounter and val. The first checks whether any button is being pressed and the other is to determine the order in which they are being pressed. It is only when all the four buttons are pressed in the right order that the green LED lights up.

Challenges

Setting the circuit was not as challenging as was getting the code to work. I encountered a problem with my buttonPushCounter because it wasn’t registering button presses. I used the console to debug and realized that it was because I had defined the variable globally as well as locally which was interfering with the functioning of the code. The solution is to either define it globally or to use something called static int to define it within the scope of the void loop.

What I am still struggling with is using the same button twice in the code. At present, I can program different combinations of button presses, but I cannot get the counter to reset every time a button is pressed.

Code 

//Referenced from code available on the Arduino forum

https://forum.arduino.cc/index.php?topic=364464.0

Continue reading

Week 4 – Lisa’s Lock

 

Goal of the project and/or desired interaction

This week, our homework was to make a lock that can be unlocked (green light will light up) with a specific pin or password with Arduino. And inserted with the wrong password or pin, a red will light up indicating the password is wrong.

Quick description of assembly and list of core components

1x Arduino board

1x Medium breadboard

1x Green LED

1x Red LED

1x Blue LED

4x Buttons

2x Resistors (220 ohms) for resistors

4x Resistors (10K ohms) for buttons

How it works

There are 4 buttons and 3 LED lights (green, red, and blue). The blue light will be on when the lock is ready. To unlock the lock, the pin is 0, 0, 1, 2, 3. Once you press the right pin, the lock will unlock with a green light that indicates it is unlocked. When you press the wrong pin, the red LED will light up and flashes.

Any problems you encountered and/or solved

I had problems setting up the sequence and had a hard time assigning them to the right buttons. After debugging my circuit and with the explanation and help others, I was able to get the sequence right.

Images of my circuit

Arduino Code

https://github.com/lynnn43/PhysicalComputing/tree/master/pcomp_wk4_hwk_lock

 

Continue reading

Simon’s locker- Carla Molins

 

  • Goal of the project and/or desired interaction

The goal of the project was to create a locker that opened (green light) when the right color code was pressed ( 4 different colours). The light must be red while the code remains wrong.

  • Quick description of assembly and list of core components

1x Arduino

1 x medium breadboard.

1x green LED

1 x red LED

4 x buttons

2 x resistors (220 ohms) – resistors

4 x resistors ( 10K ohms) – buttons

 

  • How it works

My proposal includes a counter that allows to keep tracking of the correct sequence thanks to validating certain if statements. At the end, green LED lights up, and after blinking and a short delay, red light turns ON again, and it’s locked again reseting the counter to start again.

  • Any problems you encountered and/or solved

I had problems to find the correct sequence that allowed to keep the good sequence. My counter kept reseting until I debugged the code.

Images of your circuit 

.

Arduino Code 

https://github.com/Lywa/carla_molins_Pcomp/tree/master/locker_v2

Continue reading

Joyce’s Lock(week 4)

Goal:

The goal of this project is to build a combination lock that uses 4 buttons and LEDs that indicates lock status.

Components:

red led x1

green led x1

blue led x1

button x4

resistor(200Ω) x4

resistor(10kΩ) x4

arduino board & breadboard

 

How it works

Users need to input a combination of 4 numbers to open the lock. The blue button is a reset light which will light up 5 seconds after the right code is input (The lock is locked again, the input is reset ) or the wrong four numbers are input (meaning please try again, the input is reset). The red light means a wrong code is pushed and the green light means the code is correct.

Code: https://github.com/joycemolly/pcomp–lock-combination/blob/master/homeworkLock.ino

Week 3: The story of Circuitville

The story of Circuitville

Team members:
Aakanksha Aggarwal, Elizabeth Ho, Joyce Zheng

We wanted to explain the differences between a series and parallel circuit (in terms of the Current flow, Voltage distribution, and resistance) in a fun, and engaging way. We thought that making a narrative, and introducing characters would be an effective way to introduce the differences to complete beginners.

One of the major takeaways for us was that we learned so much about this concept while trying to making a teaching aid. Also, it compelled us to think about the core ideas, the logic behind the working of circuits instead of the numerical or symbolic representations.