Servo
Project #8: Servo – Moteino R2 (RFM12B) – Mk02
——
#DonLucElectronics #DonLuc #Servo #Moteino #Transceiver #RadioFrequency #Pololu #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant
——
——
——
——
Moteino
Moteino began as a low power wireless Arduino compatible development platform based on the popular ATmega328p chip used in the Arduino UNO. There are now several Moteino development boards including MoteinoMEGA based on the Atmega1284P and MoteinoM0 based on the SAMD21G18 Cortex M0+. For programming you will need an external FTDI-Adapter to load sketches, the advantages being lower cost, smaller size.
Servo Motor
A servo motor is a rotary actuator or linear actuator that allows for precise control of angular or linear position, velocity and acceleration. It consists of a suitable motor coupled to a sensor for position feedback. It also requires a relatively sophisticated controller, often a dedicated module designed specifically for use with servo motors.
Servo motors have been around for a long time and are utilized in many applications. They are small in size but pack a big punch and are very energy-efficient. These features allow them to be used to operate remote-controlled or radio-controlled toy cars, robots and airplanes. Servo motors are also used in industrial applications, robotics, in-line manufacturing, pharmaceutics and food services.
Pololu Adjustable Boost Regulator 2.5-9.5 Volt
This powerful, adjustable boost regulator can generate an output voltage as high as 9.5 Volt from an input voltage as low as 1.5 Volt, all in a compact. A trimmer potentiometer lets you set the boost regulator’s output voltage to a value between 2.5 and 9.5 Volt.
DL2310Mk03
2 x Moteino R2 (Transceiver RFM12B)
1 x Pololu Adjustable Boost Regulator 2.5-9.5V
2 x Lithium Ion Battery – 1Ah
1 x Sub-Micro Servo 3.7g
1 x LED Green
1 x Tactile Button
1 x Resistor 10K Ohm
1 x SparkFun FTDI Basic Breakout – 5V
1 x SparkFun Cerberus USB Cable
Moteino R2 (Send)
TR0 – Digital 2
TBI – Digital 6
LED – Digital 9
TR1 – Digital 10
TR2 – Digital 11
TR3 – Digital 12
TR4 – Digital 13
VIN – +5V
VIN – +3.3V
GND – GND
——
DL2310Mk03ps.ino
/* ***** Don Luc Electronics © ***** Software Version Information Project #8: Servo - Radio Frequency - Mk02 6-02 Send DL2310Mk03ps.ino 2 x Moteino R2 (Transceiver RFM12B) 1 x Pololu Adjustable Boost Regulator 2.5-9.5V 2 x Lithium Ion Battery - 1Ah 1 x Sub-Micro Servo 3.7g 1 x LED Green 1 x Tactile Button 1 x Resistor 10K Ohm 1 x SparkFun FTDI Basic Breakout - 5V 1 x SparkFun Cerberus USB Cable */ // Include the Library Code // RFM12B Radio #include <RFM12B.h> // Sleep #include <avr/sleep.h> // You will need to initialize the radio by telling it what ID // it has and what network it's on // The NodeID takes values from 1-127, 0 is reserved for sending // broadcast messages (send to all nodes) // The Network ID takes values from 0-255 // By default the SPI-SS line used is D10 on Atmega328. // You can change it by calling .SetCS(pin) where pin can be {8,9,10} // Network ID used for this unit #define NODEID 2 // The network ID we are on #define NETWORKID 99 // The node ID we're sending to #define GATEWAYID 1 // # of ms to wait for an ack #define ACK_TIME 50 // Serial #define SERIAL_BAUD 115200 // Encryption is OPTIONAL // to enable encryption you will need to: // - provide a 16-byte encryption KEY (same on all nodes that talk encrypted) // - to call .Encrypt(KEY) to start encrypting // - to stop encrypting call .Encrypt(NULL) uint8_t KEY[] = "ABCDABCDABCDABCD"; // Wait this many ms between sending packets int interPacketDelay = 50; // Input char input = 0; // Need an instance of the RFM12B Radio Module RFM12B radio; // Send Size byte sendSize = 0; // Payload char payload[100]; // Request ACK bool requestACK = false; // LED int iLED = 9; // The number of the Tactile Button pin int iTButton = 6; // Variable for reading the button status int TButtonState = 0; // The previous reading from the input pin int lastTButtonState = LOW; // The following variables are unsigned longs // because the time, measured in // milliseconds, will quickly become a bigger // number than can be stored in an int. // The last time the output pin was toggled unsigned long lastDebounceTime = 0; // The debounce time; increase if the output flickers unsigned long debounceDelay = 50; // String String zzzzzz = ""; int iSER = 0; // Software Version Information String sver = "8-02"; void loop() { // Tactile Button isTButton(); // is RFM12B Radio isRFM12BRadio(); // Inter Packet Delay delay(interPacketDelay); }
getRFM12BRadio.ino
// RFM12B Radio void isSetupRFM12BRadio(){ // RFM12B Radio radio.Initialize(NODEID, RF12_433MHZ, NETWORKID); // Encryption radio.Encrypt(KEY); // Sleep right away to save power radio.Sleep(); // Transmitting Serial.println("Transmitting...\n\n"); } // is RFM12 BRadio void isRFM12BRadio(){ // zzzzzz "" zzzzzz = ""; // zzzzz = "<SER|" + iSER + "|*"; zzzzzz = "<SER|"; zzzzzz = zzzzzz + iSER; zzzzzz = zzzzzz + "|*"; // sendSize Length sendSize = zzzzzz.length(); // sendSize payload[sendSize]; // sendSize, charAt for(byte i = 0; i < sendSize+1; i++){ payload[i] = zzzzzz.charAt(i); } // payload Serial.print(payload); // Request ACK requestACK = sendSize; // Wakeup radio.Wakeup(); // Turn the LED on HIGH digitalWrite( iLED , HIGH); // Send radio.Send(GATEWAYID, payload, sendSize, requestACK); // Request ACK if (requestACK) { Serial.print(" - waiting for ACK..."); if (waitForAck()){ Serial.print("Ok!"); } else Serial.print("nothing..."); } // Turn the LED on LOW digitalWrite( iLED , LOW); // Sleep radio.Sleep(); // Serial Serial.println(); } // Wait a few milliseconds for proper ACK, return true if received static bool waitForAck(){ // Now long now = millis(); // ACK while (millis() - now <= ACK_TIME){ if (radio.ACKReceived(GATEWAYID)){ return true; } } return false; }
getTButton.ino
// Tactile Button void isTButton(){ // Read the state of the Button value: int reading = digitalRead(iTButton); // Check to see if you just pressed the TButton // (i.e. the input went from LOW to HIGH), and you've waited long enough // since the last press to ignore any noise: // If the TButton changed, due to noise or pressing: if (reading != lastTButtonState) { // Reset the debouncing timer lastDebounceTime = millis(); } if ((millis() - lastDebounceTime) > debounceDelay) { // Whatever the reading is at, it's been there for // longer than the debounce // delay, so take it as the actual current state: // if the button state has changed: if (reading != TButtonState) { TButtonState = reading; // Check if the TButton is pressed. If it is, the TButtonState is HIGH: if (TButtonState == HIGH) { iSER = 1; } else { iSER = 0; } } } // Save the reading. Next time through the loop, // it'll be the lastTButtonState: lastTButtonState = reading; }
setup.ino
// Setup void setup(){ // Serial Serial.begin(SERIAL_BAUD); // LED pinMode( iLED , OUTPUT); // Initialize the Button pin as an input pinMode(iTButton, INPUT); // Setup RFM12B Radio isSetupRFM12BRadio(); }
Moteino R2 (Receive)
TR0 – Digital 2
LED – Digital 9
TR1 – Digital 10
TR2 – Digital 11
TR3 – Digital 12
TR4 – Digital 13
VIN – +5V
VIN – +3.3V
GND – GND
—
DL2310Mk03Mkpr.ino
/* ***** Don Luc Electronics © ***** Software Version Information Project #8: Servo - Radio Frequency - Mk02 6-02 Receive DL2310Mk03pr.ino 2 x Moteino R2 (RFM12B) 1 x Pololu Adjustable Boost Regulator 2.5-9.5V 2 x Lithium Ion Battery - 1Ah 1 x Sub-Micro Servo 3.7g 1 x LED Green 1 x Tactile Button 1 x Resistor 10K Ohm 1 x SparkFun FTDI Basic Breakout - 5V 1 x SparkFun Cerberus USB Cable */ // Include the Library Code // RFM12B Radio #include <RFM12B.h> // Servo #include <Servo.h> // You will need to initialize the radio by telling it what ID // it has and what network it's on // The NodeID takes values from 1-127, 0 is reserved for sending // broadcast messages (send to all nodes) // The Network ID takes values from 0-255 // By default the SPI-SS line used is D10 on Atmega328. // You can change it by calling .SetCS(pin) where pin can be {8,9,10} // Network ID used for this unit #define NODEID 1 // The network ID we are on #define NETWORKID 99 // Serial #define SERIAL_BAUD 115200 // Encryption is OPTIONAL // to enable encryption you will need to: // - provide a 16-byte encryption KEY (same on all nodes that talk encrypted) // - to call .Encrypt(KEY) to start encrypting // - to stop encrypting call .Encrypt(NULL) uint8_t KEY[] = "ABCDABCDABCDABCD"; // Need an instance of the RFM12B Radio Module RFM12B radio; // Message String msg = ""; // Servo int iSER = 0; String sSER = ""; int firstClosingBracket = 0; // LED int iLED = 9; int iLEDG = 7; // Servo control Servo serv; const int pinServo = 6; // Software Version Information String sver = "8-02"; void loop() { // is RFM12B Radio isRFM12BRadio(); }
getRFM12BRadio.ino
// RFM12B Radio void isSetupRFM12BRadio() { // RFM12B Radio radio.Initialize(NODEID, RF12_433MHZ, NETWORKID); // Encryption radio.Encrypt(KEY); // Transmitting Serial.println("Listening..."); } // is RFM12 BRadio void isRFM12BRadio() { // Receive if (radio.ReceiveComplete()) { // CRC Pass if (radio.CRCPass()) { // Serial Serial.print('['); Serial.print(radio.GetSender()); Serial.print("] "); // Message msg = ""; // Can also use radio.GetDataLen() if you don't like pointers for (byte i = 0; i < *radio.DataLen; i++) { Serial.print((char)radio.Data[i]); msg = msg + (char)radio.Data[i]; } // Turn the LED on HIGH digitalWrite( iLED , HIGH); // Servo isServo(); // ACK Requested if (radio.ACKRequested()) { // Send ACK radio.SendACK(); Serial.print(" - ACK Sent"); } // Turn the LED on LOW digitalWrite( iLED , LOW); } else { // BAD-CRC Serial.print("BAD-CRC"); } // Serial Serial.println(); } }
getServo.ino
// Servo void isServo(){ // Message //Serial.println( msg ); // msg = "<SER|0|*"; firstClosingBracket = 0; // "<SER|" firstClosingBracket = msg.indexOf('|'); //Serial.println( msg ); msg.remove(0, 5); //Serial.println( msg ); // Servo firstClosingBracket = msg.indexOf('|'); sSER = msg; sSER.remove(firstClosingBracket); //Serial.println( sSER ); iSER = sSER.toInt(); //Serial.println( iSER ); int x = iSER; if (x == 1) { digitalWrite(iLEDG, HIGH); // Set servo to unlock serv.write( 0 ); delay(15); } else { digitalWrite(iLEDG, LOW); // Set servo to lock serv.write( 90 ); delay(15); } }
setup.ino
// Setup void setup() { // Serial Serial.begin(SERIAL_BAUD); // LED pinMode( iLED , OUTPUT); pinMode( iLEDG , OUTPUT); // Attach Servo serv.attach( pinServo ); // RFM12B Radio isSetupRFM12BRadio(); }
——
People can contact us: https://www.donluc.com/?page_id=1927
Teacher, Instructor, E-Mentor, R&D and Consulting
- Programming Language
- Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi, Arm, Silicon Labs, Espressif, Etc…)
- IoT
- Wireless (Radio Frequency, Bluetooth, WiFi, Etc…)
- Robotics
- Automation
- Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
- Unmanned Vehicles Terrestrial and Marine
- Machine Learning
- Artificial Intelligence (AI)
- RTOS
- eHealth Sensors, Biosensor, and Biometric
- Research & Development (R & D)
- Consulting
Follow Us
Luc Paquin – Curriculum Vitae – 2023
https://www.donluc.com/luc/
Web: https://www.donluc.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/@thesass2063
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/
Don Luc
Project #14: Components – Pan/Tilt Bracket Kit – Mk04
——
——
——
SparkFun Item: ROB-14391
This is an easy-to-assemble pan/tilt bracket kit that utilizes servos to move on two axes fit for camera and helping-hand applications. Everything is included to get this kit assembled, even the servos.
Follow Us
J. Luc Paquin – Curriculum Vitae
https://www.donluc.com/DLHackster/LucPaquinCVEngMk2020a.pdf
Web: https://www.donluc.com/
Web: http://www.jlpconsultants.com/
Web: https://www.donluc.com/DLHackster/
Web: https://www.hackster.io/neosteam-labs
Web: http://neosteamlabs.com/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Facebook: https://www.facebook.com/neosteam.labs.9/
Instagram: https://www.instagram.com/neosteamlabs/
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Twitter: https://twitter.com/labs_steam
Etsy: https://www.etsy.com/shop/NeoSteamLabs
Don Luc
Project #12: Robotics – 5-Way Switch – Mk04
——
——
——
——
——
——
——
SparkFun 5-Way Tactile Switch Breakout
This 5-way tactile switch (up, down, left, right, and center click) allows for joystick-like control in a very small package.
DL1912Mk03
1 x Adafruit RGB LCD Shield 16×2 Character Display
1 x Arduino UNO – R3
1 x ProtoScrewShield
2 x EasyDriver – Stepper Motor Driver
1 x Small Stepper Motor
1 x Pololu Mounting
1 x Symbol Stepper Motor
2 x RC Servo Motor
2 x Potentiometer 1M Ohm
2 x Knob
2 x LED Red
1 x Rocker Switches
1 x Laser Red
1 x SparkFun 5-Way Tactile Switch Breakout
1 x LED Green
1 x LED Bi-Colour
1 x LED Yellow
17 x Jumper Wires 3″ M/M
31 x Jumper Wires 6″ M/M
4 x Half-Size Breadboard
Arduino UNO
SP1 – Digital 3
DI1 – Digital 2
SP2 – Digital 5
DI2 – Digital 4
SV1 – Digital 6
PO1 – Analog A0
SV2 – Digital 7
PO2 – Analog A1
VIN – +5V
GND – GND
DL1912Mk03.ino
// ***** Don Luc Electronics © ***** // Software Version Information // Project #12: Robotics - 5-Way Switch - Mk04 // 12-03 // DL1912Mk02p.ino 12-04 // Arduino UNO // Screw Shield // Adafruit RGB LCD Shield // 1 x Small Stepper Motor // 1 x Symbol Stepper Motor // 2 x EasyDriver // 2 x RC Servo Motor // 2 x Potentiometer // 2 x LED Red // 1 x Rocker Switches // 1 x Laser Red // 1 x SparkFun 5-Way Tactile Switch Breakout // 1 x LED Green // 1 x LED Bi-Colour // 1 x LED Yellow // include the library code: #include <Adafruit_RGBLCDShield.h> #include <Servo.h> // Adafruit RGB LCD Shield Adafruit_RGBLCDShield RGBLCDShield = Adafruit_RGBLCDShield(); // These #defines make it easy to set the backlight color #define OFF 0x0 #define RED 0x1 #define YELLOW 0x3 #define GREEN 0x2 #define TEAL 0x6 #define BLUE 0x4 #define VIOLET 0x5 #define WHITE 0x7 // Momentary Button int yy = 0; uint8_t momentaryButton = 0; // 2 x EasyDriver int dirPinR = 2; // EasyDriver Right int stepPinR = 3; // stepPin Right int dirPinL = 4; // EasyDriver Left int stepPinL = 5; // stepPin Left int i = 0; // 2 x RC Servo Motor // 2 x Potentiometer Servo isRCServo1; // Create servo object to control a RCServo1 int servo1 = 6; // Servo 1 int iPot1 = A0; // Analog Potentiometer 1 int iVal1; // Variable - Analog Potentiometer 1 Servo isRCServo2; // Create servo object to control a RCServo2 int servo2 = 7; // Servo 2 int iPot2 = A1; // Analog Potentiometer 2 int iVal2; // Variable - Analog Potentiometer 2 void loop() { // Clear RGBLCDShield.clear(); // Momentary Button momentaryButton = RGBLCDShield.readButtons(); switch ( yy ) { case 1: // Up isSwitch1(); break; case 2: // Down isSwitch2(); break; case 3: // Right isSwitch3(); break; case 4: // Left isSwitch4(); break; case 5: // Stop isSwitch5(); break; default: // Stop yy = 5; RGBLCDShield.setBacklight(RED); isSwitch5(); } if ( momentaryButton ) { if ( momentaryButton & BUTTON_UP ) { yy = 1; // Up RGBLCDShield.setBacklight(GREEN); } if ( momentaryButton & BUTTON_DOWN ) { yy = 2; // Down RGBLCDShield.setBacklight(VIOLET); } if ( momentaryButton & BUTTON_LEFT ) { yy = 3; // Right RGBLCDShield.setBacklight(TEAL); } if ( momentaryButton & BUTTON_RIGHT ) { yy = 4; // Left RGBLCDShield.setBacklight(YELLOW); } if ( momentaryButton & BUTTON_SELECT ) { yy = 5; // Stop RGBLCDShield.setBacklight(RED); } } }
getServo.ino
// Servo // isServoSetup void isServoSetup() { // 2 x RC Servo Motor isRCServo1.attach( servo1 ); isRCServo2.attach( servo2 ); } // isServo1 void isServo1() { // EasyDriver isStepperStop(); // Potentiometer RC Servo Motor 1 iVal1 = analogRead( iPot1 ); // Reads the value of the iPot1 (Value between 0 and 1023) iVal1 = map(iVal1, 0, 1023, 0, 180); // Scale it to use it with the isRCServo1 (Value between 0 and 180) isRCServo1.write( iVal1 ); // isRCServo1 sets the servo position according to the scaled value delay(15); // Display // Set the cursor to column 0, line 0 RGBLCDShield.setCursor(0,0); RGBLCDShield.print("RC Servo 1"); // RC Servo 1 // Set the cursor to column 0, line 1 RGBLCDShield.setCursor(0, 1); RGBLCDShield.print( iVal1 ); // Reads the value iVal1 delay(500); } // isServo2 void isServo2() { // EasyDriver isStepperStop(); // Potentiometer RC Servo Motor 1 iVal2 = analogRead( iPot2 ); // Reads the value of the iPot2 (Value between 0 and 1023) iVal2 = map(iVal2, 0, 1023, 0, 180); // Scale it to use it with the isRCServo2 (Value between 0 and 180) isRCServo2.write( iVal2 ); // isRCServo2 sets the servo position according to the scaled value delay(15); // Display // Set the cursor to column 0, line 0 RGBLCDShield.setCursor(0,0); RGBLCDShield.print("RC Servo 2"); // RC Servo 2 // Set the cursor to column 0, line 1 RGBLCDShield.setCursor(0, 1); RGBLCDShield.print( iVal2 ); // Reads the value iVal2 delay(500); }
getStepper.ino
// Stepper // isStepperSetup void isStepperSetup() { // 2 x EasyDriver pinMode(dirPinR, OUTPUT); pinMode(stepPinR, OUTPUT); pinMode(dirPinL, OUTPUT); pinMode(stepPinL, OUTPUT); } // isStepper1 void isStepper1(){ // set the cursor to column 0, line 0 RGBLCDShield.setCursor(0,0); RGBLCDShield.print("EasyDriver"); // EasyDriver RGBLCDShield.setCursor(0,1); RGBLCDShield.print("Small Stepper"); // Small Stepper delay(500); // EasyDriver digitalWrite(dirPinR, LOW); // Set the direction. delay(100); for (i = 0; i<300; i++) // Iterate for 1000 microsteps. { digitalWrite(stepPinR, LOW); // This LOW to HIGH change is what creates the digitalWrite(stepPinR, HIGH); // "Rising Edge" so the easydriver knows to when to step. delayMicroseconds(170); // This delay time is close to top speed. } } // isStepper2 void isStepper2(){ // set the cursor to column 0, line 0 RGBLCDShield.setCursor(0,0); RGBLCDShield.print("EasyDriver"); // EasyDriver RGBLCDShield.setCursor(0,1); RGBLCDShield.print("Symbol Stepper"); // Symbol Stepper delay(500); // EasyDriver digitalWrite(dirPinL, HIGH); // Set the direction. delay(100); for (i = 0; i<300; i++) // Iterate for 1000 microsteps. { digitalWrite(stepPinL, LOW); // This LOW to HIGH change is what creates the digitalWrite(stepPinL, HIGH); // "Rising Edge" so the easydriver knows to when to step. delayMicroseconds(170); // This delay time is close to top speed. } } // isStepperStop void isStepperStop() { // 2 x EasyDriver digitalWrite(dirPinR, LOW); // Set the direction. delay(100); digitalWrite(dirPinL, LOW); // Set the direction. delay(100); digitalWrite(stepPinR, LOW); // This LOW to HIGH change is what creates the digitalWrite(stepPinL, LOW); // This LOW to HIGH change is what creates the }
getSwitch.ino
// Switch // Switch 1 void isSwitch1(){ // Small Stepper yy = 1; // EasyDriver isStepper1(); } // Switch 2 void isSwitch2(){ // Symbol Stepper yy = 2; // EasyDriver isStepper2(); } // Switch 3 void isSwitch3(){ // RC Servo Motor 1 yy = 3; // Potentiometer RC Servo Motor 1 isServo1(); } // Switch 4 void isSwitch4(){ // RC Servo Motor 2 yy = 4; // Potentiometer RC Servo Motor 2 isServo2(); } // Switch 5 void isSwitch5(){ // Stop yy = 5; // set the cursor to column 0, line 0 RGBLCDShield.setCursor(0,0); RGBLCDShield.print("Robotics"); // Robotics RGBLCDShield.setCursor(0,1); RGBLCDShield.print("Stop"); delay( 500 ); // EasyDriver isStepperStop(); }
setup.ino
// Setup void setup() { // Adafruit RGB LCD Shield // Set up the LCD's number of columns and rows: RGBLCDShield.begin(16, 2); RGBLCDShield.setBacklight(GREEN); // Display // Set the cursor to column 0, line 0 RGBLCDShield.setCursor(0,0); RGBLCDShield.print("Don Luc Electron"); // Don luc Electron // Set the cursor to column 0, line 1 RGBLCDShield.setCursor(0, 1); RGBLCDShield.print("Robotics"); // EasyDriver delay(5000); // Clear RGBLCDShield.clear(); // 2 x EasyDriver isStepperSetup(); // 2 x RC Servo Motor isServoSetup(); }
Follow Us
Web: https://www.donluc.com/
Web: http://www.jlpconsultants.com/
Web: https://www.donluc.com/DLHackster/
Web: https://www.hackster.io/neosteam-labs
Web: http://neosteamlabs.com/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Facebook: https://www.facebook.com/neosteam.labs.9/
Instagram: https://www.instagram.com/neosteamlabs/
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Twitter: https://twitter.com/labs_steam
Etsy: https://www.etsy.com/shop/NeoSteamLabs
Don Luc
Project #12: Robotics – Laser Diode – Mk03
——
——
——
——
——
——
Laser Diode
A laser diode is a semiconductor device similar to a light-emitting diode in which a diode pumped directly with electrical current can create lasing conditions at the diode’s junction. Laser diodes can directly convert electrical energy into light. Due to the drop of the electron from a higher energy level to a lower one, radiation, in the form of an emitted photon is generated. This is spontaneous emission. Stimulated emission can be produced when the process is continued and further generate light with the same phase, coherence and wavelength.
The choice of the semiconductor material determines the wavelength of the emitted beam, which in today’s laser diodes range from infra-red to the UV spectrum. Laser diodes are the most common type of lasers produced, with a wide range of uses that include fiber optic communications, barcode readers, laser pointers, CD/DVD/Blu-ray disc reading/recording, laser printing, laser scanning and light beam illumination. With the use of a phosphor like that found on white LEDs, Laser diodes can be used for general illumination.
DL1912Mk02
1 x Adafruit RGB LCD Shield 16×2 Character Display
1 x Arduino UNO – R3
1 x ProtoScrewShield
2 x EasyDriver – Stepper Motor Driver
1 x Small Stepper Motor
1 x Pololu Mounting
1 x Symbol Stepper Motor
2 x RC Servo Motor
2 x Potentiometer 1M Ohm
2 x Knob
1 x LED Red
1 x Rocker Switches
1 x Laser Red
5 x Jumper Wires 3″ M/M
29 x Jumper Wires 6″ M/M
3 x Half-Size Breadboard
Arduino UNO
SP1 – Digital 3
DI1 – Digital 2
SP2 – Digital 5
DI2 – Digital 4
SV1 – Digital 6
PO1 – Analog A0
SV2 – Digital 7
PO2 – Analog A1
VIN – +5V
GND – GND
DL1912Mk02.ino
// ***** Don Luc Electronics © ***** // Software Version Information // Project #12: Robotics - Laser Diode - Mk03 // 12-02 // DL1912Mk02p.ino 12-03 // Arduino UNO // Screw Shield // Adafruit RGB LCD Shield // 1 x Small Stepper Motor // 1 x Symbol Stepper Motor // 2 x EasyDriver // 2 x RC Servo Motor // 2 x Potentiometer // 1 x LED Red // 1 x Rocker Switches // 1 x Laser Red // include the library code: #include <Adafruit_RGBLCDShield.h> #include <Servo.h> // Adafruit RGB LCD Shield Adafruit_RGBLCDShield RGBLCDShield = Adafruit_RGBLCDShield(); // These #defines make it easy to set the backlight color #define OFF 0x0 #define RED 0x1 #define YELLOW 0x3 #define GREEN 0x2 #define TEAL 0x6 #define BLUE 0x4 #define VIOLET 0x5 #define WHITE 0x7 // Momentary Button int yy = 0; uint8_t momentaryButton = 0; // 2 x EasyDriver int dirPinR = 2; // EasyDriver Right int stepPinR = 3; // stepPin Right int dirPinL = 4; // EasyDriver Left int stepPinL = 5; // stepPin Left int i = 0; // 2 x RC Servo Motor // 2 x Potentiometer Servo isRCServo1; // Create servo object to control a RCServo1 int servo1 = 6; // Servo 1 int iPot1 = A0; // Analog Potentiometer 1 int iVal1; // Variable - Analog Potentiometer 1 Servo isRCServo2; // Create servo object to control a RCServo2 int servo2 = 7; // Servo 2 int iPot2 = A1; // Analog Potentiometer 2 int iVal2; // Variable - Analog Potentiometer 2 void loop() { // Clear RGBLCDShield.clear(); // Momentary Button momentaryButton = RGBLCDShield.readButtons(); switch ( yy ) { case 1: // Up isSwitch1(); break; case 2: // Down isSwitch2(); break; case 3: // Right isSwitch3(); break; case 4: // Left isSwitch4(); break; case 5: // Stop isSwitch5(); break; default: // Stop yy = 5; RGBLCDShield.setBacklight(RED); isSwitch5(); } if ( momentaryButton ) { if ( momentaryButton & BUTTON_UP ) { yy = 1; // Up RGBLCDShield.setBacklight(GREEN); } if ( momentaryButton & BUTTON_DOWN ) { yy = 2; // Down RGBLCDShield.setBacklight(VIOLET); } if ( momentaryButton & BUTTON_LEFT ) { yy = 3; // Right RGBLCDShield.setBacklight(TEAL); } if ( momentaryButton & BUTTON_RIGHT ) { yy = 4; // Left RGBLCDShield.setBacklight(YELLOW); } if ( momentaryButton & BUTTON_SELECT ) { yy = 5; // Stop RGBLCDShield.setBacklight(RED); } } }
getServo.ino
// Servo // isServoSetup void isServoSetup() { // 2 x RC Servo Motor isRCServo1.attach( servo1 ); isRCServo2.attach( servo2 ); } // isServo1 void isServo1() { // EasyDriver isStepperStop(); // Potentiometer RC Servo Motor 1 iVal1 = analogRead( iPot1 ); // Reads the value of the iPot1 (Value between 0 and 1023) iVal1 = map(iVal1, 0, 1023, 0, 180); // Scale it to use it with the isRCServo1 (Value between 0 and 180) isRCServo1.write( iVal1 ); // isRCServo1 sets the servo position according to the scaled value delay(15); // Display // Set the cursor to column 0, line 0 RGBLCDShield.setCursor(0,0); RGBLCDShield.print("RC Servo 1"); // RC Servo 1 // Set the cursor to column 0, line 1 RGBLCDShield.setCursor(0, 1); RGBLCDShield.print( iVal1 ); // Reads the value iVal1 delay(500); } // isServo2 void isServo2() { // EasyDriver isStepperStop(); // Potentiometer RC Servo Motor 1 iVal2 = analogRead( iPot2 ); // Reads the value of the iPot2 (Value between 0 and 1023) iVal2 = map(iVal2, 0, 1023, 0, 180); // Scale it to use it with the isRCServo2 (Value between 0 and 180) isRCServo2.write( iVal2 ); // isRCServo2 sets the servo position according to the scaled value delay(15); // Display // Set the cursor to column 0, line 0 RGBLCDShield.setCursor(0,0); RGBLCDShield.print("RC Servo 2"); // RC Servo 2 // Set the cursor to column 0, line 1 RGBLCDShield.setCursor(0, 1); RGBLCDShield.print( iVal2 ); // Reads the value iVal2 delay(500); }
getStepper.ino
// Stepper // isStepperSetup void isStepperSetup() { // 2 x EasyDriver pinMode(dirPinR, OUTPUT); pinMode(stepPinR, OUTPUT); pinMode(dirPinL, OUTPUT); pinMode(stepPinL, OUTPUT); } // isStepper1 void isStepper1(){ // set the cursor to column 0, line 0 RGBLCDShield.setCursor(0,0); RGBLCDShield.print("EasyDriver"); // EasyDriver RGBLCDShield.setCursor(0,1); RGBLCDShield.print("Small Stepper"); // Small Stepper delay(500); // EasyDriver digitalWrite(dirPinR, LOW); // Set the direction. delay(100); for (i = 0; i<300; i++) // Iterate for 1000 microsteps. { digitalWrite(stepPinR, LOW); // This LOW to HIGH change is what creates the digitalWrite(stepPinR, HIGH); // "Rising Edge" so the easydriver knows to when to step. delayMicroseconds(170); // This delay time is close to top speed. } } // isStepper2 void isStepper2(){ // set the cursor to column 0, line 0 RGBLCDShield.setCursor(0,0); RGBLCDShield.print("EasyDriver"); // EasyDriver RGBLCDShield.setCursor(0,1); RGBLCDShield.print("Symbol Stepper"); // Symbol Stepper delay(500); // EasyDriver digitalWrite(dirPinL, HIGH); // Set the direction. delay(100); for (i = 0; i<300; i++) // Iterate for 1000 microsteps. { digitalWrite(stepPinL, LOW); // This LOW to HIGH change is what creates the digitalWrite(stepPinL, HIGH); // "Rising Edge" so the easydriver knows to when to step. delayMicroseconds(170); // This delay time is close to top speed. } } // isStepperStop void isStepperStop() { // 2 x EasyDriver digitalWrite(dirPinR, LOW); // Set the direction. delay(100); digitalWrite(dirPinL, LOW); // Set the direction. delay(100); digitalWrite(stepPinR, LOW); // This LOW to HIGH change is what creates the digitalWrite(stepPinL, LOW); // This LOW to HIGH change is what creates the }
getSwitch.ino
// Switch // Switch 1 void isSwitch1(){ // Small Stepper yy = 1; // EasyDriver isStepper1(); } // Switch 2 void isSwitch2(){ // Symbol Stepper yy = 2; // EasyDriver isStepper2(); } // Switch 3 void isSwitch3(){ // RC Servo Motor 1 yy = 3; // Potentiometer RC Servo Motor 1 isServo1(); } // Switch 4 void isSwitch4(){ // RC Servo Motor 2 yy = 4; // Potentiometer RC Servo Motor 2 isServo2(); } // Switch 5 void isSwitch5(){ // Stop yy = 5; // set the cursor to column 0, line 0 RGBLCDShield.setCursor(0,0); RGBLCDShield.print("Robotics"); // Robotics RGBLCDShield.setCursor(0,1); RGBLCDShield.print("Stop"); delay( 500 ); // EasyDriver isStepperStop(); }
setup.ino
// Setup void setup() { // Adafruit RGB LCD Shield // Set up the LCD's number of columns and rows: RGBLCDShield.begin(16, 2); RGBLCDShield.setBacklight(GREEN); // Display // Set the cursor to column 0, line 0 RGBLCDShield.setCursor(0,0); RGBLCDShield.print("Don Luc Electron"); // Don luc Electron // Set the cursor to column 0, line 1 RGBLCDShield.setCursor(0, 1); RGBLCDShield.print("Robotics"); // EasyDriver delay(5000); // Clear RGBLCDShield.clear(); // 2 x EasyDriver isStepperSetup(); // 2 x RC Servo Motor isServoSetup(); }
Follow Us
Web: https://www.donluc.com/
Web: http://neosteamlabs.com/
Web: http://www.jlpconsultants.com/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Facebook: https://www.facebook.com/neosteam.labs.9/
Instagram: https://www.instagram.com/neosteamlabs/
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Twitter: https://twitter.com/labs_steam
Etsy: https://www.etsy.com/shop/NeoSteamLabs
Don Luc
Project #12: Robotics – RC Servo Motor – Mk02
——
——
——
——
——
——
——
——
——
Servo (Radio Control)
Servos (also RC servos) are small, cheap, mass-produced servomotors or other actuators used for radio control and small-scale robotics.
Radio control servos are connected through a standard three-wire connection: two wires for a DC power supply and one for control, carrying a pulse-width modulation (PWM) signal. Each servo has a separate connection and PWM signal from the radio control receiver. This signal is easily generated by simple electronics, or by microcontrollers such as the Arduino. This, together with their low-cost, has led to their wide adoption for robotics and physical computing.
DL1912Mk01
1 x Adafruit RGB LCD Shield 16×2 Character Display
1 x Arduino UNO – R3
1 x ProtoScrewShield
2 x EasyDriver – Stepper Motor Driver
2 x Small Stepper Motor
2 x Pololu Mounting
2 x RC Servo Motor
2 x Potentiometer 1M Ohm
2 x Knob
4 x Jumper Wires 3″ M/M
22 x Jumper Wires 6″ M/M
3 x Half-Size Breadboard
Arduino UNO
SP1 – Digital 3
DI1 – Digital 2
SP2 – Digital 5
DI2 – Digital 4
SV1 – Digital 6
PO1 – Analog A0
SV2 – Digital 7
PO2 – Analog A1
VIN – +5V
GND – GND
DL1912Mk01.ino
// ***** Don Luc Electronics © ***** // Software Version Information // Project #12: Robotics - RC Servo Motor - Mk02 // 12-01 // DL1912Mk01p.ino 12-02 // Arduino UNO // Screw Shield // Adafruit RGB LCD Shield // 2 x Small Stepper Motor // 2 x EasyDriver // 2 x RC Servo Motor // 2 x Potentiometer // include the library code: #include <Adafruit_RGBLCDShield.h> #include <Servo.h> // Adafruit RGB LCD Shield Adafruit_RGBLCDShield RGBLCDShield = Adafruit_RGBLCDShield(); // These #defines make it easy to set the backlight color #define OFF 0x0 #define RED 0x1 #define YELLOW 0x3 #define GREEN 0x2 #define TEAL 0x6 #define BLUE 0x4 #define VIOLET 0x5 #define WHITE 0x7 // Momentary Button int yy = 0; uint8_t momentaryButton = 0; // 2 x EasyDriver int dirPinR = 2; // EasyDriver Right int stepPinR = 3; // stepPin Right int dirPinL = 4; // EasyDriver Left int stepPinL = 5; // stepPin Left int i = 0; // 2 x RC Servo Motor // 2 x Potentiometer Servo isRCServo1; // Create servo object to control a RCServo1 int servo1 = 6; // Servo 1 int iPot1 = A0; // Analog Potentiometer 1 int iVal1; // Variable - Analog Potentiometer 1 Servo isRCServo2; // Create servo object to control a RCServo2 int servo2 = 7; // Servo 2 int iPot2 = A1; // Analog Potentiometer 2 int iVal2; // Variable - Analog Potentiometer 2 void loop() { // Clear RGBLCDShield.clear(); // Momentary Button momentaryButton = RGBLCDShield.readButtons(); switch ( yy ) { case 1: // Up isSwitch1(); break; case 2: // Down isSwitch2(); break; case 3: // Right isSwitch3(); break; case 4: // Left isSwitch4(); break; case 5: // Stop isSwitch5(); break; default: // Stop yy = 5; RGBLCDShield.setBacklight(RED); isSwitch5(); } if ( momentaryButton ) { if ( momentaryButton & BUTTON_UP ) { yy = 1; // Up RGBLCDShield.setBacklight(GREEN); } if ( momentaryButton & BUTTON_DOWN ) { yy = 2; // Down RGBLCDShield.setBacklight(VIOLET); } if ( momentaryButton & BUTTON_LEFT ) { yy = 3; // Right RGBLCDShield.setBacklight(TEAL); } if ( momentaryButton & BUTTON_RIGHT ) { yy = 4; // Left RGBLCDShield.setBacklight(YELLOW); } if ( momentaryButton & BUTTON_SELECT ) { yy = 5; // Stop RGBLCDShield.setBacklight(RED); } } }
getServo.ino
// Servo // isServoSetup void isServoSetup() { // 2 x RC Servo Motor isRCServo1.attach( servo1 ); isRCServo2.attach( servo2 ); } // isServo1 void isServo1() { // EasyDriver isStepperStop(); // Potentiometer RC Servo Motor 1 iVal1 = analogRead( iPot1 ); // Reads the value of the iPot1 (Value between 0 and 1023) iVal1 = map(iVal1, 0, 1023, 0, 180); // Scale it to use it with the isRCServo1 (Value between 0 and 180) isRCServo1.write( iVal1 ); // isRCServo1 sets the servo position according to the scaled value delay(15); // Display // Set the cursor to column 0, line 0 RGBLCDShield.setCursor(0,0); RGBLCDShield.print("isRCServo 1"); // isRCServo 1 // Set the cursor to column 0, line 1 RGBLCDShield.setCursor(0, 1); RGBLCDShield.print( iVal1 ); // Reads the value iVal1 delay(500); } // isServo2 void isServo2() { // EasyDriver isStepperStop(); // Potentiometer RC Servo Motor 1 iVal2 = analogRead( iPot2 ); // Reads the value of the iPot2 (Value between 0 and 1023) iVal2 = map(iVal2, 0, 1023, 0, 180); // Scale it to use it with the isRCServo2 (Value between 0 and 180) isRCServo2.write( iVal2 ); // isRCServo2 sets the servo position according to the scaled value delay(15); // Display // Set the cursor to column 0, line 0 RGBLCDShield.setCursor(0,0); RGBLCDShield.print("isRCServo 2"); // isRCServo 2 // Set the cursor to column 0, line 1 RGBLCDShield.setCursor(0, 1); RGBLCDShield.print( iVal2 ); // Reads the value iVal2 delay(500); }
getStepper.ino
// Stepper // isStepperSetup void isStepperSetup() { // 2 x EasyDriver pinMode(dirPinR, OUTPUT); pinMode(stepPinR, OUTPUT); pinMode(dirPinL, OUTPUT); pinMode(stepPinL, OUTPUT); } // isStepper1 void isStepper1(){ // set the cursor to column 0, line 0 RGBLCDShield.setCursor(0,0); RGBLCDShield.print("EasyDriver"); // EasyDriver RGBLCDShield.setCursor(0,1); RGBLCDShield.print("Up"); delay(500); // 2 x EasyDriver digitalWrite(dirPinR, LOW); // Set the direction. delay(100); digitalWrite(dirPinL, LOW); // Set the direction. delay(100); for (i = 0; i<300; i++) // Iterate for 1000 microsteps. { digitalWrite(stepPinR, LOW); // This LOW to HIGH change is what creates the digitalWrite(stepPinR, HIGH); // "Rising Edge" so the easydriver knows to when to step. delayMicroseconds(170); // This delay time is close to top speed. digitalWrite(stepPinL, LOW); // This LOW to HIGH change is what creates the digitalWrite(stepPinL, HIGH); // "Rising Edge" so the easydriver knows to when to step. delayMicroseconds(170); // This delay time is close to top speed. } } // isStepper2 void isStepper2(){ // set the cursor to column 0, line 0 RGBLCDShield.setCursor(0,0); RGBLCDShield.print("EasyDriver"); // EasyDriver RGBLCDShield.setCursor(0,1); RGBLCDShield.print("Down"); delay(500); // 2 x EasyDriver digitalWrite(dirPinR, HIGH); // Set the direction. delay(100); digitalWrite(dirPinL, HIGH); // Set the direction. delay(100); for (i = 0; i<300; i++) // Iterate for 1000 microsteps. { digitalWrite(stepPinR, LOW); // This LOW to HIGH change is what creates the digitalWrite(stepPinR, HIGH); // "Rising Edge" so the easydriver knows to when to step. delayMicroseconds(170); // This delay time is close to top speed. digitalWrite(stepPinL, LOW); // This LOW to HIGH change is what creates the digitalWrite(stepPinL, HIGH); // "Rising Edge" so the easydriver knows to when to step. delayMicroseconds(170); // This delay time is close to top speed. } } // isStepperStop void isStepperStop() { // 2 x EasyDriver digitalWrite(dirPinR, LOW); // Set the direction. delay(100); digitalWrite(dirPinL, LOW); // Set the direction. delay(100); digitalWrite(stepPinR, LOW); // This LOW to HIGH change is what creates the digitalWrite(stepPinL, LOW); // This LOW to HIGH change is what creates the }
getSwitch.ino
// Switch // Switch 1 void isSwitch1(){ // Up yy = 1; // 2 x EasyDriver isStepper1(); } // Switch 2 void isSwitch2(){ // Down yy = 2; // 2 x EasyDriver isStepper2(); } // Switch 3 void isSwitch3(){ // Right yy = 3; // Potentiometer RC Servo Motor 1 isServo1(); } // Switch 4 void isSwitch4(){ // Left yy = 4; // Potentiometer RC Servo Motor 2 isServo2(); } // Switch 5 void isSwitch5(){ // Stop yy = 5; // set the cursor to column 0, line 0 RGBLCDShield.setCursor(0,0); RGBLCDShield.print("Robotics"); // Robotics RGBLCDShield.setCursor(0,1); RGBLCDShield.print("Stop"); delay( 500 ); // EasyDriver isStepperStop(); }
setup.ino
// Setup void setup() { // Adafruit RGB LCD Shield // Set up the LCD's number of columns and rows: RGBLCDShield.begin(16, 2); RGBLCDShield.setBacklight(GREEN); // Display // Set the cursor to column 0, line 0 RGBLCDShield.setCursor(0,0); RGBLCDShield.print("Don Luc Electron"); // Don luc Electron // Set the cursor to column 0, line 1 RGBLCDShield.setCursor(0, 1); RGBLCDShield.print("Robotics"); // EasyDriver delay(5000); // Clear RGBLCDShield.clear(); // 2 x EasyDriver isStepperSetup(); // 2 x RC Servo Motor isServoSetup(); }
Follow Us
Web: https://www.donluc.com/
Web: http://neosteamlabs.com/
Web: http://www.jlpconsultants.com/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Facebook: https://www.facebook.com/neosteam.labs.9/
Instagram: https://www.instagram.com/neosteamlabs/
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Twitter: https://twitter.com/labs_steam
Etsy: https://www.etsy.com/shop/NeoSteamLabs
Don Luc