Coding with an Arduino

CODING WITH AN ARDUINO

In order to program with Arduino, one must first download the Arduino coding application (Arduino IDE). Arduino IDE is available on both Windows and Mac devices. Simply search for it in your App Store and download from there. 

The Arduino Nano is the main Arduino that is used in the MakeLab. In order to work with an Arduino Nano in the coding, the proper Board, Processor, and Programmer need to be set:

Board: Arduino Nano

Processor: ATmega328P (Old Bootloader)

Programmer: Atmel. I have successfully used STK500 and JTAG. To see what works for your Arduino, try to upload a simple code and run through the different programmers until one of them works.

MUSICAL LIGHTS OPEN-ACCESS CODE

Analog Circuitry

In order to create the musical lights display, the following components were used:

*All of these components are avaliable in the MakeLab!*
Pin connections of the Arduino Nano, the microphone chip, and the LED strip.

Microphone Chip (hw 484 vol. 2)

This component is a simple, and low-cost device that is used to detect sound waves traveling through the air. It also measures the intensity of the waves and converts them into an electrical signal which can be read through a microcontroller.

LED Strip (WS2812B LEDs)

This component is made so that you can use one pin on your breadboard in order to power the entire strip of lights.

The analog output (A0) of the microphone chip should be connected to A1 on the Arduino Nano. The 5V input should be connected to the 5V output of the Arduino Nano, and the ground of the microphone chip should be connected to the ground of the Nano.


The 5V wire of the LED strip should also be connected to the 5V output on the Nano, and the ground should also be connected to the ground of the Nano. The Din wire should connect to D4 on the Nano. 

A1 and D4 are established because these are the pins used in the open-access code. It is possible to use different pins, but the code must be modified to account for the change. Use the diagram on the right to obtain the correct new pin number.

The pin numbers for the Arduino Nano. Use the purple numbers for the digital pins and the green numbers for the analog pins. Sourced from Components101.

The code works to establish a relationship between the microphone chip and the LED strip such that:

As the outputting voltage value of the microphone reaches a defined threshold, the LED strip will turn on.

This relationship is actually quite simple to create in Arduinos, and it is created using an "if" statement.


The code used for the musical lights installation can also be accessed from the zip folder linked here.


The code used for the Makerspace Workshop session, along with the four week sessions, can be accessed and used from the Zip folder linked here.

References:

Arduino nano. (2021, July 17). Retrieved February 28, 2023, from https://components101.com/microcontrollers/arduino-nano

How does a sound sensor work and how to interface it with Arduino? Arduino Sound Sensor Tutorial - How Sound Sensor works and How to Interface it with Arduino. (n.d.). Retrieved February 25, 2023, from https://circuitdigest.com/microcontroller-projects/interfacing-sound-sensor-with-arduino

What is WS2812B led and how to use WS2812B led. SDIP Light. (2021, June 23). Retrieved February 25, 2023, from https://www.sdiplight.com/what-is-ws2812b-led-and-how-to-use-ws2812b-led/#:~:text=How%20do%20WS2812B%20work%3F,pin%20(DIN%20and%20DOUT).