top of page
  • Writer's pictureJack Chen

Pcomp week 2

This week I completed the digital input and output lab, and the analog input lab.

I begin first with the digital input lab and setup on the breadboard a circuit which allows the Arduino Nano 33 IoT to read digital input from a push button and then output the result to light up either a red or yellow LED based on if the button is pushed.

digital input output lab setup1

After setting up the circuit, I begin coding with the Arduino IDE for the first time. After reading this week’s materials and learning about some basic coding concepts in ICM class, I was able to roughly understand the general principles of coding an Arduino. In order to practice writing code, I wrote the code manually while referring to the lab examples instead of copy and pasting directly.

coding in arduino IDE

The first circuit worked without any difficulties once I uploaded the code to Arduino.

I then moved on to the analog input lab and setup the breadboard to let the Arduino read input from a potentiometer and output the result from the potentiometer to an LED. Manually inputting the code resulted in some errors when I first compiled the code from spelling errors and punctuations, the console gave me straightforward debugging tips about characters missing or variables undefined (usually because of spelling mistake) and I was able to fix them without too much struggle.

errors in Arduino code

after completing the potentiometer setup, I did another analog input circuit with a photoresistor going into the input pin of the Arduino and outputting to an LED. I mapped the input value based on serial monitor values from when I cover the photoresistor with my hand and without my hand, but when I upload the code the LED’s brightness did not correspond well with weather or not my hand was covering the photoresistor. I tried mapping again with different values but the serial input I get changes the range every time, I think this is because the LED lighting up and down also changes the brightness around the photoresistor, which in turn affects the LED’s own brightness as well.

The next setup I did was to input values from two force sensitive resistors (FSR) into the Arduino and outputting the values onto two LEDs. For this setup I write my own sketch based on examples provided in the lab tutorial. I still had to heavily reference the structure and functions used in the examples but I was able to write a working sketch with my own variables and comments using different pins as the tutorials. I had to fix some errors once again from spelling and punctuation/format mistakes but I was glad to finally get it working in the end.

0 views0 comments

Recent Posts

See All
bottom of page