All posts by Daniel Ryan Johnston

PComp Week 8: SPI and I2C Labs

SPI Lab: Digital Potentiometer

I got the code and physical aspects setup but there was no change in the ton volume. I was expecting some range but there was nothing.

I did notice a discrepancy within the instructions for the physical set. In the drawing, the negative lead of the speaker is connected to the 100 ohm resister then to the digital pot but the text accompanying the diagrams contradicts that. I did try both and the results were the same. A tone was produced with no column variation.
SPI Tone Breadboard Setup 1SPI Tone Breadboard Setup 2

I2C Lab: APDS-9960 RGB and Gesture Sensor

First tried code from the lab but received errors that the APDS was undefined. I made sure to use the Arduino library but could not figure out how to rectify this.  I then added the Wire.h library which took care of that error.  Then, I received the following error. 

i2c error Arduino screenshot

I was thinking maybe the solder on the headers was maybe an issue so I tried tow examples from SparkFun library.

1 – Gesture Test
I was able to get the breadboard setup properly but did not get any readings on the serial monitor.

2 – ColorSensor
This test was successful. See video below of serial monitor output.

3 – Proximity Sensor
Was able to get this working within the serial monitor

The only quesiton  I have are why wont the other examples work for this sensor?

ICM Week 8: Pixel Project

For our pixel manipulation project, Rajshree Saraf and I decided to make a piece inspired by a hologram card where, as you move the card, another image is revealed.  I am having trouble finding a image reference of the optical illusion but will update once acquired. 

Rajshree shared this piece by Kerry Rodden which inspired the user interaction we will work to create.  In Rodden’s piece, the sketch finds and tracks the user’s eyes in order to create the multicolored eye drawings.   The video below is a screen capture of my interaction with Rodden’s piece. 

Kerry Rodden Eye Sketch

 Currently, we are working individually on our code and will come together to create the final piece.

PComp Week 7: Project 2 – Game Controller Preliminary Documentation

For the 2nd project, I have decided to create a game controller with corresponding game.  The controller will be spherical with 2 force sense resistors (FSR) and a push button.  The object of the game will be to get a ball into a box.  The FSRs will control the x and y of the ball.  Once the ball is in the box, the ball will shrink and/or disappear as the box will turn red.  The button will bring a new ball into play as well as a new box.  The ball will start in the same location but the new box will be in a different location. 

The controller will have a hard inside with a foam covering and will fit in the palm of the user’s hand.  Below are my preliminary sketches followed by the breadboard set up for the controller:

Proj 2 NotesProj 2 Controller Design 2

Proj 2 Breadboard

It would be great to be able to have different size balls created each time that have to make it into specific boxes in order for box to close off.  This will depend on my coding skills but I am up to the challenge.  If I can add additional features to the controller I would like to do that as well.

I will be using the Arduino code from the Two-way Serial Comm Lab as a template to build off of.   So far, I have the following coded in P5.js:

Pressing the mouse mimics the effect of pressing the button on the controller.  I need to investigate further working with the objects and arrays in order to keep the sketch from slowing down.

Here is a demo of the sketch from the Two-way Serial Comm Lab using 2 FSR’s to control the ball. 

 

My next steps are 1) get the code squared away, 2) test out/mock up housing for controller, and 3) investigate materials for final controller. 

PComp WK 7: Two-Way (Duplex) Serial Comm Lab

Lab: Two-Way (Duplex) Serial Communication Using An Arduino and P5.js

Video: what is char and why is it used here?  This is a clip from Tom’s video Serial 6: Better Processing.

Char Image

Setup board with Force Seeing Resistor, potentiometer and bush button.

Breadboard Setup

Part A:
Ran program with just serial monitor and got the 3 numbers separated with ‘,’.

Part B: p5.js
Since I was not using the accelerometer in the Nano, I needed to change the values in serialEvent() so that the value ranges were applicable to the FSR and the potentiometer.

Receive Data in P5.js

 

Flow Control: Call and Response

The only challenge I had with this was getting the sketch to run.  I needed to close all the open post (P5.js and P5 Serial Control) then upload the sketch to the Nano without testing the call and response within the serial monitor.  Once that was done, I could open the port within the P5 Serial Control app then run the sketch in P5.js.

The sketch was smoother than the first because of the handshaking. 

 

Question:

Why does the last sketch not work after the P5.js sketch is stopped then restarted?  In order to get it to work again I have to close out of the serial control as well as uploading the Arduino sketch again.  Then I reconnect the Serial Control and restart the sketch.

PComp Week 6: Asynchronous Serial Comm. (P5.js Input/Output)

Lab 1: Intro to Asynchronous Serial Communications

 Overall. no issues working with Arduino although more practice and experimentation will be beneficial to understanding the concepts from this and the following labs.  I did, however, run into an issue getting the code to work for reading the Nano’s onboard accelerometer instead of using an external one.  The code provided stated the following:

accelerometer error

 I do nMeed more practice with understanding handshake and call and response.

Lab 2: Serial Input to P5.js

Tried again with a fresh mind and was able to get it working.
Insert video 1A (Fig. 13 related video)

After Fig. 13, within the “What’s Happening Here” section, the text states:
“You may be wondering why you’re mapping the sensor value or dividing it by 4 in the Arduino sketch above. That’s because in order to send the sensor value as a single byte, it must be between 0 and 255, or no more than 28 bits.”

Where are we dividing the sensor value by 4?

ANSWER: within map, we are mapping the sensor value from 0-1023 to 0-255. 255 is right 1/4th of 1023.

2B: Graph

Tried adding delay(100) to the loop. Which loop?
Tried adding within draw, received error noting delay is not defined.
Tried adding to graphData() after if statement, same response.
Where do I add the delay to effect the loop?

ANSWER: Add to the Arduino sketch not p5.js

2C: ASCII
Added println(inData) and received error: printlin is not defined then my computer started overheating and the browser was working hard (spinning). Had to restart browser.

Changed println(inData) to console.log(inData) and it worked. There was a definite delay though.

Screen Recording 2020-10-20 at 10.34.55 AM

Lab 3: Serial Input to P5.js

3A: LED
I was able to get the LED to respond to the movement of the mouse as well as if I typed 0 though 9. The LED changed it’s brightness as expected.

I did have to edit the code in function keyPressed(){…} as the && signs were showing up as && which caused an error.

Also tried the speaker for this lab but used a 220Ω resistor instead of the 100Ω requested in the setup.

3B: ASCII encoded numeric string
Tried this part with the speaker setup and was able to get it to work. H produced a tone and L ended the tone.

Running the code through p5.js using H and L worked! 

3C: Processing ASCII-Encoded Strings With Arduino

I don’t really understand this part. I was able to add numeric strings into the serial monitor and the speaker beeped a few times before it stopped taking input/making sound.

I am not sure exactly what is happening with his lab.

I would like to get further examples of using Table 1. Serial Communication: p5.js to Arduino (below) as I think it might help to clarify any confusion. 

chart