This mini-studio is intended to introduce some of the other components of the Maker Kit that may be useful for projects.
The objectives of today’s Studio are:
As usual, you should work in a group. Your usual group of four is desirable, but not required. Today’s studio checkout will be performed by TAs. There is no GitHub repo to get/commit.
Take five minutes and summarize what you collectively know about:
A servo is one type of motor used in a lot of interesting projects. This type of servo included in your Photon kit is commonly used in projects where back-and-forth motion is needed.
GND
pinVIN
pinD0
-D7
), but use D0
.Most Arduino-based libraries, including the one used in the Photon, include support for servos like this.
Run the following code:
// Declare a servo object:
Servo servo;
void setup() {
Serial.begin(9600);
servo.attach( D0 );
servo.write( 20 );
}
void loop() {
delay(1000);
}
Try some experiments. You may want to refer to the Particle API’s Servo
documentation.
When the preceding code is running, try to gently move the horn of the servo away from it’s position. What happens? (Be prepared to discuss with a TA)
Try to identify the range of your servo. Note the behavior at the “ends” of the range may seem unusual. What do you think is happening? (Be prepared to discuss with a TA)
Change the setup()
(don’t change loop()
) so it:
attach
es to the servo.write(40)
delay(2000)
detach
es from the servoWhen the code is running, again try to gently move the horn of the servo away from it’s position. What happens? (Be prepared to discuss with a TA)
Small vibration motors are commonly used for Haptic Feedback in wearables and IoT devices.
Connect an LED to the Photon with a 220 Ohm resistor. Write a small sketch to blink the LED (Off for 1s, then On for 1s). Replace the LED with the Pancake Vibration Motor (Unlike the LED, the motor isn’t polarized, so it doesn’t really matter which wire is connected to the lower voltage part of the circuit)
The motor’s wires are extremely small and fragile. You may need to connect wires to the breadboard and then have one of your group members hold the bare end of the motor’s wires to a bare end of the wires to the breadboard. (Or trim back the insulation and wrap the wire around one post of a normal plug-in-wire)
This is an tolerable approach to quickly demonstrate the vibration motor’s general feel, but it isn’t running the motor at it’s full power. Moreover, DC motors should include a flyback diode to prevent a voltage spike due to stopping the current (and the coil of wire in the motor’s electromagnet, which is an inductor and tries to oppose this change). To achieve full power without exceeding your Arduino’s ability to supply current, build the circuit described at Learning About Electronic’s Vibration Motor Circuit. The Maker Kit contains all the parts you need:
A more thorough treatment of using Arduinos and other microcontrollers to control simple DC motors is given in Gerald Recktenwald’s Basic DC Motor Circuits.
None for this!