Cube Switch Game Update – Code Is complete

The code and the circuit for the game is complete. We only need to fabricate the cube and run the Arduino wirelessly using Bluetooth. The game starts by hitting the start button all the way on the right. The user must hit the button of the corresponding LED within the allotted time. This amount of time shrinks with each button press until the user loses, at which point all the LEDs will flash.

Continue reading “Cube Switch Game Update – Code Is complete”

Cube Switch Game Update – No Timer Yet

An update to the progress of the game we are making for our midterm P Comp project. We currently have the circuit working without any count down timer. In the video below you can see that I am hitting the start button on the far right to activate the game. Next, I am matching the button I press to the LED that is lit up.


You have noticed that the analog pots are now replaced with buttons, and this was done just to simplify. As time allows, we will make some functions to allow us to switch out the buttons for different analog sensors.

Beginning Stages of Cube Switch Game

For the P Comp midterm, Marco Wylie and I are working on a game that is kind of mash-up of bop-it and a fidget cube. The device will be a box with LEDs and various switches/buttons on 5 sides (one side will have a handle and the on/off and start buttons). Our intention for how the user will interact with the game is below.

  • Flip the power switch to on.
  • Press “start” button to activate it.
  • An LED on a random side will light up and the user will have 10 seconds to hit the switch on the corresponding side.
    • If the user successfully hits the switch in time, another random side will light up and the user will have 9 seconds to hit the switch on that side… and so on. The time to hit each switch will decrease by 1 second every time.
    • If the user misses the switch in the allotted time, they lose and all the LEDs will flash. The game is over.
  • Once the game ends, the user can hit the start button to play again. Or turn off the power when he/she is done.

I am currently working on building the basic circuit and Arduino program for this. Here is the circuit that I built. It has pots, buttons, and LEDs that are each connected to the appropriate digital and analog pins.

So far I have set up the code so that I can get the LEDs to light up randomly when a button is pressed. I will need to add to the code so each LED is tied its button and so that it is connect to a timing system. Here is a short video and the code I have so far for the random LEDs lighting up.

 

Merging Serial Communication with p5 Underwater Scene

I am starting to use asynchronous serial communication to connect what we are doing with the Arduino in P Comp with what we are doing with p5 in ICM. It’s pretty exciting with all the new possibilities, but first I wanted to see if I could use two sensors to make changes in a pre-existing p5 sketch I had.

Continue reading “Merging Serial Communication with p5 Underwater Scene”

Automated Scissors – Updated!

Since this was a catch up week, I worked on fixing up my automated scissors project to reflect my original intent. This means I solved my problem of making my LED blink while the servo was in motion.

It turns out that using code for “blink without delay” solved my problem. However, it still took me an embarrassingly long time to figure out where to slide this piece of code into the rest of my Arduino sketch. I initially had it running outside of my loops to make the servo move and had it run when the “swtichState” variables were HIGH. I think this didn’t work because the loop that moves the servo had to completed before doing anything else. I also tried using¬†Tom Igoe’s Interval library, which I couldn’t make work for only the button press. Finally, I moved the blink without delay code into the right spot and my servo and blinking LED combination works! It needed to start right before the servo begins to move inside of the loop. Here it is working with the code below.


Continue reading “Automated Scissors – Updated!”

Automated Scissors

To follow up on my previous issue with LED blinking… I decided instead of flashing, the LED should stay on to indicate when the servo is moving. I did explore a few methods for blink without delay using millis(), but I had trouble making it only blink when the button was pressed and only for the duration of the servo’s motion. Anyways, I automated a pair of scissors using a servo. It runs at two speeds depending on how fast you want to cut some paper. Here is a gif of it in action.

Continue reading “Automated Scissors”

Working with Servo Motors

I am currently working on this week’s project for Physical Computing and I am running into some issues with servo motors. Specifically, how I can do other things while the servo motor is running.

First, I’ll go over what I’ve done so far to check that certain parts of my circuit and code are definitely working. I started by making a circuit to control the servo using a potentiometer. Before putting in a servo, I used an LED to make sure I wired the potentiometer correctly.

Next, I swapped out the LED for my servo and updated my code to use the servo library.



All of this was working great. So I know for this week’s project I want to have a servo that will go through its motion and then return to the original position after it completes its travel. I am able to get this working as shown below.

And then because I will have an option (via push buttons) to choose a slow or fast speed, I want the LED to blink either fast or slow accordingly. I added the LED blinking code using delays, but it slows down my servo’s motion to a crawl.


I know it’s going through the delays each time it loops to move my servo, so I am looking into ways to avoid using delays to get my LED to blink. Or is it only possible stop the slowing down by running one output at a time? I doubt it, so I’m going to keep looking into solutions.

Light Level

This week, I worked on using both digital and analog components with my Arduino. I wanted to use a photoresistor, an analog component, but I first started all with digital inputs to make sure I wired and programmed my Arduino correct. I initially forgot to connect my switch to high voltage, which caused the signal from the button switch to be inconsistent. I fixed the issue after noticing my LED not lighting properly. I made this code:

And after fixing my button switch circuit, it worked to light up my LED.

Next, I knew I needed replace the button switch, except I would need to wire it to the analog pins on the Arduino. I wanted more lights to light up based on how much light the photoresistor sensed. If it sensed more light, then more of the LEDs would light up.  Here is what my circuit diagram looks like:

And then this is the code I created:

Which then yielded this: