Week 2: Testing the 3 Sensor Circuit

 After the successful distance measuring test last week, our next goals were:

  1. Set up a breadboard prototype with 3 sensors and 2 speakers. 
  2. Program the device to work with 3 sensors simultaneously.
  3. Program the speakers to output a beeping noise with various speeds depending on the object proximity and direction to each of the sensors. 

Table 1. Truth table of which speaker would work depending on the direction of the detected object.

Left Sensor

Middle Sensor

Right Sensor

 

Left Speaker

Right Speaker

On

Off

Off

 

On

Off

Off

Off

On

 

Off

On

On

Off

On

 

On

On

Off

On

Off

 

On

On




Figure 1. Diagram of 3 sensor, 2 speaker, and an Arduino Nano circuit


This week's accomplishments:

  1. The circuit was set up correctly with the 3 sensors, 2 speakers, and the Arduino Nano.

  2. The 3 sensors were tested and were correctly measuring distance simultaneously.

  3. The speakers did work with the sensors but an issue was found.


Figure 2. Picture of the 3 sensors connected to the Arduino



Figure 3. Video demonstration of distance measurement of each sensor


The issue that we encountered:

    The warning system did not work as planned. It did output a beeping sound when a sensor was triggered, but the 2 speakers were not working at the same time. Only one speaker could operate at any given time. This was found to be due to the Arduino Nano only being able to output one command at a time, which is because the microprocessor only has one core. To output two or more commands at once, a multicore processor must be used but this would exceed the budget of the project.


How the issue was solved:

    During the weekend after the lab day, a solution to the problem was researched and found. The solution was to use the timer feature included within the Arduino Nano. The Arduino has three timers, two of which could be used for our needs. When triggered, the timer periodically outputs a signal to the speaker independently of the microprocessor. To do this, an Arduino library called “Tone.h” was used (https://code.google.com/archive/p/rogue-code/wikis/ToneLibraryDocumentation.wiki). With this, we were able to program the speakers to be able to work at the same time or separately. 






Comments