top of page
Search

Week 7- Iron Chef Challenge

  • Writer: Audrey Schank
    Audrey Schank
  • Dec 8, 2024
  • 6 min read

This week we were challenged to develop something original using a secret ingredient- Iron Chef style! Our secret ingredient was a motor.

I actually started the week with the plan to ask ChatGPT for assistance in coming up with an idea using a motor, but I just couldn't understand all that it was telling me to do.  I decided to go with the DC motor and worked on completing Circuit 10 in our Arduino guide. I felt more comfortable with this because I have not had much success in completing the weekly challenges thus far. I knew I would not be comfortable writing code on my own.

I am proud to share that I was actually able to complete this Circuit! It wasn't without a lot of trial and error, but I did it! The code was running fine, the board was lighting up, but the motor just wasn't spinning. I tried turning around the resistor and diode, but no luck. I then figured I had used a temperature sensor instead of the transistor because they look exactly the same and I can't see well enough to read the print on the back of them (even with my phone magnifier. I tried changing these out by trying each one. Finally I went back to the original transistor I used (the others did turn out to be temp sensors) and turned it around and the little motor started spinning. I could hear the buzzing on the counter top but I couldn't really see anything happening. I tried to make a little flag type thing by taping on a strip of paper and that helped a bit, enough that I could see that something was happening.

This circuit reminded me of fan blades spinning. I asked ChatGPT for more examples and it gave me automated fan control, windshield wiper simulation, and smart door lock mechanism.

I am glad I ended the maker challenges with a success! It has been a long road (really only 7 weeks!) with lots of frustration, disappointment, and even some tears, but I didn't give up and did actually find a few successes along the journey!


Video of Spinning Motor:


Photo of Set-up:

Electronic Diagram from Arduino Guide:


Code from USK Guide:

/* Example sketch 10 SPINNING A MOTOR Use a transistor to spin a motor at different speeds. We'll also show you how to input data from the serial port (see the serialSpeed() function below). Motors are the basis for thousands of things in our daily lives, and the Arduino can control them. Here we'll use pulse-width modulation (PWM) to vary the speed of a motor. The Arduino pins are strong enough to light small LEDs (up to 40 milliAmps), but they're not strong enough to run motors and other power-hungry parts. (This motor needs 50-100mA). Because the motor needs more current than an Arduino pin can provide, we'll use a transistor to do the heavy lifting. A transistor is a solid-state switch. When we give it a small amount of current, it can switch a much larger current. The transistors in your kit (2N2222) can switch up to 200mA. You can turn a transistor on and off using the digitalWrite() function, but you can also use the analogWrite() function to vary the speed of the motor. The analogWrite() function pulses a pin, varying the width of the pulse from 0% to 100%. We call this technique "PWM", for "Pulse-Width Modulation". One thing to keep in mind is that when you lower the speed of a motor using PWM, you're also reducing the torque (strength) of the motor. For PWM values below 50 or so, the motor won't have enough torque to start spinning. It will start spinning when you raise the speed a bit. Hardware connections: Transistor: The transistor has three pins. Looking at the flat side with the pins down, the order is COLLECTOR, BASE, EMITTER. Connect the black wire on the motor to the COLLECTOR pin on the transistor. Connect the BASE pin through a 330 Ohm resistor to digital pin 9. Connect the EMITTER pin to GND. Motor: You've already connected the black wire on the motor to the COLLECTOR pin on the transistor. Connect the other (red) wire on the motor to 5V. Flyback diode: When the motor is spinning and suddenly turned off, the magnetic field inside it collapses, generating a voltage spike. This can damage the transistor. To prevent this, we use a "flyback diode", which diverts the voltage spike away from the transistor. Connect the side of the diode with the band (cathode) to 5V Connect the other side of the diode (anode) to the black wire on the motor. This sketch was written by SparkFun Electronics, with lots of help from the Arduino community. This code is completely free for any use. Visit http://www.arduino.cc to learn about the Arduino. Version 2.0 6/2012 MDG */ // We'll be controlling the motor from pin 9. // This must be one of the PWM-capable pins. const int motorPin = 9; void setup() { // Set up the motor pin to be an output: pinMode(motorPin, OUTPUT); // Set up the serial port: Serial.begin(9600); } void loop() { // Here we've used comments to disable some of the examples. // To try different things, uncomment one of the following lines // and comment the other ones. See the functions below to learn // what they do and how they work. // motorOnThenOff(); // motorOnThenOffWithSpeed(); // motorAcceleration(); serialSpeed(); } // This function turns the motor on and off like the blinking LED. // Try different values to affect the timing. void motorOnThenOff() { int onTime = 3000; // milliseconds to turn the motor on int offTime = 3000; // milliseconds to turn the motor off digitalWrite(motorPin, HIGH); // turn the motor on (full speed) delay(onTime); // delay for onTime milliseconds digitalWrite(motorPin, LOW); // turn the motor off delay(offTime); // delay for offTime milliseconds } // This function alternates between two speeds. // Try different values to affect the timing and speed. void motorOnThenOffWithSpeed() { int Speed1 = 200; // between 0 (stopped) and 255 (full speed) int Time1 = 3000; // milliseconds for speed 1 int Speed2 = 50; // between 0 (stopped) and 255 (full speed) int Time2 = 3000; // milliseconds to turn the motor off analogWrite(motorPin, Speed1); // turns the motor On delay(Time1); // delay for onTime milliseconds analogWrite(motorPin, Speed2); // turns the motor Off delay(Time2); // delay for offTime milliseconds } // This function slowly accelerates the motor to full speed, // then back down to zero. void motorAcceleration() { int speed; int delayTime = 20; // milliseconds between each speed step // accelerate the motor for(speed = 0; speed <= 255; speed++) { analogWrite(motorPin,speed); // set the new speed delay(delayTime); // delay between speed steps } // decelerate the motor for(speed = 255; speed >= 0; speed--) { analogWrite(motorPin,speed); // set the new speed delay(delayTime); // delay between speed steps } } // This function will let you type a speed into the serial // monitor window. Open the serial monitor using the magnifying- // glass icon at the top right of the Arduino window. Then // type your desired speed into the small text entry bar at the // top of the window and click "Send" or press return. The motor // will then operate at that speed. The valid range is 0 to 255. void serialSpeed() { int speed; Serial.println("Type a speed (0-255) into the box above,"); Serial.println("then click [send] or press [return]"); Serial.println(); // Print a blank line // In order to type out the above message only once, // we'll run the rest of this function in an infinite loop: while(true) // "true" is always true, so this will loop forever. { // First we check to see if incoming data is available: while (Serial.available() > 0) { // If it is, we'll use parseInt() to pull out any numbers: speed = Serial.parseInt(); // Because analogWrite() only works with numbers from // 0 to 255, we'll be sure the input is in that range: speed = constrain(speed, 0, 255); // We'll print out a message to let you know that the // number was received: Serial.print("Setting speed to "); Serial.println(speed); // And finally, we'll set the speed of the motor! analogWrite(motorPin, speed); } } }


 
 
 

Recent Posts

See All

Comments


Subscribe Form

Thanks for submitting!

  • Facebook
  • Twitter
  • LinkedIn

©2019 by Explorations in Ed Tech. Proudly created with Wix.com

bottom of page