top of page
  • Writer's pictureAlan Seder

EDTEC 568 - Arduino Challenge - The Sixth Week

Welcome to the fifth week of EDTEC 568 - Makerspaces Build Challenge. This week's challenge was the "Iron Chef" challenge with the secret ingredients of motor and sensor. What I opted to do with this challenge was to control a motor's speed using a distance measurement from an ultrasonic sensor. Since I also wanted the motor to actually do something, I used the motor to drive a zoetrope. As a zoetrope requires relatively fine control, I also set up an on-off switch and a motor spin direction switch. To accomplish all this control (and frankly to get to play with an integrated circuit chip) I used the transitions onboard an H-bridge IC chip to facilitate al the motor controls.


To begin, we will take a look at the Motor_Ultrasonic project code I generated in Sketch on the Arduino IDE shown below. The sequence of the program is to identify the pins and global variables for the ultrasonic sensor, followed by the pins and global variables for the motor control. Note all the pins are digital pins and that the motor control parameters are set up as "byte" constants or variables which ar 8-bit with values ranging from 0 to 255. The void setup() initializes the pins for the the ultrasonic sensor, initializes the serial monitor, and initializes the pins for the motor control via the H-bridge IC chip.


Next, the void loop() checks the states of the on-off switch and the motor spin direction switch. Then, the ultrasonic sensor is used to make a distance reading which is limited to be active from 0cm to 40cm. The distance measurement is then used to calculate a motor speed setting so that the motor speed is zero outside 40cm and increases proportionally to the maximum motor speed as the distance decreases to 0cm.


Finally, the Sketch goes through a series of checks to establish the position of the on-off switch and the motor spin direction switch using state variables, followed by outputting the related signals to the H-bridge IC chip to control the motor, and storing the last state variables before returning to the beginning of the loop to check for changes of state and run through the code again.

Motor_Ultrasonic Code

Next, below are images from various perspectives of my Arduino Uno and the breadboard with the Motor_Ultrasonic project I built. The circuits are relatively simple looking on the breadboard, but this belies the complexity given the circuitry built into the ultrasonic sensor and the H-bridge IC chip.


The circuit diagram for the Motor_Ultrasonic project is below. I am not exactly proud of the "cleaness" of the layout. Circuit complexity is getting to the point that I would switch to using some drafting software i the future. Note the power for Arduino and the power for the motor comes from different sources, but that both circuits share a common ground; this is an important lesson I learned from setting up equipment for my amateur radio station where my common ground is a 9-foot copper rod driven into the Earth.


The following video shows the Motor_Ultrasonic project in action and describes the workings of the circuit and some features of the Sketch code uploaded from the Arduino IDE.


When I first thought about this week's challenge, I considered many different directions - light sensor control, temperature sensor control, sound sensor control, and, perhaps the worst idea, flame sensor control. I had wanted to play with the ultrasonic sensor, so I said "What the heck." and indulged myself. I guess I am either becoming more whimsical in my challenge selection or just a bit punchy. To round out whichever the case may be, I love zoetropes so I decided to put my motor to work. Choosing how to address a challenge has made doing these assignments even more enjoyable; I now have a better sense of how my students feel when they are empowered to choose.


Upon reflection, I feel I learned quite a bit about DC motors, the use of the H-bridge IC chip, and the use of an ultrasonic circuit. While being able to use these components successfully was satisfying, I cannot help but feel that the opacity of the project has increased. When using sophisticated components like the H-bridge IC chip and the ultrasonic sensor, a large portion of the circuitry in play are less accessible to the maker. Yes, one can (and should) look up the circuit diagrams for these components which promotes some understanding of how they work, but to truly understand I feel one needs to be able to take things apart and modify them. I think the takeaway is my students should work with basic building block components, at least at first, to promote their understanding before the ability to do so gets lost in the complexity. In retrospect, I probably shortchanged myself a bit by using the transistors on the H-bridge IC chip rather than using individual transistors to build the switching circuits. What can I say, having been trained as an engineer, I was taught to be efficient (lazy?).


Now, a bit of discussion of my extension this week. My plan was to replace the ultrasonic sensor with an alcohol breathalyzer sensor. The plan was to set up the sensor so that the zoetrope could only be stopped if the breathalyzer registered within the legal limit to drive; so, if you can stop the zoetrope, you get your car keys back. Of course, if the party contains coders, someone may think modifying the sensor input would make a great drinking game, as in "See how fast you can make the zoetrope spin!" As an engineer by training, I know that you can only make something foolproof, not idiotproof. Hopefully, a coder's ability to code will be impaired before their judgement, but this is not a failsafe situation.


Sadly, my alcohol breathalyzer sensor did not arrive by the time of this posting; therefore, I have avoided the potential technical issues and legal ramifications for now. Between the rise of COVID in our areas and still teaching in-person at my school during the last few weeks before finals, I probably would have enjoyed field testing the extension device.

22 views0 comments

Comentarios


Post: Blog2_Post
bottom of page