Back to Parent

Outcome


Outcome and Process

This is our second lab in DIoT class. I am able to know how sensors work and the characteristics of Argon (like, do not support SparkIntervalTimer.h so I can't use some sensors that I usually use on Phonton....).

Getting Inputs

Combine a switch and potentiometer. The switch should turn on and off the light while the potentiometer will fade up and down the light (but only when its on).

The task for Getting Inputs is the combination of switch and potentiometer. The tricky part is that the potentiometer shall only work when the LED is on. In this case, I put the code chunk of potentiometer inside the if condition that the button state is low. The code and video are attached.

Show Advanced Options
Show Advanced Options

Working with Sensors

Photoresistor and Temperature Sensor

Add a photocell/resistor to the TMP36 circuit and post both temperature and light readings to the Particle cloud.

I use two separate analog pins for photocell and TMP36. Both the readings of photocell and TMP36 can be retrieved from the Particle cloud. The photocell reading will also serve as a brightness indicator of the LED - I use the reverse mapping. with 0 - 4095 maps to 255-0 as a negative linear relationship. I think it makes more sense since we only need additional lighting (LED in the example) when the ambiance light is low.

The code and video are attached.

Show Advanced Options
Show Advanced Options

FSR Game

Make a basic game which challenges you to reach the most force.

Set three levels of force: medium (>1000), hard (>1500) and extra hard (>2000).

If the player gets to medium - blink once; hard, twice; and extra hard three times.

Wait until the force sensor reading returns to zero before starting again.


This is a fun exercise as I can play the game after setting up. The tricky part is to use the if statement for different force ranges. I also use the ledBlink function we built in Lab 1 to make the code cleaner and easier to change the variables. Please note that the original analog read range is too narrow for me to differentiate, so I use 1000 interval for FSR readings.

Show Advanced Options
Show Advanced Options

Practice Exercise: Combining Sensors and Inputs

The final challenge for week 2 is the exercise to combine sensors and inputs. I came up with a system as follows:

The system will start when the ambient light drops to a certain level. The LED will be lit. 

The starting point of the brightness of the LED will compensate for the ambient light drop.

Then we can use the potentiometer to adjust the brightness to achieve a personal ideal level for lighting comfort.

Other than that, I set up the FSR sensor for temporarily raising the brightness and system shutdown - if the force reading is less than 2000, i.e., we press the FSR sensor slightly, the LED will light up to its maximum brightness for 2 seconds. If the force reading is larger than 2000, then pressing the FSR sensor will shut down the system, namely turn off the LED>

The system can work as a personal lighting system in office space. When sunset is approaching and the ambient light is not sufficient, the personal lighting fixture will turn on. The occupant will be able to adjust its brightness by using the rotating button. However, if there is a task that requires high illuminance, the occupant can touch the button to temporarily raise the brightness of the lighting fixture for work. If the occupant would like to turn off the personal lighting system, they can press the button to do so. This system is handy and already being applied in the industry.

The setup is below. I also attach the code and demonstration video.

Img 3756.thumb
Show Advanced Options
Show Advanced Options
Show Advanced Options

Reflection

This lab let me know how to use the input devices and sensors separately and collectively. I also learn how to use if statement, and nested if statement. It helps me build the skills needed for the following week. I also learned how to create my own prototype design by doing practice exercise 2.

Drop files here or click to select

You can upload files of up to 20MB using this form.