Process Journal #1
In this class, our assignment was to explore XBee radio communication through the concept of high (“H”) and low (“L”) commands as incoming data. Our class was each given an XBee radio, and an XBee breakout board to experiment transmitting and receiving radio commands. Our final assignment was to set up our XBee radios to control an actuator of our choice on Arduino that would respond to a “metronome” that was transmitting a count from an accompanying XBee.
Part 1: Testing with the XBee Radios
Step 1: Internally sending and receiving
The first step was to connect my XBee radio to CoolTerm to test if my Arduino Micro would respond to high and low commands. I opened up CoolTerm, connected to the serial port that my Arduino was hooked up to, and tested typing “H” and “L” commands to turn on and off an LED. I had no problem with this working.
A classmate and I testing out our transmitting and receiving with each other. They are transmitting “H” and “L” to control the LED light on the Arduino.
Turning the LED lights on and off using “H” and “L” commands.
Step 4: Changing the code
I was inspired by the realization that the Philip’s Hue Lights use a type of radio communication as controls. I have a few within my own possession and wanted to see if I could create a very simplified version. I copied the “H” and “L” command code, but rather than simply turning on and off the lights, I used different keys to change the colour of the strips. Here in the video below, I use the commands “R” for red, “G” for green, “B” for blue, “P” for pink, “Y” for yellow, “O” for orange, and “W” for white.
Creating a simplified version of Philip’s Hue Light by transmitting simple letter commands to control the hue of the LED strip.
Part 1 overall outcome
At this point in my radio experimentation journey, the most exciting part is the ability to control one, or multiple other, devices through transmitting commands. I feel quite inspired through the mock “Philip’s Hue Lights” test to create smaller bespoke lamps for my own bedroom.
When testing by myself, the simple commands for turning the actuators on and off do not feel that different from what I have the ability to do with an Arduino solely.
When testing with others, I found that it was interesting to see the differences in “lag” depending on the radio. The classmate I was testing with had about a second delay on their commands, which led for confusion when attempting a proof of concept. The lag only went one way; when I would send commands their LED would turn on and off almost instantly. I wonder if this has anything to do with the machine speed on either side.
Part 2: Metronome
For this part of the experiment, I wanted to count how many “beats per a minute” the metronome was outputting. I decided upon this after choosing as my output, which was an LCD display.
Step 1: Choosing an output
For this experiment, I rifled through my toolkit to see what I had that would be newer and interesting to play with. I found an LCD LiquidDisplays that I had inherited from my Dad’s electronic supply and decided the use it.
I found readily available documentation for the LCD screen on AdaFruit. I followed the tutorial and connected the screen to my Arduino Uno. I was able to get a “hello world” screen up and counting the seconds that have passed.
LCD screen displaying the LiquidCrystal example which prints out “hello, world!” and on the second line counts how many seconds the program has been on.
Step 2: Connecting the XBee and LED lights
I then moved the connections to my Arduino Micro. I used the same code that worked for initial experimentation that made the addressable LED lights turn on and off. Rather than simply turning the LEDs on and off, I changed the brightness of them. I found that if I turned them on and off fully, it was too much of a drain of the power in the circuit. This would cause the LCD screen to flicker. As well, on the high command, on the screen I printed out “high” and on the low command I printed out “low”.
LCD screen connected to CoolTerm, and receiving “High” and “Low” commands to change the input of the screen, and as well the brightness of the LED strip.
Step 3: Counting the beats
Because I was testing this at home, I wrote a pseudo metronome in my code to mimic different speeds of a count.
I would change the value of the metronome to get varying results. I would count the passing millisecond’s in-between counts, take 60000 and divide the result, and multiply by two to take into account the offbeat. I took this count and printed it out to the LCD screen.
LCD screen displaying a rudimentary BPM of the program
Step 4: What are you dancing too?
I took the BPM of the mock metronome, and then created statements that would print out what type of music correlated to the actual bpm that was listed. If the BPM was lower than 60 or higher than 200, messages of “slow is also good” come up, or a warning saying “Don’t dance too fast!” appear.
LCD screen showing the bpm of the program & what type of dance music is associated with that beat.
The one bug I have yet to fix is that the program initially detects that the bpm is half of what it is within the first couple of counts. It quickly fixes itself upon the second round of metronome counts.
Part 2 overall
I found this program to be interesting because it was not simply turning something “on” or “off”. It dynamically takes in data and will be able to print out the data accordingly so.
Testing out the screen with the metronome did not give as specific data as I thought. The range for the metronome was 100 – 5000 milliseconds, while my code is optimized for a range 200-1500 milliseconds. This is not necessarily a bad thing, as it requires someone to slowly go through the range as opposed to just cranking the potentiometer in either direction.
Overall the experiment was an interesting exercise in communication. It was interesting to see what other folks did with the metronome data in the class. Some interpreted the data to count every fourth beat, while others used the data to control servo-motors. The work altogether was interesting to see, and because of the nature of the rhythm of the metronome, it seemed to all connect in a collage-like way.
Liquid Crystal: https://www.arduino.cc/en/Reference/LiquidCrystal
Tutorial for LCD screen: https://learn.adafruit.com/adafruit-arduino-lesson-11-lcd-displays-1
Different music types: https://accusonus.com/sites/default/files/media/blog/Electronic_music_tempo-.pdf