1. The piezo buzzer
We will be using the same shield as the first training session (Keyestudio Easy Module Shield V1: see right). This shield contains a passive piezo buzzer that is connected to port D5. Marco Aita has encapsulated the Arduino tone library in a XOD node that can be used to switch on and control the pitch of the buzzer.
The Training Session TWO software will be available as a xodball file that can be downloaded from this site.
Identify the buzzer node, copy into a patch and experiment with the use of inputs from other devices on the shield, such as the variable resistor and photoresistor. The buzzer provides a useful device for audible alarms. Next, we'll wire up a digital sensor.
2. Digital thermometer
The DS18B20 chip is a digital thermometer that provides 9-bit to 12-bit Celsius temperature measurements (and has an alarm function with nonvolatile user-programmable upper and lower trigger points). You will be provided with a waterproof sealed unit with a 1M lead. The DS18B20 chip is contained in the stainless steel tip, and communicates over a 1-Wire bus that requires only one data line (and ground) for communication with the Arduino. In addition, the DS18B20 can derive power directly from the data line (“parasite power”), eliminating the need for an external power supply. Each DS18B20 has a unique 64-bit serial code, which allows multiple sensors to be placed on the same 1-Wire bus. XOD provides a node in the "common hardware" library that can read single 18DSB20 devices in a circuit.
The sensor measures temperatures from -55°C to +125°C with better than ±0.5°C Accuracy from -10°C to +85°C (see graph) - the chip is internally calibrated and returns a digital measurement that can be displayed directly. (For more information, see: https://create.arduino.cc/projecthub/TheGadgetBoy/ds18b20-digital-temperature-sensor-and-arduino-9cc806)
Your challenge is to devise and implement in XOD a temperature alarm system using the Arduino prototyping system, DS18B20 sensor, LCD panel readout and buzzer.
3. Sonar device
XOD contains a node that supports use of an ultrasonic sonar distance sensor, the HC-SR04. For more information about the device, see: (https://components101.com/ultrasonic-sensor-working-pinout-datasheet).
The ultrasonic transmitter emits an sound waves at 40 000 Hz which travel through the air and if there is an object or obstacle on its path It will bounce back to the module. The module also has a receiver that allows measurement of the travel time. Knowing the speed of the sound allows calculation of the distance. The HC-SR04 Ultrasonic Module has 4 pins, Ground, VCC, Trig and Echo. The GND and the VCC pins of the module need to be connected to ground and the 5 volts pins on the Arduino board and the trig and echo pins to any Digital I/O pin on the Arduino Board.
Can you use this code to create a theremin-like device, using different forms of input to control the (potentially) tuneful passive buzzer output device?
4. Timing for XOD: traffic light
The programming of timing sequences in XOD is not as straightforward as in standard text languages. The developers of XOD have provided a very useful example and step-by-step tutorial. Marco Aita and Carlos Lugo have rewritten this for use with the shield and RGB LED. Please find the tutorial online at:
...and the code in the Training Session TWO library.