Physcial Computing Blog

Week 2 - Working with Arduino

This week's activities consisted of first interactions with the Arduino interface and working with some programming concepts. Since I have a programming background I could get through the basic concepts easily but the hardware side of the story is all new and somewhat challenging. Terms like activity boards and development boards the distinction between them or how microcontrollers differ from processors and so on. As I understand the bootloader on Arduino is used to change the program or shift the bits into the memory and it is then capable of running that program whenever it is powered on.

After reviewing the pins and their functions on the Arduino 33 IoT, I started the labs and using the pins I was able to make digital and analog inputs control an LED's behavior. The potentiometer was a bit loose so I had to keep it in place with my finger to make the circuit function properly otherwise it would just stay on and would not behave according to the state of resistance.

The distinction between analog and digital I/O is still a bit foggy to me, I have to look into how they differ exactly, but for now I can see that a digital I/O only has two states, true or false, and an analog I/O has rising and falling and peak states, it's a spectrum rather than a switch. And as I understand the analog behavior is achieved by pulse width modulation on the Arduino 33 IoT. I hooked up an FSR and printed the value returned by the sensor into the Serial Plotter, it seems to be a rather noisy input, or maybe it's just normal behavior.

Then I used this input to control an LED, I first read the value using analogRead(), mapped the value received by the sensor into a range of 0 - 255 to control the brightness of the LED and wrote the value using analogWrite() through pin 11.

void loop() {
  int sensorValue = analogRead(A0);
  int mappedValue = map(sensorValue,0,1000,0,255);
  Serial.println(mappedValue);
  analogWrite(11,mappedValue);
}

There are lots of possibilities now that I can access the physical domain in a programming environment, as fun as it sounds it also can be a challenge to figure out what can be done using this interface, I'm excited to explore more. Maybe I can introduce a speaker and do some sound synthesis.

Nima Niazi