Recent Question/Assignment

Bachelor of Creative Technologies
ENEL599 2021 S2 – Assignment 2
Summative (25%) Due: Friday, 24th of September, 9am
Task
In this assignment, you are required to create a hardware that measures an analogue signal (e.g., from a potentiometer or from an LDR or phototransistor) and sends these results to a Processing sketch which continuously displays the signal. In the Processing sketch, you can use the mouse to set a threshold that causes a) a red/green LED on the Arduino to change brightness when the signal is lower or close to this threshold and b) a buzzer to sound when the signal is above the threshold.
You will be provided with a Processing skeleton sketch where you have to fill in the blanks to make the code work together with your Arduino.
For completing the assignment, you have to:
1. Download the code and folder structure skeleton .ZIP file from Blackboard and unpack it on your computer. Make yourself familiar with the structure and which files are where.
2. Design the circuitry. Create a schematic and a breadboard layout using Fritzing.
3. Implement the hardware on the breadboard.
4. Design, write, and test the code on the Arduino.
5. Complete the code skeleton for Processing.
6. Submit all necessary files to Blackboard.
7. Provide two photos and a short video on your blog.
Hardware
You will need:
1. An Arduino (or compatible)
2. A variable resistor for an input sensor, e.g., potentiometer or LDR
3. If necessary, a suitable resistor for the voltage divider
4. Two LEDs (red and green) + Resistors (220O, 330O, or 470O)
5. A buzzer/speaker
6. Breadboard and cables
Software
Download the skeleton file provided on Blackboard and unpack it onto your computer.
Complete the empty Arduino sketch and fill in the blanks and TODOs in the provided Processing skeleton sketch to fulfil the required task.
Make sure you apply the coding guidelines that you have learned in the previous semester in
“Programming for Creativity” (variable names, comments, indentation, etc.)
Detailed Task Description
In effect, with this assignment, you are creating a data logger or an analogue oscilloscope.
On the Arduino side, your sketch needs to use an analogue pin as an input of the signal created by a potentiometer or an LDR/phototransistor. Your main loop measures the input constantly and rapidly and sends the result to the Processing sketch. Preferably the measured value should be sent in full 10-bit precision with mechanisms in place that avoid data corruption (e.g., sanity checks).
You can decide whether to send the data as ASCII (using print and println) or as binary (using write). The former is easier to debug using the Arduino console. The latter is more efficient and allows you to measure faster.
The Processing sketch needs to receive this measurement data and pass it on to the Graph object which will display it on the screen.
The Arduino further keeps track of a threshold level (initially 512) to control two LEDs and a buzzer.
1) As long as the signal is lower than the threshold, the red LED is active. The brightness of the red LED depends on the difference of the actual signal from the threshold. The closer the signal to the threshold, the darker the LED. In effect, the brightness can be calculated as:
???????????? = ??h??????h?????? - ????????????
255, ???????????? 255
????????h???????????????? ?????? = { 0, ???????????? 0
???????????? ????h????????????
2) As soon as the signal is within 20 units of the threshold, the green LED is active.
???????????? = ??????(???????????? - ??h??????h??????)
????, ???????????? = 20
?????????? ?????? = {
??????, ????h????????????

3) As long as the signal is higher than the threshold+20, the buzzer is active (1000Hz).
???????????? = ???????????? - ??h??????h??????
????, ???????????? 20
???????????? = {
?????? ????h????????????

The following figure represents a schematic view of the LED and buzzer behaviour given a threshold set at 512 and represented by the red, horizontal line.
Buzzer
Red LED
Green LED
Threshold
By clicking into the Processing graph, you can set the threshold to a new value which should be sent to the Arduino and immediately take effect. Again, it is your decision whether Processing sends the new threshold as ASCII text or as binary value to the Arduino.
The comparison with the threshold and control of the LEDs and the buzzer should be implemented purely on the Arduino side!
Bonus
To claim the bonus of 10%, modify the Arduino and Processing code so that the Arduino measures all six analogue channels, sends those six 10-bit values to Processing (with a proper protocol in place to avoid data corruption/confusion) where they are displayed in 6 charts below each other.
The red/green LED/buzzer code functionality does not change in principle, but will operate on the channel that had its threshold value changed last, i.e., it should start on A0, but when you change the threshold on channel A3, the LEDs/buzzer should operate on the signal on that channel until a new threshold/channel is selected.
The final grade of this assignment will be capped at 100%.
Assessment Criteria
Your submission is going to be marked on the following criteria:
Code (LO1)
Information provided in the header (title, description, name, Student ID, etc.) 5%
Commenting 5%
Structure/Indentation/Cleanliness 5%
Variable naming 5%
Code quality and efficiency 10%
Functionality (LO1+2)
Signal is measured and sent to the Processing sketch in 10-bit precision 10%
Mechanisms are in place to avoid data corruption during transfer in both directions 7%
Threshold comparison and LED control happens on the Arduino 3%
Red/Green LEDs and the buzzer behave accordingly around the threshold 5%
Threshold can be changed from Processing sketch 7%
Wiring diagram (LO3)
Cleanliness (e.g., using a fairly optimal positioning of the components) 5%
Suitable wire colours (5V: red, GND: black, etc.) 2%
No connections are un-routed 2%
Schematics (LO3)
Cleanliness and use of right angles as much as possible 5%
Proper labelling of the components and positioning of the labels 5%
Grouping of functional components (e.g. input related and output related components) 2%
No connections are un-routed 2%
Hardware (LO3)
Cleanliness of wiring (straight, no long/blank wires, etc.) 5%
Suitable wire colours if possible (5V: red, GND: black, etc.) 2%
Photos and Video (LO2)
Functionality is clearly demonstrated 5%
Photos are focussed, well lit, and show the hardware clearly from different perspectives 3%
Bonus (LO2+3)
Implemented the 6-channel mode
+10%
5